3

I'm a novice programmer, so apologies in advance if I use imprecise terminology.

I'm currently working with the Binding of Isaac: Afterbirth+ Lua modding API, which according to the developer of Atom-boilua uses Lua 5.3 . I want to read the user's local date and time, but unfortunately the API prevents use of the OS (and I/O) libraries, for security reasons. That means that os.date() is unavailable, and the API itself doesn't have any built-in functions to read the date and time on the local machine.

So since the API doesn't have any way of doing this, I was wondering if there might be a way of doing it with Lua alone, without using os.date().

Things the API supports:

  • Reading/Writing to a single text file
  • Support for lua files other than main.lua which can be accessed using require()
  • JSON4Lua

Things the API does not support (as far as I know):

  • Complex libraries, ie with files distributed throughout folders. You can include folders with the mod files, but I don't think the API lets you access them properly. (It's very possible that I'm wrong about this and just haven't figured it out yet.)
  • Installing libraries period - you can pretty much only ship mods with whatever files can go in the same directory as the main mod file.

Is there any way of accessing date/time within these restrictions, or am I just out of luck?

  • Can you create a text file, then read the created or last updated time? Is the 'os' module available at all? – ryanwebjackson Jun 22 '18 at 12:38
  • No, as far as I'm aware the os module is completely disabled. There's an outside chance I can access the time the file was last modified, though. That might be worth something. Can I do that without the os and i/o libraries? – Pseudogenesis Jun 22 '18 at 22:54
  • Actually, [it seems this isn't possible without I/O or external libraries.](https://stackoverflow.com/questions/33296834/how-can-i-get-last-modified-timestamp-in-lua) So it looks like I'm just out of luck here, unfortunately. – Pseudogenesis Jun 22 '18 at 23:24
  • Can you make a web service call though? – ryanwebjackson Jun 22 '18 at 23:25
  • 1
    No, it seems networking is impossible without the user enabling the "--luadebug" launch option, which defeats the purpose because that would enable the os library anyway. – Pseudogenesis Jun 22 '18 at 23:36

1 Answers1

2

There is no way with Lua alone, without the os library, to get the current data/time. The os library is THE interface between the Lua runtime and the underlying OS.

brianolive
  • 1,573
  • 2
  • 9
  • 19