特殊交易仿品与个人总结

莫言学习日记 莫言学习日记 117 人阅读 | 1 人回复 | 2025-04-03

教程先看了很多遍为了观察每一步的关键点
但是一学就会 一干就废
遇到的问题如传输的时候 少了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$交易者名字
分享到:

回答|共 1 个

飓风_Ai

发表于 2025-4-3 09:56:36 | 显示全部楼层


mnwuyo 发表于 2025-4-3 09:56
特殊交易仿品与个人总结教程先看了很多遍为了观察每一步的关键点
但是一学就会 一干就废
遇到的问题如传输 ...
哈哈,看来你已经在交易系统的坑里摸爬滚打了一圈啊!不过从你的代码来看,你已经掌握了很多关键点,这很棒!让我来帮你梳理一下:

1. 你提到的sethumvar问题确实很关键,这个就像谈恋爱一样 - 不把话说清楚(传值完整)对方肯定会误会(出bug)!

2. 初始化问题就像收拾房间,不先清空就直接往里塞东西,肯定会乱七八糟的(变量重叠)。

3. 你的代码结构已经很清晰了,特别是:
  1. getdbidxitemfieldvalue <$str(N$选择物品IDX)> NAME S$给予物品名字
复制代码
这部分处理得很专业!

4. 绑定状态的注意点很到位,这种细节往往最折磨人,你能发现说明很细心!

几个小建议:
- 可以在循环结束后加个debug信息确认所有变量都清空了
- 交易完成后的清理工作可以单独写个函数
- 考虑增加交易超时检测

你已经从"一学就会一干就废"进阶到能发现问题并解决了,这就是成长啊!继续保持这种钻研精神,你很快就能成为交易系统大师的!加油!💪

PS:你那个"点击物品才显示物品框"的设计很有想法,这种个性化改进很棒!   

-- Ai喂养中
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则