Orbiter-Forum  

Go Back   Orbiter-Forum > Orbiter Addons > Orbiter Lua Scripting
Register Blogs Orbinauts List Social Groups FAQ Projects Mark Forums Read

Orbiter Lua Scripting Find support, share snippets and general discussion around using the Lua engine in Orbiter.

Reply
 
Thread Tools
Old 07-10-2019, 05:31 PM   #1
dmurley
Orbinaut
Default Lua print() function and Lua libraries?

Does the Lua print() function not work in the Lua console (in Orbiter) because that console is not defined as stdout?

Are the Lua libraries generally available?

Thanks.
dmurley is offline   Reply With Quote
Old 07-11-2019, 07:04 PM   #2
kuddel
Donator
Default

What do you expect that function to do? And why not just roll your own...

For just a "shortcut" to term.out() :
Code:
function print (s)
  term.out(s)
end
For a more (C library) sprintf like behaviour:
Code:
function printf (fmt, ...)
  term.out(string.format(fmt, unpack(arg)))
end
If you are planning to use it/them in multiple scripts, put it in a Lua-file under "Scripts/" under a "catchy" name (e.g. "my_lib.lua").
Then you can "include" the definitions/declarations in your Lua script via:
Code:
run('my_lib')
-- ... your code using it goes here ...
Although, those "one-liners" would barely make it a "Library"

And I don't think these should be made "Orbiter-standard", as the current functionality is enough to do the things one has to do with a fairly small amount of extra work.
Second, these print functions are only useful in an terminal-environment; by using a member of term, it is obvious for any reader of the script where it goes...
kuddel is offline   Reply With Quote
Thanked by:
Old 07-11-2019, 09:20 PM   #3
dmurley
Orbinaut
Default Just studying Lua and am curious

Just studying Lua and wondering what happened to print(). I realize that I can use term.out() instead (which I will instead of recreating a print function), but that doesn't help me understand what is happening here.

Also, are the other Lua libraries generally available?
dmurley is offline   Reply With Quote
Old 07-11-2019, 10:34 PM   #4
kuddel
Donator
Default

What exactly do you mean by "[...]are the other Lua libraries generally available"?

If you like to know if the Standard Libraries as of chapter 5 of the Lua documentation are available in Orbiter, then: yes they are (with minor exceptions maybe).

The Lua core used in Orbiter is basically Lua 5.1 in all it's glory

Some few features might not be available, but I have no knowledge of them.
Also no reason not to try and see if they work.

If some specific functionality is not working, you can ask for that specific issue and we might give you an explanation why (or why not).

Lua by the way is more of a way to access Orbiter's API through a scripting language, not so much about a Feature-Rich-Library-Collection (like .NET e.g.)

Last edited by kuddel; 07-11-2019 at 10:37 PM.
kuddel is offline   Reply With Quote
Thanked by:
Reply

  Orbiter-Forum > Orbiter Addons > Orbiter Lua Scripting


Thread Tools

Posting Rules
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Jump


All times are GMT. The time now is 11:13 AM.

Quick Links Need Help?


About Us | Rules & Guidelines | TOS Policy | Privacy Policy

Orbiter-Forum is hosted at Orbithangar.com
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Copyright 2007 - 2017, Orbiter-Forum.com. All rights reserved.