⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit_immobile_buider.lua

📁 这是整套横扫千军3D版游戏的源码
💻 LUA
字号:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------  file:    unit_immobile_buider.lua--  brief:   sets immobile builders to ROAMING, and gives them a PATROL order--  author:  Dave Rodgers----  Copyright (C) 2007.--  Licensed under the terms of the GNU GPL, v2 or later.------------------------------------------------------------------------------------------------------------------------------------------------------------------function widget:GetInfo()  return {    name      = "ImmobileBuilder",    desc      = "Sets immobile builders to ROAM, with a PATROL command",    author    = "trepan",    date      = "Jan 8, 2007",    license   = "GNU GPL, v2 or later",    layer     = 0,    enabled   = false  --  loaded by default?  }end------------------------------------------------------------------------------------------------------------------------------------------------------------------ Automatically generated local definitionslocal CMD_MOVE_STATE    = CMD.MOVE_STATElocal CMD_PATROL        = CMD.PATROLlocal CMD_STOP          = CMD.STOPlocal spGetMyTeamID     = Spring.GetMyTeamIDlocal spGetTeamUnits    = Spring.GetTeamUnitslocal spGetUnitDefID    = Spring.GetUnitDefIDlocal spGetUnitPosition = Spring.GetUnitPositionlocal spGiveOrderToUnit = Spring.GiveOrderToUnit----------------------------------------------------------------------------------------------------------------------------------------------------------------local function SetupUnit(unitID)  -- set immobile builders (nanotowers?) to the ROAM movestate,  -- and give them a PATROL order (does not matter where, afaict)  local x, y, z = spGetUnitPosition(unitID)  spGiveOrderToUnit(unitID, CMD_STOP, {}, {})  spGiveOrderToUnit(unitID, CMD_MOVE_STATE, { 2 }, {})  spGiveOrderToUnit(unitID, CMD_PATROL, { x + 25, y, z - 25 }, {})endfunction widget:Initialize()  for _,unitID in ipairs(spGetTeamUnits(spGetMyTeamID())) do    local unitDefID = spGetUnitDefID(unitID)    local ud = unitDefID and UnitDefs[unitDefID] or nil    if (ud and ud.builder and not ud.canMove) then      SetupUnit(unitID)    end  endendfunction widget:UnitCreated(unitID, unitDefID, unitTeam)  if (unitTeam ~= spGetMyTeamID()) then    return  end  local ud = UnitDefs[unitDefID]  if (ud and ud.builder and not ud.canMove) then    SetupUnit(unitID)  endendfunction widget:UnitGiven(unitID, unitDefID, unitTeam)  widget:UnitCreated(unitID, unitDefID, unitTeam)end----------------------------------------------------------------------------------------------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -