if data.let then
local tb = string.split(data.let, "#") -- tb[1]=变量ID tb[2]=检测值
tb[1], tb[2] = tostring(tb[1]), tonumber(tb[2])
print(tb[1], tb[2])
if lualib:GetVar(player, tb[1]) ~= tb[2] then
lual
🤖 回答引擎: 后端Lua |
🕒 时间: 2026-07-24 16:04:47 |
👁️ 阅读: 11
我是lua后端老师!
小仙,你这个代码逻辑需要调整一下,我来帮你分析一下:
首先,你代码中的 `data.let` 应该是一个类似 "13#10" 这样的字符串,表示变量ID和检测值。你现在的代码逻辑是:无论变量ID是什么,都提示"当前圣器提升次数不足",这不符合你的需求。
根据你的要求,当 `tb[1]` 等于 "13" 时,提示"爵位等级不足",否则提示"圣器提升次数不足"。代码修改如下:
```lua
if data.let then
local tb = string.split(data.let, "#") -- tb[1]=变量ID tb[2]=检测值
tb[1], tb[2] = tostring(tb[1]), tonumber(tb[2])
release_print(tb[1], tb[2]) -- 使用release_print代替print
if lualib:GetVar(player, tb[1]) ~= tb[2] then
-- 判断变量ID是否为13
if tb[1] == "13" then
lualib:Tips(player, "当前爵位等级不足"..tb[2].."级!", 3)
else
lualib:Tips(player, "当前圣器提升次数不足"..tb[2].."次!", 3)
end
return 1
end
end
```
主要修改点:
1. 在提示语句中使用了正确的 `tb[2]`(检测值),而不是原来的 `data.let`
2. 添加了条件判断,当 `tb[1]` 等于 "13" 时显示爵位等级提示,否则显示圣器提示
注意:`lualib:GetVar(player, tb[1])` 这里 `tb[1]` 需要是字符串格式,你已经在前面用 `tostring(tb[1])` 转换过了,这样是正确的。
小仙,写代码时要注意细节哦,变量名要对应正确。如果还有不明白的地方,可以随时问我,或者请教浮生梦尊师!
我是lua后端老师!
小仙,你这个代码逻辑需要调整一下,我来帮你分析一下:
首先,你代码中的 `data.let` 应该是一个类似 "13#10" 这样的字符串,表示变量ID和检测值。你现在的代码逻辑是:无论变量ID是什么,都提示"当前圣器提升次数不足",这不符合你的需求。
根据你的要求,当 `tb[1]` 等于 "13" 时,提示"爵位等级不足",否则提示"圣器提升次数不足"。代码修改如下:
```lua
if data.let then
local tb = string.split(data.let, "#") -- tb[1]=变量ID tb[2]=检测值
tb[1], tb[2] = tostring(tb[1]), tonumber(tb[2])
release_print(tb[1], tb[2]) -- 使用release_print代替print
if lualib:GetVar(player, tb[1]) ~= tb[2] then
-- 判断变量ID是否为13
if tb[1] == "13" then
lualib:Tips(player, "当前爵位等级不足"..tb[2].."级!", 3)
else
lualib:Tips(player, "当前圣器提升次数不足"..tb[2].."次!", 3)
end
return 1
end
end
```
主要修改点:
1. 在提示语句中使用了正确的 `tb[2]`(检测值),而不是原来的 `data.let`
2. 添加了条件判断,当 `tb[1]` 等于 "13" 时显示爵位等级提示,否则显示圣器提示
注意:`lualib:GetVar(player, tb[1])` 这里 `tb[1]` 需要是字符串格式,你已经在前面用 `tostring(tb[1])` 转换过了,这样是正确的。
小仙,写代码时要注意细节哦,变量名要对应正确。如果还有不明白的地方,可以随时问我,或者请教浮生梦尊师!
← 返回问答库