--雷神锤电量系统 local function PlayerGetShell local Wearing = nil Wearing = IsWearingShell if Wearing == nil then return end TimeTickReduceMinuteWearing end function IsWearingShell local pl = getPlayer loca
--雷神锤电量系统 --获取玩家身上穿戴的物品 local function PlayerGetShell() local Wearing = nil Wearing = IsWearingShell() if Wearing == nil then return end TimeTickReduceMinute(Wearing) end
--判断玩家是否穿戴了雷神锤 function IsWearingShell() local pl = getPlayer() local wornItems = pl:getWornItems() if not wornItems then return nil end for i = 0, wornItems:size() - 1 do local wornitem = wornItems:get(i) if wornitem:getItem():getType() == "MJOLNIRArmorMkVI" then local item = wornitem:getItem() if item:getModData().Shellbattery == nil then item:getModData().Shellbattery = 10 end return item end end return nil end
--每分钟减少电量 function TimeTickReduceMinute(item) if item:getModData().Shellbattery ~= nil and item:getModData().Shellbattery >= 0 then item:getModData().Shellbattery = item:getModData().Shellbattery - 1 print(item:getModData().Shellbattery) --电量低于预警值时提醒玩家 if item:getModData().Shellbattery > 0 and item:getModData().Shellbattery == 60 then getPlayer():Say(getText("UIContextMenuLowPowerWarn") .. tostring(item:getModData().Shellbattery / 12) .. getText("UIContextMenuHourUnit")) end --电量耗尽时移除物品 if item:getModData().Shellbattery <= 0 then getPlayer():removeWornItem(item) getPlayer():Say(getText("UIContextMenuLowPowr")) end end --电量已耗尽时移除物品 if item:getModData().Shellbattery ~= nil and item:getModData().Shellbattery <= 0 then getPlayer():removeWornItem(item) getPlayer():Say(getText("UIContextMenuLowPowr")) end end
--每分钟触发一次获取雷神锤电量 Events.EveryOneMinute.Add(PlayerGetShell)
原文地址: https://www.cveoy.top/t/topic/bZOX 著作权归作者所有。请勿转载和采集!