Module LuaHandleSynced
Callins, functions called by the Engine (Synced)
See also:
Misc
- RecvFromSynced
- Receives data sent via
SendToUnsynced
callout.
Custom Object Rendering
- DrawUnit
- For custom rendering of units
- DrawFeature
- For custom rendering of features
- DrawShield
- For custom rendering of shields.
- DrawProjectile
- For custom rendering of weapon (& other) projectiles
- DrawMaterial
- CommandFallback
- Called when the unit reaches an unknown command in its queue (i.e.
- AllowCommand
- Called when the command is given, before the unit's queue is altered.
- AllowUnitCreation
- Called just before unit is created.
- AllowUnitTransfer
- Called just before a unit is transferred to a different team.
- AllowUnitBuildStep
- Called just before a unit progresses its build percentage.
- AllowUnitCaptureStep
- AllowUnitTransport
- AllowUnitTransportLoad
- AllowUnitTransportUnload
- AllowUnitCloak
- AllowUnitCloak
- AllowUnitKamikaze
- AllowFeatureCreation
- Called just before feature is created.
- AllowFeatureBuildStep
- Called just before a feature changes its build percentage.
- AllowResourceLevel
- Called when a team sets the sharing level of a resource.
- AllowResourceTransfer
- Called just before resources are transferred between players.
- AllowDirectUnitControl
- Determines if this unit can be controlled directly in FPS view.
- AllowBuilderHoldFire
- Called when a construction unit wants to "use his nano beams".
- AllowStartPosition
- Whether a start position should be allowed
- MoveCtrlNotify
- Enable both Spring.MoveCtrl.SetCollideStop and Spring.MoveCtrl.SetTrackGround to enable this call-in.
- TerraformComplete
- Called when pre-building terrain levelling terraforms are completed (c.f.
- UnitPreDamaged
- Called before damage is applied to the unit, allows fine control over how much damage and impulse is applied.
- FeaturePreDamaged
- Called before damage is applied to the feature.
- ShieldPreDamaged
- Called before any engine shield-vs-projectile logic executes.
- AllowWeaponTargetCheck
- Determines if this weapon can automatically generate targets itself.
- AllowWeaponTarget
- Controls blocking of a specific target from being considered during a weapon's periodic auto-targeting sweep.
- AllowWeaponInterceptTarget
- Controls blocking of a specific intercept target from being considered during an interceptor weapon's periodic auto-targeting sweep.
Misc
RecvFromSynced(arg1, arg2, argn)
Receives data sent via `SendToUnsynced` callout.
Parameters:
-
arg1
any -
arg2
any -
argn
any
Custom Object Rendering
For the following calls drawMode can be one of the following, notDrawing = 0, normalDraw = 1, shadowDraw = 2, reflectionDraw = 3, refractionDraw = 4, and finally gameDeferredDraw = 5 which was added in 102.0.
DrawUnit(unitID, drawMode)
For custom rendering of units
Parameters:
-
unitID
number -
drawMode
number
Returns:
- bool suppressEngineDraw
DrawFeature(featureID, drawMode)
For custom rendering of features
Parameters:
-
featureID
number -
drawMode
number
Returns:
- bool suppressEngineDraw
DrawShield(featureID, weaponID, drawMode)
For custom rendering of shields.
Parameters:
-
featureID
number -
weaponID
number -
drawMode
number
Returns:
- bool suppressEngineDraw
DrawProjectile(projectileID, drawMode)
For custom rendering of weapon (& other) projectiles
Parameters:
-
projectileID
number -
drawMode
number
Returns:
- bool suppressEngineDraw
DrawMaterial(uuid, drawMode)
Parameters:
-
uuid
number -
drawMode
number
Returns:
- bool suppressEngineDraw
CommandFallback(unitID, unitDefID, unitTeam, cmdID, cmdParams, cmdOptions, cmdTag)
Called when the unit reaches an unknown command in its queue (i.e.
one not handled by the engine).
Parameters:
-
unitID
number -
unitDefID
number -
unitTeam
number -
cmdID
number -
cmdParams
{number,...} -
cmdOptions
cmdOptions -
cmdTag
number
Returns:
- boolean whether to remove the command from the queue
AllowCommand(unitID, unitDefID, unitTeam, cmdID, cmdParams, cmdOptions, cmdTag, synced, fromLua)
Called when the command is given, before the unit's queue is altered.
The queue remains untouched when a command is blocked, whether it would be queued or replace the queue.
Parameters:
-
unitID
number -
unitDefID
number -
unitTeam
number -
cmdID
number -
cmdParams
{number,...} -
cmdOptions
cmdOptions -
cmdTag
number -
synced
bool -
fromLua
bool
Returns:
- bool whether it should be let into the queue.
AllowUnitCreation(unitDefID, builderID, builderTeam, x, y, z, facing)
Called just before unit is created.
Parameters:
-
unitDefID
number -
builderID
number -
builderTeam
number -
x
number -
y
number -
z
number -
facing
number
Returns:
- bool allow, bool dropOrder
AllowUnitTransfer(unitID, unitDefID, oldTeam, newTeam, capture)
Called just before a unit is transferred to a different team.
Parameters:
-
unitID
number -
unitDefID
number -
oldTeam
number -
newTeam
number -
capture
bool
Returns:
- bool whether or not the transfer is permitted.
AllowUnitBuildStep(builderID, builderTeam, unitID, unitDefID, part)
Called just before a unit progresses its build percentage.
Parameters:
-
builderID
number -
builderTeam
number -
unitID
number -
unitDefID
number -
part
number
Returns:
- bool whether or not the build makes progress.
AllowUnitCaptureStep(builderID, builderTeam, unitID, unitDefID, part)
Parameters:
-
builderID
number -
builderTeam
number -
unitID
number -
unitDefID
number -
part
number
Returns:
- bool whether or not the capture makes progress.
AllowUnitTransport(transporterID, transporterUnitDefID, transporterTeam, transporteeID, transporteeUnitDefID, transporteeTeam)
Parameters:
-
transporterID
number -
transporterUnitDefID
number -
transporterTeam
number -
transporteeID
number -
transporteeUnitDefID
number -
transporteeTeam
number
Returns:
- bool whether or not the transport is allowed
AllowUnitTransportLoad(transporterID, transporterUnitDefID, transporterTeam, transporteeID, transporteeUnitDefID, transporteeTeam, x, y, z)
Parameters:
-
transporterID
number -
transporterUnitDefID
number -
transporterTeam
number -
transporteeID
number -
transporteeUnitDefID
number -
transporteeTeam
number -
x
number -
y
number -
z
number
Returns:
- bool whether or not the transport load is allowed
AllowUnitTransportUnload(transporterID, transporterUnitDefID, transporterTeam, transporteeID, transporteeUnitDefID, transporteeTeam, x, y, z)
Parameters:
-
transporterID
number -
transporterUnitDefID
number -
transporterTeam
number -
transporteeID
number -
transporteeUnitDefID
number -
transporteeTeam
number -
x
number -
y
number -
z
number
Returns:
- bool whether or not the transport unload is allowed
AllowUnitCloak(unitID[, enemyID])
Parameters:
-
unitID
number -
enemyID
number (optional)
Returns:
- bool whether unit is allowed to cloak
AllowUnitCloak(unitID[, objectID[, weaponNum]])
Parameters:
-
unitID
number -
objectID
number (optional) -
weaponNum
number (optional)
Returns:
- bool whether unit is allowed to decloak
AllowUnitKamikaze(unitID, targetID)
Parameters:
-
unitID
number -
targetID
number
Returns:
- bool whether unit is allowed to selfd
AllowFeatureCreation(featureDefID, teamID, x, y, z)
Called just before feature is created.
Parameters:
-
featureDefID
number -
teamID
number -
x
number -
y
number -
z
number
Returns:
- bool whether or not the creation is permitted
AllowFeatureBuildStep(builderID, builderTeam, featureID, featureDefID, part)
Called just before a feature changes its build percentage.
Note that this is also called for resurrecting features, and for refilling features with resources before resurrection. On reclaim the part values are negative, and on refill and ressurect they are positive. Part is the percentage the feature be built or reclaimed per frame. Eg. for a 30 workertime builder, that's a build power of 1 per frame. For a 50 buildtime feature reclaimed by this builder, part will be 100/-50(/1) = -2%, or -0.02 numerically.
Parameters:
-
builderID
number -
builderTeam
number -
featureID
number -
featureDefID
number -
part
number
Returns:
- bool whether or not the change is permitted
AllowResourceLevel(teamID, res, level)
Called when a team sets the sharing level of a resource.
Parameters:
-
teamID
number -
res
string -
level
number
Returns:
- bool whether or not the sharing level is permitted
AllowResourceTransfer(oldTeamID, newTeamID, res, amount)
Called just before resources are transferred between players.
Parameters:
-
oldTeamID
number -
newTeamID
number -
res
string -
amount
number
Returns:
- bool whether or not the transfer is permitted.
AllowDirectUnitControl(unitID, unitDefID, unitTeam, playerID)
Determines if this unit can be controlled directly in FPS view.
Parameters:
-
unitID
number -
unitDefID
number -
unitTeam
number -
playerID
number
Returns:
- bool allow
AllowBuilderHoldFire(unitID, unitDefID, action)
Called when a construction unit wants to "use his nano beams".
Parameters:
-
unitID
number -
unitDefID
number -
action
number one of following:-1 Build CMD.REPAIR Repair CMD.RECLAIM Reclaim CMD.RESTORE Restore CMD.RESURRECT Resurrect CMD.CAPTURE Capture
Returns:
- bool actionAllowed
AllowStartPosition(playerID, teamID, readyState, clampedX, clampedY, clampedZ, rawX, rawY, rawZ)
Whether a start position should be allowed
clamped{X,Y,Z} are the coordinates clamped into start-boxes, raw is where player tried to place their marker. The readyState can be any one of: 0 - player picked a position, 1 - player clicked ready, 2 - player pressed ready OR the game was force-started (player did not click ready, but is now forcibly readied) or 3 - the player failed to load. The default 'failed to choose' start-position is the north-west point of their startbox, or (0,0,0) if they do not have a startbox.
Parameters:
-
playerID
number -
teamID
number -
readyState
number -
clampedX
number -
clampedY
number -
clampedZ
number -
rawX
number -
rawY
number -
rawZ
number
Returns:
- bool allow
MoveCtrlNotify(unitID, unitDefID, unitTeam, data)
Enable both Spring.MoveCtrl.SetCollideStop and Spring.MoveCtrl.SetTrackGround to enable this call-in.
Parameters:
-
unitID
number -
unitDefID
number -
unitTeam
number -
data
number was supposed to indicate the type of notification but currently never has a value other than 1 ("unit hit the ground").
Returns:
- bool whether or not the unit should remain script-controlled (false) or return to engine controlled movement (true).
TerraformComplete(unitID, unitDefID, unitTeam, buildUnitID, buildUnitDefID, buildUnitTeam)
Called when pre-building terrain levelling terraforms are completed (c.f.
levelGround)
Parameters:
-
unitID
number -
unitDefID
number -
unitTeam
number -
buildUnitID
number -
buildUnitDefID
number -
buildUnitTeam
number
Returns:
- bool if true the current build order is terminated
UnitPreDamaged(unitID, unitDefID, unitTeam, damage, paralyzer[, weaponDefID[, projectileID[, attackerID[, attackerDefID[, attackerTeam]]]]])
Called before damage is applied to the unit, allows fine control over how much damage and impulse is applied.
Called after every damage modification (even `HitByWeaponId`) but before the damage is applied expects two numbers returned by lua code: 1st is stored under *newDamage if newDamage != NULL 2nd is stored under *impulseMult if impulseMult != NULL
Parameters:
-
unitID
number -
unitDefID
number -
unitTeam
number -
damage
number -
paralyzer
bool -
weaponDefID
number Synced Only (optional) -
projectileID
number Synced Only (optional) -
attackerID
number Synced Only (optional) -
attackerDefID
number Synced Only (optional) -
attackerTeam
number Synced Only (optional)
Returns:
- number newDamage, number impulseMult
FeaturePreDamaged(featureID, featureDefID, featureTeam, damage, weaponDefID, projectileID, attackerID, attackerDefID, attackerTeam)
Called before damage is applied to the feature.
Allows fine control over how much damage and impulse is applied.
Parameters:
-
featureID
number -
featureDefID
number -
featureTeam
number -
damage
number -
weaponDefID
number -
projectileID
number -
attackerID
number -
attackerDefID
number -
attackerTeam
number
Returns:
- number newDamage
- number impulseMult
ShieldPreDamaged(projectileID, projectileOwnerID, shieldWeaponNum, shieldCarrierID, bounceProjectile, beamEmitterWeaponNum, beamEmitterUnitID, startX, startY, startZ, hitX, hitY, hitZ)
Called before any engine shield-vs-projectile logic executes.
If the weapon is a hitscan type (BeamLaser or LightningCanon) then proID is nil and beamEmitterWeaponNum and beamEmitterUnitID are populated instead.
Parameters:
-
projectileID
number -
projectileOwnerID
number -
shieldWeaponNum
number -
shieldCarrierID
number -
bounceProjectile
bool -
beamEmitterWeaponNum
number -
beamEmitterUnitID
number -
startX
number -
startY
number -
startZ
number -
hitX
number -
hitY
number -
hitZ
number
Returns:
- bool if true the gadget handles the collision event and the engine does not remove the projectile
AllowWeaponTargetCheck(attackerID, attackerWeaponNum, attackerWeaponDefID)
Determines if this weapon can automatically generate targets itself.
See also commandFire weaponDef tag.
Parameters:
-
attackerID
number -
attackerWeaponNum
number -
attackerWeaponDefID
number
Returns:
- bool allowCheck
- bool ignoreCheck
AllowWeaponTarget(attackerID, targetID, attackerWeaponNum, attackerWeaponDefID, defPriority)
Controls blocking of a specific target from being considered during a weapon's periodic auto-targeting sweep.
Parameters:
-
attackerID
number -
targetID
number -
attackerWeaponNum
number -
attackerWeaponDefID
number -
defPriority
number
Returns:
- bool allowed
- number the new priority for this target (if you don't want to change it, return defPriority). Lower priority targets are targeted first.
AllowWeaponInterceptTarget(interceptorUnitID, interceptorWeaponID, targetProjectileID)
Controls blocking of a specific intercept target from being considered during an interceptor weapon's periodic auto-targeting sweep.
Only called for weaponDefIDs registered via Script.SetWatchWeapon.
Parameters:
-
interceptorUnitID
number -
interceptorWeaponID
number -
targetProjectileID
number
Returns:
- bool allowed