User:Flozi

From Spring
Revision as of 17:41, 28 October 2013 by Flozi (talk | contribs) (shove this in here for now, both are wrong due to 'thread' behaviour in LUS)
Jump to navigationJump to search

LUS Script Examples

How to use

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

Script Scaffolds

Builder

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)
    -- 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

Factory

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)

local buildPad = piece("buildPad")
function script.QueryBuildInfo()
    return buildPad
end

-- Called when factory yard opens
function script.Activate()
    -- TODO: This is where you would add your unpack / point towards animation
end

-- Called when factory yard closes
function script.Deactivate()
    -- TODO: This is where you would add your pack-up animation
end

function script.StartBuilding()
    -- TODO: animation 
    SetUnitValue(COB.INBUILDSTANCE, 1)
end
function script.StopBuilding()
    SetUnitValue(COB.INBUILDSTANCE, 0)
end

Template:LuaCallout & Template:LuaCallin Examples


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


addon.AllowUnitCreation()
return: bool allow

{{{info}}}


addon.Initialize()
return: none

{{{info}}}


addon.Shutdown()
return: none

{{{info}}}


addon.PlayerChanged()
return: none

{{{info}}}

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)

Move all pages in Units- to Units: or maybe Gamedev: ?

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

Categories