SpringRTS/Callouts 中的 Lua
外观
Callouts 只是在 Spring 中定义的函数,您可以在任何时候运行它们。callins 和 callouts 之间的区别在于,callins 实际上是事件调用器,而 callouts 是您可以使用的函数。Callouts 的性质与任何函数完全相同。它们可以返回值,可以更改值,也可以同时进行这两项操作。请记住,同步/异步理论仍然需要考虑。
例如,尝试通过小部件中的 callout 更改游戏参数的值是不允许的。
callout 示例
teamID=Spring.GetUnitTeam(unitID)
在上面的示例中,我们将 unitID 作为参数传递给 GetUnitTeam() 函数。GetUnitTeam 返回团队的 ID,我们将该 ID 存储到我们的变量 (teamID) 中。
Callout 名称 | 描述 | 同步模式 | 异步模式 | 参数 | 返回值 |
---|---|---|---|---|---|
Spring.AddGrass | x, y, z | nil | |||
Spring.AddHeightMap | 只能在 SetHeightMapFunc 中调用 | x, z, height | nil number newHeight | ||
Spring.AddSmoothMesh | 只能在 SetSmoothMeshFunc 中调用 | x, z, height | nil number newHeight | ||
Spring.AddTeamResource | teamID, resourceName, resourceAmount | nil | |||
Spring.AddUnitDamage | unitID, damageAmount [, number paralyze = 0 [, attackerID = -1 [, weaponID = -1[, impulse_x [, impulse_y [, impulse_z ]]] ]]] | nil | |||
Spring.AddUnitImpulse | unitID, x, y, z | nil | |||
Spring.AddUnitResource | unitID, resourceName, resourceAmount | nil | |||
Spring.AddUnitSeismicPing | unitID, pingSize | nil | |||
Spring.AdjustHeightMap | x1, z1 [, x2, z2], height | nil | |||
Spring.AdjustSmoothMesh | x1, z1 [, x2, z2], height | nil | |||
Spring.CallCOBScript | unitID, funcID string funcName, number retArgs, COBArg1, COBArg2, ... |
number returnValue, number retArg1, number retArg2, ... | |||
Spring.CallCOBScriptCB | 在 0.78.2.1 中已损坏;将随着 Lua 作为 COB 替换的引入而被移除 | funcName, number retArgs, COBArg1, COBArg2, ... | number returnValue, number CallbackData, number retArg1, number retArg2, ... | ||
Spring.CreateFeature | defName featureID, x, y, z[,number heading [, allyTeamID ]] |
featureID | |||
Spring.CreateUnit | 地图外的位置将被限制!您仍然可以使用 MoveCtrl 来实现这一点 | number unitDefID, x, y, z, number facing string "facing", teamID, [boolean build = false] | unitID, | ||
Spring.DestroyFeature | featureID | nil | |||
Spring.DestroyUnit | unitID, [boolean selfd = false,], [boolean reclaimed = false,], [number attackerID] | nil | |||
Spring.EditUnitCmdDesc | 是 | 否 | unitID, number cmdDescID, table cmdArray | nil | |
Spring.GameOver | 将宣布游戏结束。在 0.83.x 版本中新增 | [ [1] = allyTeamID1, [2] = allyTeamID2, .. ] | nil | ||
Spring.GetCOBScriptID | unitID, funcName | funcID | |||
Spring.GetUnitCOBValue | unitID, [, boolean splitData=false], number COBValue[, number param1 [,number param2 [, number param3 [, number param4 ] ] ] ] | number result1, number result2 | |||
Spring.GiveOrderArrayToUnitArray | unitArray = { [1] = unitID, etc... },orderArray = {{ number cmdID,{number, etc...}, params{"alt", "ctrl", "shift", "right"} options}, ..} | nil | |||
Spring.GiveOrderArrayToUnitMap | unitMap = { [unitID] = dontCare, etc... }, orderArray = {{ number cmdID,{number, etc...}, params{"alt", "ctrl", "shift", "right"} options}, ..} | nil | |||
Spring.GiveOrderToUnit | unitID, number cmdID, params = {number, etc...}, options = {"alt", "ctrl", "shift", "right"} | nil | |||
Spring.GiveOrderToUnitArray | unitArray = { [1] = unitID, etc... },number cmdID,params = {number, etc...},options = {"alt", "ctrl", "shift", "right"} | nil | |||
Spring.GiveOrderToUnitMap | unitMap = { [unitID] = dontCare, etc... },number cmdID,params = {number, etc...},options = {"alt", "ctrl", "shift", "right"} | nil | |||
Spring.InsertUnitCmdDesc | unitID, [, number cmdDescID ] , table cmdArray | nil | |||
Spring.KillTeam | 将宣布一个团队死亡。在 0.83.x 版本中新增 | teamID | nil | ||
Spring.LevelHeightMap | x1, z1 [, x2, z2], height | nil | |||
Spring.LevelSmoothMesh | x1, z1 [, x2, z2], height | nil | |||
Spring.RemoveBuildingDecal | unitID, | nil | |||
Spring.RemoveGrass | x, y, z | nil | |||
Spring.RemoveUnitCmdDesc | unitID, [, number cmdDescID ] | nil | |||
Spring.RevertHeightMap | x1, z1 [, x2, z2], number origFactor | nil | |||
Spring.RevertSmoothMesh | x1, z1 [, x2, z2], number origFactor | nil | |||
Spring.SetExperienceGrade | number expGrade[, number ExpPowerScale [, number ExpHealthScale [, number ExpReloadScale ]]] | nil | |||
Spring.SetFeatureAlwaysVisible | featureID, boolean enable | nil | |||
Spring.SetFeatureCollisionVolumeData | featureID, number scaleX, number scaleY, number scaleZ, number offsetX, number offsetY, number offsetX, number vType, number tType, number Axis | nil | |||
Spring.SetFeatureDirection | featureID, x, y, z | nil | |||
Spring.SetFeatureHealth | featureID, number health | nil | |||
Spring.SetFeatureNoSelect | featureID, boolean noSelect | nil | |||
Spring.SetFeaturePosition | featureID, x, y, z [, boolean snapToGround] | nil | |||
Spring.SetFeatureReclaim | featureID, number reclaimLeft | nil | |||
Spring.SetFeatureResurrect | string facing ] | nil | |||
Spring.SetHeightMap | 只能在 SetHeightMapFunc 中调用 | x, z, number height [,number terraform = 1] | number absHeightDiff | ||
Spring.SetHeightMapFunc | lua_function [, arg1 ,[ arg2 [, ... ] ] | number absTotalHeightMapAmountChanged | |||
Spring.SetMapSquareTerrainType | x, z, int newType | int oldType | |||
Spring.SetNoPause | boolean noPause | nil | |||
Spring.SetProjectileCEG | number projID, string ceg_name | nil | |||
Spring.SetProjectileCollision | number projID | nil | |||
Spring.SetProjectileGravity | number projID [, number grav = 0] | nil | |||
Spring.SetProjectileMoveControl | 禁用引擎移动控制,以便 Lua 可以完全控制物理 | number projID, boolean enable | nil | ||
Spring.SetProjectilePosition | number projID [, number x = 0 [, number y = 0 [, number z = 0 ]]] | nil | |||
Spring.SetProjectileSpinAngle | number projID [, number spinAngle = 0] | nil | |||
Spring.SetProjectileSpinSpeed | number projID [, number speed = 0] | nil | |||
Spring.SetProjectileSpinVec | number projID [, number x = 0 [, number y = 0 [, number z = 0]]] | nil | |||
Spring.SetProjectileVelocity | number projID [, number x = 0 [, number y = 0 [, number z = 0 ]]] | nil | |||
Spring.SetSmoothMesh 只能在 SetSmoothMeshFunc 中调用 | x, z, number height [,number terraform = 1] | number absHeightDiff | |||
Spring.SetSmoothMeshFunc | lua_function [, arg1 ,[ arg2 [, ... ] ] | number absTotalHeightMapAmountChanged | |||
Spring.SetTeamResource | teamID, string resource, number amount | nil | |||
Spring.SetTeamShareLevel | "energy", number amount | nil | |||
Spring.SetTerrainTypeData | int typeIndex[, number speedTanks = nil ][, number speedKBOTs = nil ][, number speedHovers = nil ][, number speedShips = nil ] | boolean true | |||
Spring.SetUnitAlwaysVisible | unitID, boolean alwaysVisible | nil | |||
Spring.SetUnitArmored | unitID, boolean armored | nil | |||
Spring.SetUnitBlocking | unitID, boolean blocking [, boolean collide ] | nil | |||
Spring.SetUnitBuildSpeed | number builderID, number buildSpeed, [ number repairSpeed [, number reclaimSpeed [,number resurrectSpeed [, number captureSpeed [, number terraformSpeed ]] ]]] | nil | |||
Spring.SetUnitCOBValue | unitID, number COBValue, number param1 [,number param2] | nil | |||
Spring.SetUnitCloak | number scriptCloak, [ number decloakDistance | boolean decloakAbs ] | nil | |||
Spring.SetUnitCollisionVolumeData | unitID, number scaleX, number scaleY, number scaleZ, number offsetX, number offsetY, number offsetX, number vType, number tType, number Axis | nil | |||
Spring.SetUnitCosts | unitID, { [ buildTime = number amount ], [ metalCost = number amount ], [ energyCost = number amount ]} | nil | |||
Spring.SetUnitExperience | unitID, number experience | nil | |||
Spring.SetUnitFlanking | unitID, string "mode", number mode | nil | |||
Spring.SetUnitFuel | unitID, number fuel | nil | |||
Spring.SetUnitHealth | { [ health = number health ],[ capture = number capture ],[ paralyze = number paralyze ],[ build = number build ] } | nil | |||
Spring.SetUnitLineage | 从 0.83.x 版本中移除 | unitID, number teamID [, boolean isRoot] | nil | ||
Spring.SetUnitLosMask | table losTypes | nil | |||
Spring.SetUnitLosState | table losTypes | nil | |||
Spring.SetUnitMaxHealth | unitID, number maxHealth | nil | |||
Spring.SetUnitMetalExtraction | unitID, number depth [,number range] | nil | |||
Spring.SetUnitMoveGoal | 默认命令使用,用于进入建造范围、攻击范围等 | unitID, x, y, z, [, number radius = 0 [, number speed = unit] ] | nil | ||
Spring.SetUnitNeutral | unitID, boolean neutral | nil | |||
Spring.SetUnitPhysics | unitIDnumber posx, number posy, number posz,number velx, number vely, number velz,number rotx, number roty, number rotz, | nil | |||
Spring.SetUnitPieceCollisionVolumeData | unitID, number pieceIndex, boolean affectLocal, boolean affectGlobal, boolean enableLocal, boolean enableGlobal, number scaleX, number scaleY, number scaleZ, number offsetX, number offsetY, number offsetZ, number vType, number Axis | nil | |||
Spring.SetUnitPosition | unitID, x, number z [, boolean alwaysAboveSea] | nil | |||
Spring.SetUnitResourcing | unitID, resourceName, resourceAmount unitID, resourceName=resourceAmount |
nil | |||
Spring.SetUnitRotation | unitID, number rotx, number roty, number rotz | nil | |||
Spring.SetUnitSensorRadius | unitID, string type, number radius | number newRadius | |||
Spring.SetUnitShieldState | unitID, [, number weaponID = -1] [, boolean enabled] [, number power] | nil | |||
Spring.SetUnitSonarStealth | unitID, boolean sonarStealth | nil | |||
Spring.SetUnitStealth | unitID, boolean stealth | nil | |||
Spring.SetUnitStockpile | unitID, [, number stockpile [, number buildPercent ]] | nil | |||
Spring.SetUnitTarget | x, y, z, [ boolean dgun = false ] | nil | |||
Spring.SetUnitToFeature | boolean tofeature | nil | |||
Spring.SetUnitTooltip | unitID, string "tooltip" | nil | |||
Spring.SetUnitTravel | unitID, number travel [, number travelPeriod] | nil | |||
Spring.SetUnitVelocity | unitID, number velx, number vely, number velz | nil | |||
Spring.SetUnitWeaponState | table states | nil | |||
Spring.ShareTeamResource | 0.82 及更高版本 | number teamID_src, number teamID_recv, resource, number amount | nil | ||
Spring.SpawnCEG | string "cegname", number posX = 0, number posY = 0, number posZ = 0, number dirX = 0, number dirY = 0, number dirZ = 0, number radius = 0, number damage = 0 | nil | |||
Spring.TransferFeature | featureID number teamID | nil | |||
Spring.TransferUnit | unitID, numer newTeamID,[boolean given = true] | nil | |||
Spring.UseTeamResource | { metal = number amount, energy = number amount} | boolean hadEnough | |||
Spring.UseUnitResource | unitID, resourceName, resourceAmount unitID, resourceName = resourceAmount} |
boolean success | |||
Spring.GetAllyTeamList | { [1] = number allyTeamID, etc... } |