教程先看了很多遍为了观察每一步的关键点
但是一学就会 一干就废
遇到的问题如传输的时候 少了sethumvar
字段 导致出现BUG 对方无法正常接受物品
很多地方也需要初始化 不然会重叠或者显示过多
通过这次的一比一还原
学会了传输数据类型 对方名字.命令
通过物品IDX获取物品名称 getdbidxitemfieldvalue
通过名称获得IDC getdbitemfieldvalue
其中也有自己根据自己喜好改的界面和方式 例如我点击物品对方才显示物品框
还有一点需要注意GIVES 木剑#5#1
语句最后的1要和N$绑定状态一致 要么会让你浪费时间找为啥背包有绑定物品 就是不读取
如下是我的代码
[@查询背包物品]
#ACT
getitembindinfo <$str(N$物品唯一ID)> N$绑定状态
#IF
equal N$绑定状态 1
#ACT
getdbitemfieldvalue <$str(S$物品的名称)> idx S$物品IDX
inc S$物品数据 <$str(S$物品IDX)>,
inc S$物品数量 <$str(N$物品的数量)>,
inc S$选择物品ID <$str(N$物品唯一ID)>,
[@点击物品]
#IF
equal S$交易者名字
#act
sendmsg 9 无法获得对方名字!
break
#IF
#ACT
mov N$选择物品IDX <$str(N$物品信息_<$str(S$物品参数)>)>
mov N$选择物品数量 <$str(N$物品数量_<$str(S$物品参数)>)>
SENDMSG 9 <$str(S$物品参数)>---
sendmsg 0 <$str(N$物品信息_<$str(S$物品参数)>)>/<$str(N$物品数量_<$str(S$物品参数)>)>
sethumvar <$str(S$交易者名字)> N$选择物品IDX <$str(N$选择物品IDX)>
sethumvar <$str(S$交易者名字)> N$选择物品数量 <$str(N$选择物品数量)>
goto @打开特殊交易界面
<$str(S$交易者名字)>.goto @对方打开界面
[@确认按钮]
#IF
equal N$选择物品IDX
#act
sendmsg 9 请选择物品!
break
#IF
equal N$选择物品数量 0
#act
sendmsg 9 无法获得物品数量!
break
#IF
equal S$交易者名字
#act
sendmsg 9 无法获得对方名字!
break
#IF
#act
sethumvar <$str(S$交易者名字)> N$选择物品IDX <$str(N$选择物品IDX)>
sethumvar <$str(S$交易者名字)> N$选择物品数量 <$str(N$选择物品数量)>
getdbidxitemfieldvalue <$str(N$选择物品IDX)> NAME S$给予物品名字
sethumvar <$str(S$交易者名字)> S$给予物品名字 <$str(S$给予物品名字)>
takes <$str(N$选择物品IDX)>#<$str(N$选择物品数量)> n0 1 1
<$str(S$交易者名字)>.GIVES <$str(S$给予物品名字)>#<$str(N$选择物品数量)>#1
sendmsg 0 <$str(S$交易者名字)>获得<$str(N$选择物品数量)>把<$str(S$给予物品名字)>物品
goto @Message_100
<$str(S$交易者名字)>.close
[@Message_100]
#ACT
lua_uid2name <$CUSTMSGPARAM>
mov S$交易者名字 <$luaresult>
mov S$物品数据
mov s$物品数量
mov S$选择物品ID
mov n0 0
while n0 < 30
inc n0 1
mov S$物品信息_<$str(n0)>
mov S$物品数量_<$str(n0)>
mov S$物品ID_<$str(n0)>
endwhile
loopbagitems @查询背包物品 N$物品唯一ID S$物品的名称 N$物品的数量 N$绑定状态
getvalidstrsuper <$str(S$物品数据)> , S$物品信息_
getvalidstrsuper <$str(S$物品数量)> , S$物品数量_
getvalidstrsuper <$str(S$选择物品ID)> , S$物品ID_
mov n0 0
while n0 < 30
inc n0 1
mov N$物品信息_<$str(n0)> <$str(S$物品信息_<$str(n0)>)>
mov N$物品数量_<$str(n0)> <$str(S$物品数量_<$str(n0)>)>
mov N$物品ID_<$str(n0)> <$str(S$物品ID_<$str(n0)>)>
endwhile
MOV N$选择物品IDX
MOV N$选择物品数量
goto @打开特殊交易界面
[@打开特殊交易界面]
#if
#SAY
<Img|x=427.0|y=102.0|reset=1|bg=1|move=0|loadDelay=0|show=0|img=public/bg_npc_11.jpg|esc=1>
<Layout|x=873.0|y=79.0|width=80|height=80|link=@退出交易>
<Button|x=886.0|y=101.0|nimg=public/1900000510.png|pimg=public/1900000511.png|link=@退出交易>
<Img|x=206.0|y=142.0|width=230|height=180|img=public/bg_fubentg_02.png|esc=0>
<Button|x=286.0|y=265.0|percentwidth=16|percentheight=8|nimg=public/00000361.png|color=253|size=18|link=@确认按钮>
<ItemShow|ay=1|x=289.0|y=191.0|width=70|height=70|itemid=<$str(N$选择物品IDX)>|itemcount=<$str(N$选择物品数量)>|showtips=1|bgtype=1>
<ItemShow|x=436|y=150.0|width=70|height=70|itemid=<$str(N$物品信息_1)>|itemcount=<$str(N$物品数量_1)>|showtips=1|bgtype=1|link=@点击物品#物品参数=1>
<ItemShow|x=510|y=150.0|width=70|height=70|itemid=<$str(N$物品信息_2)>|itemcount=<$str(N$物品数量_2)>|showtips=1|bgtype=1|link=@点击物品#物品参数=2>
<ItemShow|x=584|y=150.0|width=70|height=70|itemid=<$str(N$物品信息_3)>|itemcount=<$str(N$物品数量_3)>|showtips=1|bgtype=1|link=@点击物品#物品参数=3>
<ItemShow|x=658|y=150.0|width=70|height=70|itemid=<$str(N$物品信息_4)>|itemcount=<$str(N$物品数量_4)>|showtips=1|bgtype=1|link=@点击物品#物品参数=4>
<ItemShow|x=732|y=150.0|width=70|height=70|itemid=<$str(N$物品信息_5)>|itemcount=<$str(N$物品数量_5)>|showtips=1|bgtype=1|link=@点击物品#物品参数=5>
<ItemShow|x=806|y=150.0|width=70|height=70|itemid=<$str(N$物品信息_6)>|itemcount=<$str(N$物品数量_6)>|showtips=1|bgtype=1|link=@点击物品#物品参数=6>
<ItemShow|x=436|y=230.0|width=70|height=70|itemid=<$str(N$物品信息_7)>|itemcount=<$str(N$物品数量_7)>|showtips=1|bgtype=1|link=@点击物品#物品参数=7>
<ItemShow|x=510|y=230.0|width=70|height=70|itemid=<$str(N$物品信息_8)>|itemcount=<$str(N$物品数量_8)>|showtips=1|bgtype=1|link=@点击物品#物品参数=8>
<ItemShow|x=584|y=230.0|width=70|height=70|itemid=<$str(N$物品信息_9)>|itemcount=<$str(N$物品数量_9)>|showtips=1|bgtype=1|link=@点击物品#物品参数=9>
<ItemShow|x=658|y=230.0|width=70|height=70|itemid=<$str(N$物品信息_10)>|itemcount=<$str(N$物品数量_10)>|showtips=1|bgtype=1|link=@点击物品#物品参数=10>
<ItemShow|x=732|y=230.0|width=70|height=70|itemid=<$str(N$物品信息_11)>|itemcount=<$str(N$物品数量_11)>|showtips=1|bgtype=1|link=@点击物品#物品参数=11>
<ItemShow|x=806|y=230.0|width=70|height=70|itemid=<$str(N$物品信息_12)>|itemcount=<$str(N$物品数量_12)>|showtips=1|bgtype=1|link=@点击物品#物品参数=12>
<ItemShow|x=436|y=310.0|width=70|height=70|itemid=<$str(N$物品信息_13)>|itemcount=<$str(N$物品数量_13)>|showtips=1|bgtype=1|link=@点击物品#物品参数=13>
<ItemShow|x=510|y=310.0|width=70|height=70|itemid=<$str(N$物品信息_14)>|itemcount=<$str(N$物品数量_14)>|showtips=1|bgtype=1|link=@点击物品#物品参数=14>
<ItemShow|x=584|y=310.0|width=70|height=70|itemid=<$str(N$物品信息_15)>|itemcount=<$str(N$物品数量_15)>|showtips=1|bgtype=1|link=@点击物品#物品参数=15>
<ItemShow|x=658|y=310.0|width=70|height=70|itemid=<$str(N$物品信息_16)>|itemcount=<$str(N$物品数量_16)>|showtips=1|bgtype=1|link=@点击物品#物品参数=16>
<ItemShow|x=732|y=310.0|width=70|height=70|itemid=<$str(N$物品信息_17)>|itemcount=<$str(N$物品数量_17)>|showtips=1|bgtype=1|link=@点击物品#物品参数=17>
<ItemShow|x=806|y=310.0|width=70|height=70|itemid=<$str(N$物品信息_18)>|itemcount=<$str(N$物品数量_18)>|showtips=1|bgtype=1|link=@点击物品#物品参数=18>
<ItemShow|x=436|y=390.0|width=70|height=70|itemid=<$str(N$物品信息_19)>|itemcount=<$str(N$物品数量_19)>|showtips=1|bgtype=1|link=@点击物品#物品参数=19>
<ItemShow|x=510|y=390.0|width=70|height=70|itemid=<$str(N$物品信息_20)>|itemcount=<$str(N$物品数量_20)>|showtips=1|bgtype=1|link=@点击物品#物品参数=20>
<ItemShow|x=584|y=390.0|width=70|height=70|itemid=<$str(N$物品信息_21)>|itemcount=<$str(N$物品数量_21)>|showtips=1|bgtype=1|link=@点击物品#物品参数=21>
<ItemShow|x=658|y=390.0|width=70|height=70|itemid=<$str(N$物品信息_22)>|itemcount=<$str(N$物品数量_22)>|showtips=1|bgtype=1|link=@点击物品#物品参数=22>
<ItemShow|x=732|y=390.0|width=70|height=70|itemid=<$str(N$物品信息_23)>|itemcount=<$str(N$物品数量_23)>|showtips=1|bgtype=1|link=@点击物品#物品参数=23>
<ItemShow|x=806|y=390.0|width=70|height=70|itemid=<$str(N$物品信息_24)>|itemcount=<$str(N$物品数量_24)>|showtips=1|bgtype=1|link=@点击物品#物品参数=24>
<ItemShow|x=436|y=470.0|width=70|height=70|itemid=<$str(N$物品信息_25)>|itemcount=<$str(N$物品数量_25)>|showtips=1|bgtype=1|link=@点击物品#物品参数=25>
<ItemShow|x=510|y=470.0|width=70|height=70|itemid=<$str(N$物品信息_26)>|itemcount=<$str(N$物品数量_26)>|showtips=1|bgtype=1|link=@点击物品#物品参数=26>
<ItemShow|x=584|y=470.0|width=70|height=70|itemid=<$str(N$物品信息_27)>|itemcount=<$str(N$物品数量_27)>|showtips=1|bgtype=1|link=@点击物品#物品参数=27>
<ItemShow|x=658|y=470.0|width=70|height=70|itemid=<$str(N$物品信息_28)>|itemcount=<$str(N$物品数量_28)>|showtips=1|bgtype=1|link=@点击物品#物品参数=28>
<ItemShow|x=732|y=470.0|width=70|height=70|itemid=<$str(N$物品信息_29)>|itemcount=<$str(N$物品数量_29)>|showtips=1|bgtype=1|link=@点击物品#物品参数=29>
<ItemShow|x=806|y=470.0|width=70|height=70|itemid=<$str(N$物品信息_30)>|itemcount=<$str(N$物品数量_30)>|showtips=1|bgtype=1|link=@点击物品#物品参数=30>
[@对方打开界面]
#IF
#SAY
<Img|x=206|y=142|width=230|height=180|move=0|show=0|reset=1|bg=1|loadDelay=1|img=public/bg_fubentg_02.png|esc=1>
<Layout|x=414.0|y=122.0|width=80|height=80|link=@exit>
<Button|x=437.0|y=160.0|size=18|nimg=public/1900000512.png|color=255|link=@exit>
<ItemShow|ay=1|x=288.0|y=191.0|width=70|height=70|itemid=<$str(N$选择物品IDX)>|itemcount=<$str(N$选择物品数量)>|showtips=1|bgtype=1>
<Text|x=268.0|y=256.0|size=18|color=255|text=<$USERNAME>给你>
[@退出交易]
#IF
#ACT
close
<$str(S$交易者名字)>.close
MOV S$交易者名字