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)
Function from Lua: os.date()
The Standard Libraries of Lua
Re: Function from Lua: os.date()
Most os functions are blocked by the sandbox, so it looks like this is sadly not usable.
Re: Function from Lua: os.date()
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.
It returns one string from all table values.
Can it work in OpenRa?
Or another way to turn all table values to string?
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
Can it work in OpenRa?
Or another way to turn all table values to string?
Re: Function from Lua: os.date()
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()
I tried. OpenRA returns nearly the same error (as os.date) for table.concat too.I don't think the 'table' function is blocked by our sandbox, so I'd just try if that works in OpenRA.
[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.
Anyway, it was not very difficult to write it by myself. Thanks for your advise about "for".Otherwise you'll need to iterate over the table contents in a for loop and concat "manually".
I supposed to do this with "foreach". But "for" is quite good for this aim.
Re: Function from Lua: os.date()
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.