查看: 58|回复: 3

[提交中] 这样写不对吗?

[复制链接]
  • TA的每日心情

    5 天前
  • 签到天数: 1 天

    [LV.1]初来乍到

    1

    主题

    3

    帖子

    30

    积分

    新手上路

    Rank: 1

    积分
    30
    发表于 前天 08:15 | 显示全部楼层 |阅读模式
    BUG
    引擎版本号: 0507
    BUG描述: NPC
    BUG重现方式: NPC复制进来
    修复后达到的效果: 能用就行。
    联系方式: 2533518890
    -- 这是给这个脚本起个名字,如果有需要可以让其他的脚本直接调用到它。名字我也叫做“仓库-0”
    module("仓库-0", package.seeall)

    -- 下面这句话等同于[@Main]的开始 ,固定格式,参照写即可。
    function main(Npc, Player)
    -- 下面相当于把要SAY的所有文字先存起来到一个变量里,等会SAY要用到。
    local S = [[
    您好。我可以帮你金条与金币相互对换。\
    <开始兑换/@duihuanshuoming>\
    <退出/@exit>\
    ]]

        -- 等同于#SAY上面的文字
        Npc:Say(Player, '', S, false);
    end  --end就相当于整个[@main]的结束


    function duihuanshuoming(Npc, Player)
    local S = [[
    你知道我是什么人吗? \
    我做的是这样的事情... \
    你要试一下吗?有什么要拜托的就说吧 \ \
    \\
    我想<金币换金条/@jinbihuanjintiaoshuoming> \
    我想<金条换金币/@jintiaohuanjinbishuoming> \
    \\
    <离 开/@exit>
    ]]


        Npc:Say(Player, '', S, false);
    end

    function jinbihuanjintiaoshuoming(Npc, Player)
    --LUA脚本可以不用按照固定格式先写#IF
    -- 先把钱够和钱不够的文字堆起来
    local S1 = [[
    你说你要用金币换成金条? \
    好的,我帮你换 \
    但是要支付手续费 \
    费用是2000金币,你还换吗? \ \
    <交换/@jinbihuanjintiao> \
    <离 开/@exit>
    ]]

    local S2 = [[
    你连这点钱都没有,还换什么? \
    等你有足够的钱,再来找我吧 \ \
    <返 回/@Main>
    ]]
        -- 写完了文本再来写#IF  
        -- vvlib:check 作用等同于#IF
        -- 前面的1个参数Player 固定写
        -- CHECKGOLD,2000 等同于 #if的checkgold 2000
        -- 要查阅这里与哪个传统#if命令的对应,请打开const.lua查看。
        if vvlib:check(Player,CHECKGOLD, 2000) then
        -- 如果满足条件金币大于2000就显示帮你换,需要手续费的文字
            Npc:Say(Player, '', S1, false);
        else
        -- 如果没有2000的金币则显示没足够的钱文字
            Npc:Say(Player, '', S2, false);
        end
    end



    function jinbihuanjintiaoshuoming(Npc, Player)
    -- 把换成功和换失败的文字先定义出来
    local S1 = [[
    金币已经换好金条了. \
    还换吗? \ \
    <交换/@jinbihuanjintiaoshuoming> \
    <离 开/@exit>
    ]]

    local S2 = [[
    你的包里东西已经满了,或者你没有足够的钱支付手续费\
    你再确认一下吧 \ \
    <离 开/@exit>
    ]]
        --[[
            以下代码等同于
            #if
            check CHECKBAGSIZE 1
            checkgold 1002000
        --]]


    ------------

    if vvlib:check(Player, CHECKBAGSIZE, 1) and vvlib:check(Player, CHECKGOLD, 1002000)  then
        -- 条件都满足,取走金币给一根金条
            -- gamelib:Action相当于#act
            -- 前三个参数和check的一致
            -- 第四个cmdTAKE,金币,1002000  = #act 的 take 金币 1002000
            vvlib:action(Player,  TAKE, '金币', 1002000);
            -- 等同于 #act的 give 金条 1
            vvlib:action(Player,  GIVE, '金条', 1);
            Npc:Say(Player, '', S1, false);
        else
        -- 如果没有1002000的金币或者没有一格剩余包袱位置则显示失败文字
            Npc:Say(Player, '', S2, false);
        end
    end



    function jintiaohuanjinbishuoming(Npc, Player)
    -- 把换成功和换失败的文字先定义出来
    local S1 = [[
    你要把金条换成金币? \
    好的,我给你换 \
    不过需要支付手续费\
    费用是2000金币,你还换吗? \ \
    <交换/@jintiaohuanjinbi> \
    ]]

    local S2 = [[
    你都没有金条还换什么? \
    想骗我?快滚! \ \
    <离 开/@exit>
    ]]

        --相当于 #if 的 checkitem 金条 1
        if vvlib:check(Player, CHECKITEM, '金条', 1) then
            Npc:Say(Player, '', S1, false);
        else
            Npc:Say(Player, '', S2, false);
        end
    end


    function jintiaohuanjinbi(Npc, Player)
    local S1 = [[
    我也很想给你换, \
    但是你钱太多了,我没办法给你换. \ \
    <离 开/@exit>
    ]]


        --相当于 #if 的 checkitem 金条 1
        if vvlib:check(Player, CHECKITEM, '金条', 1) and vvlib:check(Player, CHECKGOLD, 14000001) then
            Npc:Say(Player, '', S1, false);
        else
            --等同于goto @jintiaohuanjinbi_2
            jintiaohuanjinbi_2(Npc,Player)
        end
    end


    function jintiaohuanjinbi_2(Npc, Player)
    local S1 = [[
    金条已经换好金币了. \
    还换吗? \ \
    <交换/@jintiaohuanjinbishuoming> \
    <离 开/@exit>
    ]]
        if vvlib:check(Player, CHECKITEM, '金条', 1)  then
            vvlib:action(Player, TAKE, '金条', 1);
            vvlib:action(Player, GIVE, '金币', 998000);
            Npc:Say(Player, '', S1, false);
        end
    end
    回复

    使用道具 举报

  • TA的每日心情
    开心
    昨天 00:05
  • 签到天数: 3 天

    [LV.2]偶尔看看I

    0

    主题

    5

    帖子

    58

    积分

    注册会员

    Rank: 2

    积分
    58
    发表于 前天 18:41 | 显示全部楼层
    我是新手,我也进来学习!
    回复

    使用道具 举报

  • TA的每日心情
    开心
    前天 10:29
  • 签到天数: 4 天

    [LV.2]偶尔看看I

    0

    主题

    4

    帖子

    54

    积分

    注册会员

    Rank: 2

    积分
    54
    发表于 昨天 20:27 | 显示全部楼层
    我是新手,我也进来学习!
    回复

    使用道具 举报

  • TA的每日心情
    开心
    2025-11-29 21:17
  • 签到天数: 63 天

    [LV.6]常住居民II

    16

    主题

    98

    帖子

    1589

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    积分
    1589
    发表于 昨天 21:58 | 显示全部楼层
    24年的是这种写法,这个不要在学了,已经放弃这种模式了
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    快速回复 返回顶部 返回列表