Page 1 of 1

LUA equivlents to COB GET/SETs

Posted: 19 Jun 2010, 19:17
by bobthedinosaur
while converting one of my cob scripts to lua I ran into an issue. Where i would normally use get/set of some constants, I am wondering how I would do this with LUA. What are the LUA equivalents of GET/SET for some of the more essential cob constants such as:


PIECE_XZ 7
PIECE_Y 8
GROUND_HEIGHT 16
ARMORED 20
VETERAN_LEVEL 32
MAX_SPEED 75
CLOAKED 76
HEADING 82
CURRENT_FUEL 93

edit: found some examples

would you use all of them like this:


local cloaked = COB.CLOAKED

Spring.UnitScript.SetUnitValue( cloaked, 0 )

Re: LUA equivlents to COB GET/SETs

Posted: 20 Jun 2010, 12:39
by jK
You shouldn't use any GET/SET functions in Lua.
Lua has its own API which is more powerful than the COB one.

The wiki will help you to find the functions you need:
http://springrts.com/wiki/Lua_Scripting

Re: LUA equivlents to COB GET/SETs

Posted: 20 Jun 2010, 14:10
by FLOZi
Lua doesn't have SetHeading without the use of MoveCtrl, for a start.

Re: LUA equivlents to COB GET/SETs

Posted: 20 Jun 2010, 17:32
by jK
Spring.SetUnitRotation
( number unitID, number rotx, number roty, number rotz ) -> nil
?

Re: LUA equivlents to COB GET/SETs

Posted: 20 Jun 2010, 18:10
by bobthedinosaur
I don't think that is the same thing as heading.

And yes I've read the wiki's, it just seems like not all of those translate to lua unit control.

Re: LUA equivlents to COB GET/SETs

Posted: 20 Jun 2010, 19:31
by jK
They are there and they even have equal function names, use ctrl+f it's a pretty nice function of your browser.

And sure SetUnitRotation contains the same functionally as HEADING in COB, you just need to use the more common euler system.

Re: LUA equivlents to COB GET/SETs

Posted: 20 Jun 2010, 19:45
by FLOZi
Why have GetUnitHeading and not SetUnitHeading, or why have it only as part of MoveCtrl?

The functions for getting piece position/direction are also dubious at best. (direction is based on angle of v1 - v0 instead of actual rotation around origin, unless you use Spring.UnitScript.GetPiece* functions).

Re: LUA equivlents to COB GET/SETs

Posted: 21 Jun 2010, 18:53
by bobthedinosaur
well if

Code: Select all

local cloaked = COB.CLOAKED
Spring.UnitScript.SetUnitValue( cloaked, 0 )

is incorrect why is CA using it? I am just saying there is a lack of proper examples.