User:Flozi: Difference between revisions

From Spring
Jump to navigationJump to search
Flozi (talk | contribs)
Flozi (talk | contribs)
cleanup
Line 1: Line 1:
= LUS Script Examples =
= My User Subpages =  
{{Special:PrefixIndex/User:Flozi/}}


== How to use ==
= TODO: =
* <code>FIXME</code> - Indicates a section of code you will need to tweak to suit your own unit / model
* <code>TODO</code> - Indicates an optional section of code is missing that you may wish to pad out e.g. with an animation


== Script Scaffolds ==
Continue to improve [[Gamedev:Main]]
=== Builder ===
<code><pre>
local nanoPieces = {}
-- FIXME: this example has 2 nano pieces to alternate between
for i = 1, 2 do
    -- FIXME: the pieces are named nanoPiece1 and nanoPiece2 in the model
    nanoPieces[i] = piece("nanoPiece" .. i)
end
Spring.SetUnitNanoPieces(unitID, nanoPieces)


function script.StartBuilding(heading, pitch)
[[Assimp]] build upon, metadata doc, split tutorial again >_>
    -- TODO: This is where you would add your unpack / point towards animation
    SetUnitValue(COB.INBUILDSTANCE, 1)
end
function script.StopBuilding()
    -- TODO: This is where you would add your pack-up animation
    SetUnitValue(COB.INBUILDSTANCE, 0)
end
</pre></code>


=== Factory ===
Revamp [[LuaCallinReturn]]
<code><pre>
local nanoPieces = {}
-- FIXME: this example has 2 nano pieces to alternate between
for i = 1, 2 do
    -- FIXME: the pieces are named nanoPiece1 and nanoPiece2 in the model
    nanoPieces[i] = piece("nanoPiece" .. i)
end
Spring.SetUnitNanoPieces(unitID, nanoPieces)


function script.QueryBuildInfo()
Page on spring wiki etiquette ([[SpringWiki]]) / style guide & template usage ([[Mapdev:WikiGuide]]) /namespace conventions ([[Spring:PageNamingConventions]]) - pages are good already; put these in revamped community portal?
    -- FIXME: the pad piece is named buildPad in the model
    return piece("buildPad")
end


local function OpenCloseAnim(open)
Move all pages in [http://springrts.com/mediawiki/index.php?title=Special%3APrefixIndex&prefix=Animation-&namespace=0 Animation-] to [http://springrts.com/mediawiki/index.php?title=Special%3APrefixIndex&prefix=Animation%3A&namespace=0 Animation:]
    Signal(1) -- Kill any other copies of this thread
    SetSignalMask(1) -- Allow this thread to be killed by fresh copies
    if open then
        -- TODO: This is where you would add your opening up anim
    else
        -- TODO: This is where you would add your closing up anim
    end
    SetUnitValue(COB.INBUILDSTANCE, open and 1 or 0)
    SetUnitValue(COB.BUGGER_OFF, open and 1 or 0)
end


-- Called when factory yard opens
Clickable / right-click copy pasteable anchors in <nowiki>{{tag}}</nowiki> et al
function script.Activate()
    -- OpenCloseAnim must be threaded to call Sleep() or WaitFor functions
    StartThread(OpenCloseAnim, true)
end
 
-- Called when factory yard closes
function script.Deactivate()
    -- OpenCloseAnim must be threaded to call Sleep() or WaitFor functions
    StartThread(OpenCloseAnim, false)
end
 
function script.StartBuilding()
    -- TODO: You can run any animation that continues throughout the build process here e.g. spin pad
end
 
function script.StopBuilding()
    -- TODO: You can run any animation that signifies the end of the build process here
end
</pre></code>
 
=== Wind Generator ===
<code><pre>
-- FIXME: Assumes model has pieces named 'tower' and 'blades'
local tower, blades = piece("tower", "blades")


function script.WindChanged (number heading, number strength)
  -- Turn the tower to face the wind at 30deg/s
  Turn(tower, y_axis, heading, math.rad(30))
  -- Spin the turbine blades relative to wind strength
  -- FIXME: Here I set rotational speed to half of strength
  Spin(blades, z_axis, strength * 0.5)
end
</pre></code>
<hr/>
= Template:LuaCallout Examples =
= Template:LuaCallout Examples =
{{LuaCallout
{{LuaCallout
|parent = Spring
|parent = Spring
Line 99: Line 24:
|description = Imposes a one-off usage of resources on the given team. The return value indicates whether or not the team had sufficient resources to meet the usage demand.}}
|description = Imposes a one-off usage of resources on the given team. The return value indicates whether or not the team had sufficient resources to meet the usage demand.}}
<hr/>
<hr/>
= Lua Callins =
== Common ==
{{LuaCallin
|addon = addon
|name = Initialize
|params =
|return = none
|description = Called when the addon is (re)loaded.
}}
{{LuaCallin
|addon = addon
|name = Shutdown
|params =
|return = none
|description = Called when the addon or the game is shutdown.
}}
== Unsynced Only ==
{{LuaCallin
|addon = addon
|name = DrawWorldPreUnit
|params =
|return = none
|description = Spring draws units, features, some water types, cloaked units, and the sun.
}}
== Synced - Unsynced Shared ==
{{LuaCallin
|addon = addon
|name = PlayerChanged
|params = number playerID
|return = none
|description = Called whenever a player's status changes e.g. becoming a spectator.
}}
== Synced Only ==
{{LuaCallin
|addon = addon
|name = AllowUnitCreation
|params = number unitDefID, number builderID, number builderTeam, <br/> number x, number y, number z, number facing
|return = bool allow
|description = Called just before unit is created, the boolean return value determines whether or not the creation is permitted.
}}
<hr/>
= TODO: =
Continue to improve [[Gamedev:Main]]
[[Assimp]] build upon, metadata doc, split tutorial again >_>
Revamp [[LuaCallinReturn]]
Page on spring wiki etiquette ([[SpringWiki]]) / style guide & template usage ([[Mapdev:WikiGuide]]) /namespace conventions ([[Spring:PageNamingConventions]]) - pages are good already; put these in revamped community portal?
Move all pages in [http://springrts.com/mediawiki/index.php?title=Special%3APrefixIndex&prefix=Animation-&namespace=0 Animation-] to [http://springrts.com/mediawiki/index.php?title=Special%3APrefixIndex&prefix=Animation%3A&namespace=0 Animation:]
Clickable / right-click copy pasteable anchors in <nowiki>{{tag}}</nowiki> et al

Revision as of 14:43, 1 November 2013

My User Subpages

TODO:

Continue to improve Gamedev:Main

Assimp build upon, metadata doc, split tutorial again >_>

Revamp LuaCallinReturn

Page on spring wiki etiquette (SpringWiki) / style guide & template usage (Mapdev:WikiGuide) /namespace conventions (Spring:PageNamingConventions) - pages are good already; put these in revamped community portal?

Move all pages in Animation- to Animation:

Clickable / right-click copy pasteable anchors in {{tag}} et al

Template:LuaCallout Examples

{{{prefix}}}UseTeamResource ( {{{arg1}}}, {{{arg2}}}, {{{arg3}}}, {{{arg4}}}, {{{arg5}}}, {{{arg6}}}, {{{arg7}}}, {{{arg8}}}, {{{arg9}}} )
return: nil | bool hadEnough