Jump to content

Recommended Posts

Hi, I want to ask if someone understands this strange behavior:

worldgen_main.lua has this function that when the module is loaded it gets executed:

function SetWorldGenSeed(seed)
	if seed == nil then
		seed = tonumber(tostring(os.time()):reverse():sub(1,6))
	end

	math.randomseed(seed)
	math.random()

	return seed
end

I do know that this is running in the WorldSim API in the client thread, but I don't know how much this affects the script running inside it.

For example, when this script is executed in the WorldSim thread (during world generation) the SEED value always has 10 digits, but when you run this in your local machine the result is kinda strange: it only has 6 digits. I didn't debugged the client yet to see if the API sets a requirement or if the 'os.time' gets different value running in the "C environment", can someone explain it to me?

@edit:

Solved: The WorldSim API thread probably starts the SEED, because it's never nil as I tested here. And the condition SEED == os.time() is always true.

Edited by Provoked

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...