LUA equivlents to COB GET/SETs

LUA equivlents to COB GET/SETs

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
bobthedinosaur
Blood & Steel Developer
Posts: 2702
Joined: 25 Aug 2004, 13:31

LUA equivlents to COB GET/SETs

Post 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 )
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: LUA equivlents to COB GET/SETs

Post 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
Last edited by jK on 20 Jun 2010, 18:04, edited 1 time in total.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: LUA equivlents to COB GET/SETs

Post by FLOZi »

Lua doesn't have SetHeading without the use of MoveCtrl, for a start.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: LUA equivlents to COB GET/SETs

Post by jK »

Spring.SetUnitRotation
( number unitID, number rotx, number roty, number rotz ) -> nil
?
User avatar
bobthedinosaur
Blood & Steel Developer
Posts: 2702
Joined: 25 Aug 2004, 13:31

Re: LUA equivlents to COB GET/SETs

Post 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.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: LUA equivlents to COB GET/SETs

Post 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.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: LUA equivlents to COB GET/SETs

Post 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).
User avatar
bobthedinosaur
Blood & Steel Developer
Posts: 2702
Joined: 25 Aug 2004, 13:31

Re: LUA equivlents to COB GET/SETs

Post 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.
Post Reply

Return to “Lua Scripts”