Page 1 of 1

Spring.SetUnitStealth and .fbi vs .lua

Posted: 28 Mar 2011, 06:18
by Von66341
Hey! just some question on SetUnitStealth and .fbi vs .lua.

I understand that the following can be use to set stealth true/false in a unit.
Spring.SetUnitSonarStealth
( number unitID, boolean sonarStealth ) -> nil

Is it able to be use with a unitdef that is written in .fbi?

If I would like to convert .fbi to .lua how should I go about it?
Is there a wiki or guide on this?
What are the main difference of .fbi and .lua?

Thanks!

Re: Spring.SetUnitStealth and .fbi vs .lua

Posted: 28 Mar 2011, 11:39
by SpikedHelmet
Von66341 wrote: I understand that the following can be use to set stealth true/false in a unit.
Spring.SetUnitSonarStealth
( number unitID, boolean sonarStealth ) -> nil

Is it able to be use with a unitdef that is written in .fbi?
Yes it can as it is an engine function that doesn't care what language your unitdefs or scripts are written in.
If I would like to convert .fbi to .lua how should I go about it?
Is there a wiki or guide on this?
What are the main difference of .fbi and .lua?
Looking at existing Lua scripts from ZK or Gundam or etc will help you a lot with familiarizing, I'd start there.

Re: Spring.SetUnitStealth and .fbi vs .lua

Posted: 28 Mar 2011, 15:31
by oksnoop2
BA recently made the jump to lua. maybe open a side by side of a 7.20 and a 7.31 unit.

Re: Spring.SetUnitStealth and .fbi vs .lua

Posted: 28 Mar 2011, 19:48
by Guessmyname
Isn't there an fbi > lua conversion script around somewhere?

Re: Spring.SetUnitStealth and .fbi vs .lua

Posted: 28 Mar 2011, 20:00
by CarRepairer

Re: Spring.SetUnitStealth and .fbi vs .lua

Posted: 29 Mar 2011, 00:36
by Forboding Angel
stealth = true, (lua unitdef)
stealth = 1; (fbi unitdef)

Re: Spring.SetUnitStealth and .fbi vs .lua

Posted: 29 Mar 2011, 02:55
by Von66341
Hey! my unitdef are in .fbi

I created a gadget, to turn on/off stealth.

Part of the code as following:

Code: Select all

if cmdID = CMD_STEALTH then 
local ud = UnitDefs[Spring.GetUnitDefID(unitID)]
if(ud.stealth ==false) then
Spring.SetUnitStealth(unitID,true)
Spring.Echo("Stealth is on") 
Spring.Echo(ud.stealth) --line that print false
else 
Spring.SetUnitStealth(unitID,false) 
Spring.Echo("Stealth is off") 
Spring.Echo(ud.stealth) 
When i run in it the game,
The line,Spring.Echo(ud.stealth) will still print out false, after the line, Spring.SetUnitStealth(unitID,true) is run.
Did I use Spring.SetUnitStealth wrongly?

Re: Spring.SetUnitStealth and .fbi vs .lua

Posted: 29 Mar 2011, 15:02
by trepan
unitDef ~= unit

Want you want is the GetUnitStealth() function, which does not exist.

Re: Spring.SetUnitStealth and .fbi vs .lua

Posted: 29 Mar 2011, 22:19
by Forboding Angel
OOOOOOOOOOOOOOHHHHHHHHHHHH!

I'm sorry I totally misunderstood. You were wanting something so that stealth could be turned on and off. Well you can still do that using radarjamming. It's not as elegant as a stealth on/off switch, but what would be the advantage of having stealth be off?

Re: Spring.SetUnitStealth and .fbi vs .lua

Posted: 29 Mar 2011, 22:24
by SinbadEV
Forboding Angel wrote:OOOOOOOOOOOOOOHHHHHHHHHHHH!

I'm sorry I totally misunderstood. You were wanting something so that stealth could be turned on and off. Well you can still do that using radarjamming. It's not as elegant as a stealth on/off switch, but what would be the advantage of having stealth be off?
I would imagine some other game mechanic would be tied to the state (for example increased power consumption or slower movement when stealth is turned on... similar to cloaking)

Re: Spring.SetUnitStealth and .fbi vs .lua

Posted: 30 Mar 2011, 11:15
by Von66341
radarjamming?
Hmm...how should I look into it?

Re: Spring.SetUnitStealth and .fbi vs .lua

Posted: 30 Mar 2011, 18:35
by SpikedHelmet
we use set stealth on/off using on/off button (activation):

function script.Activate()
Spring.SetUnitStealth(unitID, false)
end

function script.Deactivate()
Spring.SetUnitStealth(unitID, true)
end

Re: Spring.SetUnitStealth and .fbi vs .lua

Posted: 31 Mar 2011, 08:57
by Von66341
Thanks SpikedHelmet!