All pastes #752696 Raw Edit

Someone

public text v1 · immutable
#752696 ·published 2007-10-28 17:24 UTC
rendered paste body
In the cob file, insert functions like this:


Potato(speed)
{
  //stuff
}

Broccoli(heading)
{
  //stuff
  return health;
}



--------------------------------------------------------------------------------



In gadget:Initialize apply this to all affected units:

local function SetupUnit(unitID)
  scriptIDs.potato = GetCOBScriptID(unitID, "Potato")
  scriptIDs.broccoli   = GetCOBScriptID(unitID, "Broccoli")
end



function reference:

Spring.GetCOBScriptID

 ( number unitID, string funcName ) -> nil | number funcID


--------------------------------------------------------------------------------


in gadget:GameFrame, use these functions:

CallCOBScript(unitID, scriptIDs.potato, 0, speed)
health = CallCOBScript(unitID, scriptIDs.broccoli,   1, heading)



function reference: 

Spring.CallCOBScript

 ( number unitID, number funcID | string funcName, number retArgs, COBArg1, COBArg2, ... )
   -> nil | number returnValue, number retArg1, number retArg2, ...

   
--------------------------------------------------------------------------------


You can also use these functions for setting and getting cob constants but i never tried them.

Spring.GetUnitCOBValue

 ( number unitID [, boolean splitData=false], number COBValue
   [, number param1 [,number param2 [, number param3 [, number param4 ] ] ] ] ) -> nil

Spring.SetUnitCOBValue

 ( number unitID, number COBValue, number param1 [,number param2] ) -> nil

 
--------------------------------------------------------------------------------