79236489

Date: 2024-11-29 09:30:25
Score: 1
Natty:
Report link

This is an old question, but I am having the very same problem (a specific application I need to use has Lua 4.0 embedded) that led me here.

In Lua 4.0 the library functions are called directly and without class-like prefixes. So they are available, just not in a way you expect it to be, because the very most online resources assume newer versions of Lua. The documentation to the standard libraries can be found in the Lua 4.0 Reference Manual: Section 6: Standard Libraries. Documentation of functions that were later placed in the os library can be found in Section 6.5: System Facilites. But they are indeed limited compared to newer versions of Lua. This answers the general question in your title (well 9 years later...).

I can't guess if the code snippet you provided is only an example to show that os.time() resp. the os library is not available in Lua 4 or if it is the original reason you are asking the question. If it is the original reason: you are out of luck: the time() function is indeed not available in Lua 4. But if you simply want the current system time in a specific format, you can use the date() function.

print( _VERSION )
print( date( "%Y-%m-%d %H:%M:%S" ) )
--> Lua 4.0
--> 2024-11-29 10:13:19
Reasons:
  • Blacklisted phrase (0.5): I need
  • Whitelisted phrase (-1.5): you can use
  • Long answer (-1):
  • Has code block (-0.5):
  • Me too answer (2.5): I am having the very same problem
  • Low reputation (1):
Posted by: ChaosOptimum