Page 1 of 1
Function from Lua: os.date()
Posted: Sun Nov 22, 2020 7:02 pm
by Adrian
I read about Lua in general now. About the Standard Libraries.
Here is a chapter
"Date and Time":
https://www.lua.org/pil/22.1.html
I try to use function
os.date(). It must return string or table with
date and/or
time data.
Can I use this function in any game lua files?
I try to write like this:
vrem = os.date()
or even copy example of table from manual
temp = os.date("*t", 906000490)
and this does not work.
Fatal Lua Error: [string "atreides03a.lua"]:196: attempt to call field 'date' (a nil value)
Re: Function from Lua: os.date()
Posted: Mon Nov 23, 2020 2:11 pm
by abcdefg30
Most os functions are blocked by the sandbox, so it looks like this is sadly not usable.
Re: Function from Lua: os.date()
Posted: Mon Nov 23, 2020 3:41 pm
by Adrian
Thank you.
I read about tables now. About
table.concat().
http://lua-users.org/wiki/TableLibraryTutorial
This is example for command line. And it work in my command line, Lua 5.1.5.
Code: Select all
> = table.concat({ 1, 2, "three", 4, "five" })
12three4five
It returns one string from all table values.
Can it work in OpenRa?
Or another way to turn all table values to string?
Re: Function from Lua: os.date()
Posted: Tue Nov 24, 2020 9:02 am
by abcdefg30
I don't think the 'table' function is blocked by our sandbox, so I'd just try if that works in OpenRA. Otherwise you'll need to iterate over the table contents in a for loop and concat "manually".
Re: Function from Lua: os.date()
Posted: Tue Nov 24, 2020 9:44 pm
by Adrian
I don't think the 'table' function is blocked by our sandbox, so I'd just try if that works in OpenRA.
I tried. OpenRA returns nearly the same error (as os.date) for table.concat too.
[string "harkonnen09b.lua"]:547: attempt to call field 'concat' (a nil value)
So I thought, may be I must
include some libraries to activate these functions... May be no.
Otherwise you'll need to iterate over the table contents in a for loop and concat "manually".
Anyway, it was not very difficult to write it by myself. Thanks for your advise about "
for".
I supposed to do this with "
foreach". But "
for" is quite good for this aim.
Re: Function from Lua: os.date()
Posted: Sat Jan 02, 2021 8:13 pm
by Matt
Those functions have to be added there
https://github.com/OpenRA/OpenRA/blob/8 ... ua#L51-L72 they are currently not whitelisted, but they do sound safe.