📄 gadgets.lua
字号:
if (actionHandler.GotChatMsg(msg, player)) then return true end for _,g in ipairs(self.GotChatMsgList) do if (g:GotChatMsg(msg, player)) then return true end end if (IsSyncedCode()) then SendToUnsynced(player, msg) end return falseend------------------------------------------------------------------------------------ Drawing call-ins---- generates ViewResize() calls for the gadgetsfunction gadgetHandler:SetViewSize(vsx, vsy) self.xViewSize = vsx self.yViewSize = vsy if ((self.xViewSizeOld ~= vsx) or (self.yViewSizeOld ~= vsy)) then gadgetHandler:ViewResize(vsx, vsy) self.xViewSizeOld = vsx self.yViewSizeOld = vsy endendfunction gadgetHandler:ViewResize(vsx, vsy) for _,g in ipairs(self.ViewResizeList) do g:ViewResize(vsx, vsy) end returnend------------------------------------------------------------------------------------ Game call-ins--function gadgetHandler:GameOver() for _,g in ipairs(self.GameOverList) do g:GameOver() end returnendfunction gadgetHandler:TeamDied(teamID) for _,g in ipairs(self.TeamDiedList) do g:TeamDied(teamID) end returnend------------------------------------------------------------------------------------ LuaRules Game call-ins--function gadgetHandler:CommandFallback(unitID, unitDefID, unitTeam, cmdID, cmdParams, cmdOptions) for _,g in ipairs(self.CommandFallbackList) do local used, remove = g:CommandFallback(unitID, unitDefID, unitTeam, cmdID, cmdParams, cmdOptions) if (used) then return remove end end return true -- remove the commandendfunction gadgetHandler:AllowCommand(unitID, unitDefID, unitTeam, cmdID, cmdParams, cmdOptions, synced) for _,g in ipairs(self.AllowCommandList) do if (not g:AllowCommand(unitID, unitDefID, unitTeam, cmdID, cmdParams, cmdOptions, synced)) then return false end end return trueendfunction gadgetHandler:AllowUnitCreation(unitDefID, builderID, builderTeam, x, y, z) for _,g in ipairs(self.AllowUnitCreationList) do if (not g:AllowUnitCreation(unitDefID, builderID, builderTeam, x, y, z)) then return false end end return trueendfunction gadgetHandler:AllowUnitTransfer(unitID, unitDefID, oldTeam, newTeam, capture) for _,g in ipairs(self.AllowUnitTransferList) do if (not g:AllowUnitTransfer(unitID, unitDefID, oldTeam, newTeam, capture)) then return false end end return trueendfunction gadgetHandler:AllowUnitBuildStep(builderID, builderTeam, unitID, unitDefID, part) for _,g in ipairs(self.AllowUnitBuildStepList) do if (not g:AllowUnitBuildStep(builderID, builderTeam, unitID, unitDefID, part)) then return false end end return trueendfunction gadgetHandler:AllowFeatureCreation(featureDefID, teamID, x, y, z) for _,g in ipairs(self.AllowFeatureCreationList) do if (not g:AllowFeatureCreation(featureDefID, teamID, x, y, z)) then return false end end return trueendfunction gadgetHandler:AllowResourceLevel(teamID, res, level) for _,g in ipairs(self.AllowResourceLevelList) do if (not g:AllowResourceLevel(teamID, res, level)) then return false end end return trueendfunction gadgetHandler:AllowResourceTransfer(teamID, res, level) for _,g in ipairs(self.AllowResourceTransferList) do if (not g:AllowResourceTransfer(teamID, res, level)) then return false end end return trueendfunction gadgetHandler:AllowDirectUnitControl(unitID, unitDefID, unitTeam, playerID) for _,g in ipairs(self.AllowDirectUnitControlList) do if (not g:AllowDirectUnitControl(unitID, unitDefID, unitTeam, playerID)) then return false end end return trueend------------------------------------------------------------------------------------ Unit call-ins--function gadgetHandler:UnitCreated(unitID, unitDefID, unitTeam, builderID) for _,g in ipairs(self.UnitCreatedList) do g:UnitCreated(unitID, unitDefID, unitTeam, builderID) end returnendfunction gadgetHandler:UnitFinished(unitID, unitDefID, unitTeam) for _,g in ipairs(self.UnitFinishedList) do g:UnitFinished(unitID, unitDefID, unitTeam) end returnendfunction gadgetHandler:UnitFromFactory(unitID, unitDefID, unitTeam, factID, factDefID, userOrders) for _,g in ipairs(self.UnitFromFactoryList) do g:UnitFromFactory(unitID, unitDefID, unitTeam, factID, factDefID, userOrders) end returnendfunction gadgetHandler:UnitDestroyed(unitID, unitDefID, unitTeam, attackerID, attackerDefID, attackerTeam) for _,g in ipairs(self.UnitDestroyedList) do g:UnitDestroyed(unitID, unitDefID, unitTeam, attackerID, attackerDefID, attackerTeam) end returnendfunction gadgetHandler:UnitIdle(unitID, unitDefID, unitTeam) for _,g in ipairs(self.UnitIdleList) do g:UnitIdle(unitID, unitDefID, unitTeam) end returnendfunction gadgetHandler:UnitDamaged(unitID, unitDefID, unitTeam, damage, paralyzer, weaponID, attackerID, attackerDefID, attackerTeam) for _,g in ipairs(self.UnitDamagedList) do g:UnitDamaged(unitID, unitDefID, unitTeam, damage, paralyzer, weaponID, attackerID, attackerDefID, attackerTeam) end returnendfunction gadgetHandler:UnitTaken(unitID, unitDefID, unitTeam, newTeam) for _,g in ipairs(self.UnitTakenList) do g:UnitTaken(unitID, unitDefID, unitTeam, newTeam) end returnendfunction gadgetHandler:UnitGiven(unitID, unitDefID, unitTeam, oldTeam) for _,g in ipairs(self.UnitGivenList) do g:UnitGiven(unitID, unitDefID, unitTeam, oldTeam) end returnendfunction gadgetHandler:UnitEnteredRadar(unitID, unitTeam, allyTeam, unitDefID) for _,g in ipairs(self.UnitEnteredRadarList) do g:UnitEnteredRadar(unitID, unitTeam, allyTeam, unitDefID) end returnendfunction gadgetHandler:UnitEnteredLos(unitID, unitTeam, allyTeam, unitDefID) for _,g in ipairs(self.UnitEnteredLosList) do g:UnitEnteredLos(unitID, unitTeam, allyTeam, unitDefID) end returnendfunction gadgetHandler:UnitLeftRadar(unitID, unitTeam, allyTeam, unitDefID) for _,g in ipairs(self.UnitLeftRadarList) do g:UnitLeftRadar(unitID, unitTeam, allyTeam, unitDefID) end returnendfunction gadgetHandler:UnitLeftLos(unitID, unitTeam, allyTeam, unitDefID) for _,g in ipairs(self.UnitLeftLosList) do g:UnitLeftLos(unitID, unitTeam, allyTeam, unitDefID) end returnendfunction gadgetHandler:UnitSeismicPing(x, y, z, strength, allyTeam, unitID, unitDefID) for _,g in ipairs(self.UnitSeismicPingList) do g:UnitSeismicPing(x, y, z, strength, allyTeam, unitID, unitDefID) end returnendfunction gadgetHandler:UnitLoaded(x, y, z, strength) for _,g in ipairs(self.UnitLoadedList) do g:UnitLoaded(x, y, z, strength) end returnendfunction gadgetHandler:UnitUnloaded(x, y, z, strength) for _,g in ipairs(self.UnitUnloadedList) do g:UnitUnloaded(x, y, z, strength) end returnendfunction gadgetHandler:StockpileChanged(unitID, unitDefID, unitTeam, weaponNum, oldCount, newCount) for _,g in ipairs(self.StockpileChangedList) do g:StockpileChanged(unitID, unitDefID, unitTeam, weaponNum, oldCount, newCount) end returnend------------------------------------------------------------------------------------ Feature call-ins--function gadgetHandler:FeatureCreated(featureID, allyTeam) for _,g in ipairs(self.FeatureCreatedList) do g:FeatureCreated(featureID, allyTeam) end returnendfunction gadgetHandler:FeatureDestroyed(featureID, allyTeam) for _,g in ipairs(self.FeatureDestroyedList) do g:FeatureDestroyed(featureID, allyTeam) end returnend------------------------------------------------------------------------------------ Misc call-ins--function gadgetHandler:Explosion(weaponID, px, py, pz, ownerID) local noGfx = false for _,g in ipairs(self.ExplosionList) do noGfx = noGfx or g:Explosion(weaponID, px, py, pz, ownerID) end return noGfxend------------------------------------------------------------------------------------ Draw call-ins--function gadgetHandler:Update() for _,g in ipairs(self.UpdateList) do g:Update() end returnendfunction gadgetHandler:DefaultCommand() for _,g in ipairs(self.DefaultCommandList) do local id = g:DefaultCommand() if (id) then return id end end returnendfunction gadgetHandler:DrawWorld() for _,g in ipairs(self.DrawWorldList) do g:DrawWorld() end returnendfunction gadgetHandler:DrawWorldPreUnit() for _,g in ipairs(self.DrawWorldPreUnitList) do g:DrawWorldPreUnit() end returnendfunction gadgetHandler:DrawWorldShadow() for _,g in ipairs(self.DrawWorldShadowList) do g:DrawWorldShadow() end returnendfunction gadgetHandler:DrawWorldReflection() for _,g in ipairs(self.DrawWorldReflectionList) do g:DrawWorldReflection() end returnendfunction gadgetHandler:DrawWorldRefraction() for _,g in ipairs(self.DrawWorldRefractionList) do g:DrawWorldRefraction() end returnendfunction gadgetHandler:DrawScreenEffects(vsx, vsy) for _,g in ipairs(self.DrawScreenEffectsList) do g:DrawScreenEffects(vsx, vsy) end returnendfunction gadgetHandler:DrawScreen(vsx, vsy) for _,g in ipairs(self.DrawScreenList) do g:DrawScreen(vsx, vsy) end returnendfunction gadgetHandler:DrawInMiniMap(mmsx, mmsy) for _,g in ipairs(self.DrawInMiniMapList) do g:DrawInMiniMap(mmsx, mmsy) end returnend----------------------------------------------------------------------------------------------------------------------------------------------------------------gadgetHandler:Initialize()----------------------------------------------------------------------------------------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -