cfrag Posted February 22, 2023 Share Posted February 22, 2023 Currently, there is no way to establish current date and time in a mission; we merely get game time via timer.getTime(). Beside other obvious tasks like timestamping, there is one very important use case that requires access to an unpredictable (at time of mission writing), constantly changing value: math.randomseed(). To truly randomize a mission, we need access to a value that is not predictable, else random's sequence is predictable. Lua's os.time() is accessible only via an un-sanitized 'os' library, and I want that library to stay sanitized. Hence my request: please provide a method to get an ever-changing value from the running system; preferably current datetime as an integer. 1 Link to comment Share on other sites More sharing options...
TEMPEST.114 Posted February 22, 2023 Share Posted February 22, 2023 (edited) +1 Although getting absolute time + mission time and doing some maths with it before doing the math.random() gets me close enough. Edited February 22, 2023 by Elphaba Link to comment Share on other sites More sharing options...
PravusJSB Posted March 30, 2023 Share Posted March 30, 2023 (edited) Just a thought for you to consider on allowing the os library access but keeping security the way I do it. -- localise all risky functions so no code but inside this scope can access local null_fun = function() _log("Security alerts can go here") return end local os_execute = os.execute os.execute = null_fun local os_remove = os.remove os.remove = null_fun local os_open_uri = os.open_uri os.open_uri = null_fun local os_run_process = os.run_process os.run_process = null_fun -- -- Provide global API of my naming, so only I would know... as an array (no keys) so only I would know the index of which func. API_FUNCS = { os_execute, -- call like this API_FUNCS[1](...) } -- -- module security here... remove the library if you want to aswell os.getenv = nil os.difftime = nil os.run_process = nil os.remove = nil os.execute = nil os.open_uri = nil os.rename = nil os.getpid = nil console = nil -- I wrote that for you its not a copy/paste so hopefully get the jist, it should work but there may be typos or errors... I will be providing a 24/7 support line if you need it, please deposit your bank details in my DMs Edited March 30, 2023 by PravusJSB 1 1 Creator & Developer of XSAF ::An AI model that wants to kill you, and needs no help from humans. Discord: PravusJSB#9484 twitch.tv/pravusjsb https://www.patreon.com/XSAF https://discord.gg/pC9EBe8vWU https://bmc.link/johnsbeaslu Work with me on Fiverr: https://www.fiverr.com/pravusjsb Link to comment Share on other sites More sharing options...
cfrag Posted March 31, 2023 Author Share Posted March 31, 2023 (edited) Thank you, @PravusJSB, that's a really elegant approach that I'm experimenting with right now (man I wish Lua had proper introspection and reflection). I guess the only drawback (a byproduct intended for security) here is that it's server-individual. A mission that I write with this approach can't run on another server unless their server has exactly the same script installed. My server provider currently also balks at modifying missionscripting beyond commenting out lfs and io, but this modification is still great for my local server. Thanks! -ch Edited March 31, 2023 by cfrag Link to comment Share on other sites More sharing options...
Recommended Posts