I was trying to use a random number in a dungeon editor script. I found the 'math.random' function in a lua document on line. The same document gave a lua function to cause the lua random generator to always generate a different series of numbers. It was 'math.randomseed(os.time()). The problem is the dungeon editor doesn't seem to recognize 'os.time'. Is there any way to access system time in a dungeon editor script? Or is there any other way to seed the random generator with a script?
Follow up:
Before submitting this I tried the random function in the dungeon editor and it seems it does generate a different series of random numbers each time. Can anyone explain why you don't have to seed the generator? Also I would still like to know about accessing the system time.
random seed
Re: random seed
Grimrock frequently calls the RNG itself. Setting the seed in your dungeon will result in lower quality numbers, not higher. There's no way to access system time in the Grimrock scripting interface, there's also no reason to. If you need a tightly controlled RNG you will need to implement it yourself in Grimrock 1. (Grimrock 2 comes with a MersenneTwister class that you can use for that).
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.