后端Lua
后端Lua
后端Lua
做了一个元宝捐献功能,如何查询哪个玩家捐了最多
后端Lua
称号属性在哪设置
后端Lua
consumebindmoney(actor, "元宝", cfgData.money, "称号升级扣除") 和changemoney(actor, 2, "-", cfgData.money, "称号升级扣除", false)有什么区别
后端Lua
local enemy = {hp = 100 ,attack = 10 } function enemy:new(name) local obj ={ name = name } local mt = { __newindex = function (t,k,v) if k == 'hp' and v*1 > 10000 then error('血量不能超过10000')
后端Lua
创建Enemy敌人类,要求: 类包含hp=100和attack=10两个默认属性 构造函数new接收name参数,创建对象时name写入对象自身 使用__index让对象继承类的hp和attack 使用__newindex限制:hp不能超过10000,attack不能超过1000,使用rawset写入 添加hurt方法,接收damage参数,从hp中扣除 类里面有hp了 会走__newindex吗
后端Lua
local bankaccount = { balance = 0 } local mt = { __newindex = function(t,k,v) if type(v) ~= 'number' then error('必须是数字类型') return elseif v*1 < 0 then error('不能为负数') r
后端Lua
local config = { version = '1.0'} local mt = { __newindex = function(t,k,v) if k == 'version' then print('修改成功',t,k,v) rawset(t,k,v) else print('该文件只读') end end } setmetatable(config,mt
后端Lua
local config = { version = '1.0'} local mt = { __newindex = function(t,k,v) if k == 'version' then rawset(t,k,v) print('修改成功',t,k,v) else print('该文件只读') end end } setmetatable(config,mt
后端Lua
local p = { self.math = math, self.english = english, self.xueke = xueke, } 有啥问题
后端Lua
[string "local player = { math = 100 , english = 800 }..."]:7: '}' expected (to close '{' at line 6) near '='
后端Lua
local t = {} local proxy = {} local mt = { __newindex = proxy -- 指向另一个表 } setmetatable(t, mt) t.newKey = "value" -- 触发 __newindex -- 因为 __newindex 是 proxy 表,所以会执行 proxy.newKey = "value" print(t.newKey) -- 输出: nil(t 本身没有) print(proxy.newKey
后端Lua
say里面的text怎么隐藏
后端Lua
function recharge(actor, gold, product_id, money_id, isReal) if gold > 0 then -- 充值标识 local cz_id = getplaydef(actor, "T9") if cz_id ~= '' then -- 充值标识配置 local cur_cz_id_cfg = RechargeModule.cz_id_p
后端Lua