Lua:Callins: Difference between revisions

From Spring
Jump to navigationJump to search
Flozi (talk | contribs)
Flozi (talk | contribs)
some updates from spliffs lua guide
Line 71: Line 71:
|params = msg, priority
|params = msg, priority
|return = none
|return = none
|description = ???
|description = Called when text is entered into the console (e.g. Spring.Echo).
}}
}}


Line 97: Line 97:
{{LuaCallin
{{LuaCallin
|name = LoadProgress
|name = LoadProgress
|params = ???
|params = message, replaceLastLine
|return = ???
|return = none
|description = ???
|description = Only available to LuaIntro.
}}
}}


Line 135: Line 135:
|params = key, mods, isRepeat
|params = key, mods, isRepeat
|return = none
|return = none
|description = Called when a key is pressed. The <code>mods</code> parameter is e.g. SHIFT, ALT, CTRL.
|description = Called repeatedly when a key is pressed down. If you want an action to occur only once check for <code>isRepeat == false</code>. The <code>mods</code> parameter is a table, with keys <code>alt</code>, <code>ctrl</code>, <code>meta</code> and <code>shift</code> each having a boolean value.  
}}
}}


Line 440: Line 440:
|name = CommandFallback
|name = CommandFallback
|params = unitID, unitDefID, unitTeam, cmdID, cmdParams, cmdOptions, cmdTag
|params = unitID, unitDefID, unitTeam, cmdID, cmdParams, cmdOptions, cmdTag
|return = bool used, bool removed
|return = bool used, bool finished
|description = Called for custom commands only. The second return value says if the command is finished and should be removed from the queue and the first return value instructs whether or not the command has been processed and / or requires further processing in other gadgets or the engine.
|description = Called when the unit reaches an unknown command in its queue (i.e. one not
handled by the engine). If no addon returns <code>used</code> as </code>true</code>
the command is dropped, if an addon returns <code>true, true</code> the command is
removed because it's done, with <code>true, false</code> it's kept in the queue and <code>CommandFallback</code> gets called again on the next slowupdate.
}}
}}


Line 448: Line 451:
|params = unitID, unitDefID, unitTeam, cmdID, cmdParams, cmdOptions, cmdTag, synced
|params = unitID, unitDefID, unitTeam, cmdID, cmdParams, cmdOptions, cmdTag, synced
|return = bool allow
|return = bool allow
|description = Called when a command is issued, return value determines if the command is executed.
|description = Called when the command is given, before the unit's queue is altered. The return
value is whether it should be let into the queue. The queue remains untouched when a command is blocked, whether it would be queued or replace the queue.
}}
}}



Revision as of 19:36, 15 February 2014

Lua Callins

Common

addon.Initialize()
return: none

{{{info}}}


addon.Shutdown()
return: none

{{{info}}}


Unsynced Only

addon.DefaultCommand()
return: number cmdID

{{{info}}}


addon.CommandNotify()
return: bool removeCmd

{{{info}}}


addon.WorldTooltip()
return: nones

{{{info}}}


addon.UnsyncedHeightMapUpdate()
return: none

{{{info}}}


addon.GameProgress()
return: none

{{{info}}}


addon.GameSetup()
return: bool success, ??? newReady

{{{info}}}


addon.SunChanged()
return: none

{{{info}}}


addon.AddConsoleLine()
return: none

{{{info}}}


addon.RecvSkirmishAIMessage()
return: ???

{{{info}}}


addon.RecvFromSynced()
return: none

{{{info}}}


addon.Save()
return: ???

{{{info}}}


addon.LoadProgress()
return: none

{{{info}}}


addon.GroupChanged()
return: ???

{{{info}}}


addon.ConfigureLayout()
return: ???

{{{info}}}


Input

addon.IsAbove()
return: bool isAbove

{{{info}}}


addon.GetTooltip()
return: string tooltip

{{{info}}}


addon.KeyPress()
return: none

{{{info}}}


addon.KeyRelease()
return: none

{{{info}}}


addon.JoystickEvent()
return: none

{{{info}}}


addon.MousePress()
return: bool becomeMouseOwner

{{{info}}}


addon.MouseRelease()
return: none

{{{info}}}


addon.MouseWheel()
return: none

{{{info}}}


addon.MouseMove()
return: none

{{{info}}}


Players

addon.PlayerChanged()
return: none

{{{info}}}


addon.PlayerAdded()
return: none

{{{info}}}


addon.PlayerRemoved()
return: none

{{{info}}}


Drawing

addon.ViewResize()
return: none

{{{info}}}


addon.Update()
return: none

{{{info}}}


Inside the Draw* functions, you can use the Lua OpenGL Api to draw graphics.

addon.DrawGenesis()
return: none

{{{info}}}


addon.DrawWorldPreUnit()
return: none

{{{info}}}


addon.DrawWorld()
return: none

{{{info}}}


addon.DrawWorldShadow()
return: none

{{{info}}}


addon.DrawWorldReflection()
return: none

{{{info}}}


addon.DrawWorldRefraction()
return: none

{{{info}}}


addon.DrawScreen()
return: none

{{{info}}}


addon.DrawScreenEffects()
return: none

{{{info}}}


addon.DrawLoadScreen()
return: none

{{{info}}}


addon.DrawInMinimap()
return: none

{{{info}}}


Custom Object Rendering

For the following calls drawMode can be one of the following, notDrawing = 0, normalDraw = 1, shadowDraw = 2, reflectionDraw = 3, refractionDraw = 4.

addon.DrawUnit()
return: none

{{{info}}}


addon.DrawFeature()
return: none

{{{info}}}


addon.DrawShield()
return: none

{{{info}}}


addon.DrawProjectile()
return: none

{{{info}}}


Synced - Unsynced Shared

Game

addon.GameID()
return: none

{{{info}}}


addon.GamePaused()
return: none

{{{info}}}


addon.GameOver()
return: none

{{{info}}}


addon.GameFrame()
return: none

{{{info}}}


addon.GamePreload()
return: none

{{{info}}}


addon.GameStart()
return: none

{{{info}}}


Teams

addon.TeamChanged()
return: none

{{{info}}}


addon.TeamDied()
return: none

{{{info}}}


Units

Features

addon.FeatureCreated()
return: none

{{{info}}}


addon.FeatureDamaged()
return: none

{{{info}}}


addon.FeatureDestroyed()
return: none

{{{info}}}


addon.FeatureMoved()
return: none

{{{info}}}


Projectiles

The following Callins are only called for weaponDefIDs registered via Script.SetWatchWeapon.

addon.ProjectileCreated()
return: none

{{{info}}}


addon.ProjectileDestroyed()
return: none

{{{info}}}


addon.Explosion()
return: bool noGfx

{{{info}}}


Synced Only

addon.CommandFallback()
return: bool used, bool finished

{{{info}}}


addon.AllowCommand()
return: bool allow

{{{info}}}


addon.AllowUnitCreation()
return: bool allow

{{{info}}}


addon.AllowUnitTransfer()
return: bool allow

{{{info}}}


addon.AllowUnitBuildStep()
return: bool allow

{{{info}}}


addon.AllowFeatureCreation()
return: bool allow

{{{info}}}


addon.AllowFeatureBuildStep()
return: bool allow

{{{info}}}


addon.AllowResourceLevel()
return: bool allow

{{{info}}}


addon.AllowResourceTransfer()
return: bool allow

{{{info}}}


addon.AllowStartPosition()
return: bool allow

{{{info}}}


addon.AllowDirectUnitControl()
return: bool allow

{{{info}}}


addon.AllowWeaponTargetCheck()
return: bool allow

{{{info}}}


addon.AllowWeaponTarget()
return: bool allowed, number priority

{{{info}}}


addon.AllowWeaponInterceptTarget()
return: bool allowed

{{{info}}}


addon.TerraformComplete()
return: bool stop

{{{info}}}


addon.MoveCtrlNotify()
return: bool moveCtrlComplete

{{{info}}}


Damage Controllers

addon.UnitPreDamaged()
return: number newDamage, number impulseMult

{{{info}}}


addon.ShieldPreDamaged()
return: bool handleCollision

{{{info}}}


addon.FeaturePreDamaged()
return: number newDamage, number impulseMult

{{{info}}}