Page 1 of 1

[Solved] Problem with chunk generation

Posted: Thu Jan 26, 2017 6:14 pm
by ZpmFred
Hello,

I'm currently developing a mod that deals with surface and i am facing a little problem with chunk generation so i came here in the hope that someone could help me.
Here is the initial situation

On a new map with only my mod, I'm the only player on the map, and i don't move

then
I create a new surface named "nauvis-underground-expansion-1".
(The new surface is striped of all it's entities and resources on chuck generation)
and call the function request_to_generate_chunks({-12, 1], 2) on the new surface
after that I wait like 15 to 30 seconds and call is_chunk_generated({-12, 1}) and it return me false

I fact i have to wait around 5 minutes for it to be generated

To troubleshoot the problem I added an event listener on the on_chunk_generated event and for the whole 5 minus it generate chunk for the nauvis surface, meanwhile my proc is idling at a little 6%

Is this a normal behavior ?
And how can i do to prioritize the chunk generation ?

I hope that with those information someone could help me :)

Re: Problem with chunk generation

Posted: Fri Jan 27, 2017 1:13 pm
by ZpmFred
No one has an idea, explanation or a workaround ?

Re: Problem with chunk generation

Posted: Fri Jan 27, 2017 3:22 pm
by orzelek
I don't think you can do anything about this.

Map gen has a scheduler that works at it's own speed to not cause map stutters. It seems that in your case it's so busy generating map on main surface that it doesn't have time to take a look at yours.
It would be good to prepare a simple test case so that devs could take a look.

Re: Problem with chunk generation

Posted: Fri Jan 27, 2017 3:49 pm
by Klonan
ZpmFred wrote:Hello,

I'm currently developing a mod that deals with surface and i am facing a little problem with chunk generation so i came here in the hope that someone could help me.
Here is the initial situation

On a new map with only my mod, I'm the only player on the map, and i don't move

then
I create a new surface named "nauvis-underground-expansion-1".
(The new surface is striped of all it's entities and resources on chuck generation)
and call the function request_to_generate_chunks({-12, 1], 2) on the new surface
after that I wait like 15 to 30 seconds and call is_chunk_generated({-12, 1}) and it return me false

I fact i have to wait around 5 minutes for it to be generated

To troubleshoot the problem I added an event listener on the on_chunk_generated event and for the whole 5 minus it generate chunk for the nauvis surface, meanwhile my proc is idling at a little 6%

Is this a normal behavior ?
And how can i do to prioritize the chunk generation ?

I hope that with those information someone could help me :)
If you want it done quickly, just chart the area for the neutral force, it should prioritize the chunks that need charting

Re: Problem with chunk generation

Posted: Fri Jan 27, 2017 6:43 pm
by ZpmFred
Thanks for the reply and idea.

I just tied the charting solution but it does not work it's still generating chunk for nauvis but not for the new surface :(

Re: Problem with chunk generation

Posted: Fri Jan 27, 2017 7:21 pm
by ZpmFred
here are detailed steps to reproduce my situation on vanilla

first create a new game just set in peaceful

Code: Select all

game.create_surface("test-1")
game.surfaces["test-1"].request_to_generate_chunks({-20, -20}, 2)
wait 30 sec

Code: Select all

game.player.print(tostring(game.surfaces["test-1"].is_chunk_generated({-20, -20})))
--> return false

Code: Select all

game.forces["neutral"].chart("test-1", {{-30, -30}, {-10, -10}})
wait another 30 sec

Code: Select all

game.player.print(tostring(game.surfaces["test-1"].is_chunk_generated({-20, -20})))
--> return false again

Re: Problem with chunk generation

Posted: Fri Jan 27, 2017 9:29 pm
by Rseding91
http://lua-api.factorio.com/latest/LuaS ... ate_chunks takes world positions

http://lua-api.factorio.com/latest/LuaS ... _generated takes chunk positions

http://lua-api.factorio.com/latest/LuaF ... orce.chart takes a bounding box which is world positions

You're giving the wrong locations to the different calls.

Re: Problem with chunk generation

Posted: Fri Jan 27, 2017 9:54 pm
by ZpmFred
Ho ho no don't tell me that I just have done that ... RTFM (facepalm)

from this point the chunk generate instantly after the call to request_to_generate_chunk ..

Thank you for the time you spent into helping me :D