Lua:Callins: Difference between revisions

From Spring
Jump to navigationJump to search
Flozi (talk | contribs)
sub headings for Unsynced only, fill in Player* callins
Flozi (talk | contribs)
unsynced input callins
Line 19: Line 19:


=== Input ===
=== Input ===
{{LuaCallin
|name = KeyPress
|params = key, mods, isRepeat
|return = none
|description = Called when a key is pressed. The <code>mods</code> parameter is e.g. SHIFT, ALT, CTRL.
}}
{{LuaCallin
|name = KeyRelease
|params = key
|return = none
|description = Called when the key is released.
}}
{{LuaCallin
|name = JoystickEvent
|params = ???
|return = none
|description = ???
}}
{{LuaCallin
|name = MousePress
|params = x, y, button
|return = none
|description = Called when a mouse button is pressed. The <code>button</code> parameter can be one of the following: <code>1</code> - left, <code>2</code> - middle, <code>3</code> - right.
}}
{{LuaCallin
|name = MouseRelease
|params = x, y, button
|return = none
|description = Called when a mouse button is released. Please note that in order to have Spring call MouseRelease, you need to have a MousePress call-in in the same addon that returns <code>true</code>.
}}
{{LuaCallin
|name = MouseWheel
|params = up, value
|return = none
|description = Called when the mouse wheel is moved. The parameters indicate the direction and amount of travel.
}}
{{LuaCallin
|name = MouseMove
|params = x, y, dx, dy, button
|return = none
|description = Called when the mouse is moved. The <code>dx</code> and <code>dy</code> parameters indicate the distance travelled, whereas the first two indicate the final position.
}}
{{LuaCallin
|name = IsAbove
|params = x, y
|return = none
|description = ???
}}
{{LuaCallin
|name = GetTooltip
|params = x, y
|return = none
|description = ???
}}


=== Players ===
=== Players ===
Line 43: Line 105:


=== Drawing ===
=== Drawing ===
Inside these functions, you can use the [[Lua_OpenGL_Api | Lua OpenGL Api]] to draw graphics.
 
{{LuaCallin
|name = ViewResize
|params = viewSizeX, viewSizeY
|return = none
|description = Called whenever the window is resized.
}}
 
{{LuaCallin
|name = Update
|params =
|return = none
|description = Called for every draw frame. Perform calculations in here and only drawing in Draw* callins.}}
 
Inside the Draw* functions, you can use the [[Lua_OpenGL_Api | Lua OpenGL Api]] to draw graphics.


{{LuaCallin
{{LuaCallin
Line 147: Line 223:


== Synced - Unsynced Shared ==
== Synced - Unsynced Shared ==
=== Game ===
=== Teams ===


=== Units ===
=== Units ===

Revision as of 19:10, 14 February 2014

Lua Callins

Common

addon.Initialize()
return: none

{{{info}}}


addon.Shutdown()
return: none

{{{info}}}


Unsynced Only

Input

addon.KeyPress()
return: none

{{{info}}}


addon.KeyRelease()
return: none

{{{info}}}


addon.JoystickEvent()
return: none

{{{info}}}


addon.MousePress()
return: none

{{{info}}}


addon.MouseRelease()
return: none

{{{info}}}


addon.MouseWheel()
return: none

{{{info}}}


addon.MouseMove()
return: none

{{{info}}}


addon.IsAbove()
return: none

{{{info}}}


addon.GetTooltip()
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

Teams

Units

Features

Projectiles

Synced Only

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

{{{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}}}