LUA Beacons in LUA

4throck

Enthusiast !
Joined
Jun 19, 2008
Messages
3,502
Reaction score
1,008
Points
153
Location
Lisbon
Website
orbiterspaceport.blogspot.com
Hi all,

I'm improving my Agena MFD with some systems simulation.
LUA comes with orbiter and it's a relatively fast way to do this sort of thing.
It's going very well but I'm having difficulty in setting up beacon lights.

To get point lights I'm doing:

vagena = oapi.get_objhandle('GATV')
name = oapi.get_objname(vagena)
v2 = vessel.get_interface(name)
le = v2:add_pointlight({x=0.0,y=0.4391,z=4},{range=2,att0=1,att1=1,att2=1},{r=.8,g=1,b=1})
le:activate(true)

That's simple enough and works perfectly.


For beacons I've tried (based on several examples):

le_aq_strong = v2:AddBeacon ({{shape = BEACONSHAPE_COMPACT}, {pos={-0.4357,0.0677,-3.5832}}, {col={1,1,1}}, {size=0.7}, {falloff=0.6}, {period=13}, {duration=7}, {tofs=2}, {active=true}})


(Of course, I tried some variations of that). No luck, I get a CTD.

Any clues on how to setup beacons in LUA?
Orbiter SKD mentions that I should pass a variable, but it looks more like a dictionary with keys
 

martins

Orbiter Founder
Orbiter Founder
Joined
Mar 31, 2008
Messages
2,448
Reaction score
462
Points
83
Website
orbit.medphys.ucl.ac.uk
This may sound stupid, but where is the vessel:AddBeacon Lua function coming from? It's not part of the default Lua interface, so did you install an extended Orbiter Lua API? If so, and if you have the source for the implementation of that API function, maybe you could have a look at the code of AddBeacon to see what's going on. It looks like a thin wrapper for the VESSEL::AddBeacon method of the C++ API.
 

4throck

Enthusiast !
Joined
Jun 19, 2008
Messages
3,502
Reaction score
1,008
Points
153
Location
Lisbon
Website
orbiterspaceport.blogspot.com
Martins, I was under the impression that LUA supported almost all the C++ API. It only means that you are doing a good job!
So "AddBeacon" was a good guess.
I just rechecked Orbiter Help and indeed it's not supported.:facepalm:


Can I motivate you to provide a more complete LUA implementation (keyboard presses come to mind)? :hmm:
It's a very accessible way to create vessels and MFDs with system simulation and complex interaction.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,615
Reaction score
2,335
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
Can I motivate you to provide a more complete LUA implementation (keyboard presses come to mind)? :hmm:
It's a very accessible way to create vessels and MFDs with system simulation and complex interaction.

Isn't the LuaVessel source code available?
 

martins

Orbiter Founder
Orbiter Founder
Joined
Mar 31, 2008
Messages
2,448
Reaction score
462
Points
83
Website
orbit.medphys.ucl.ac.uk
Can I motivate you to provide a more complete LUA implementation (keyboard presses come to mind)? :hmm:
It's a very accessible way to create vessels and MFDs with system simulation and complex interaction.
I do aim to add more missing interface functions to the Lua API over time, but as always I am rather short of spare time, so it might be a while. Writing the code itself is actually pretty straightforward (most functions are just thin wrappers to the corresponding C++ API functions), but writing the documentation is rather more time-consuming.

Isn't the LuaVessel source code available?
Yes, the entire Lua API is available in source as part of the Orbiter SDK. Most of the API is in Orbitersdk/samples/LuaScript/LuaInterpreter/Interpreter.{h,cpp}. A framework for vessel callbacks is implemented in Orbitersdk/samples/ScriptVessel/*, and a sample implementation is in Config/Vessels/ScriptPB.cfg.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,615
Reaction score
2,335
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
Yes, the entire Lua API is available in source as part of the Orbiter SDK. Most of the API is in Orbitersdk/samples/LuaScript/LuaInterpreter/Interpreter.{h,cpp}. A framework for vessel callbacks is implemented in Orbitersdk/samples/ScriptVessel/*, and a sample implementation is in Config/Vessels/ScriptPB.cfg.

So, forking off a ScriptVessel2 would be no problem. :)
 

4throck

Enthusiast !
Joined
Jun 19, 2008
Messages
3,502
Reaction score
1,008
Points
153
Location
Lisbon
Website
orbiterspaceport.blogspot.com
I don't think we need much more LUA specific documentation, because we have the SDK and the help as reference. That's more than enough to go on, at least for me and for what I'm trying to do.

Regarding the topic, I'll implement the beacons using animations, no problem.
 
Top