Robot Army


Manufacture and deploy automated robot soldiers to attack your foes and defend your factory!

1 year, 10 months ago
0.13 - 1.1
30.3K

b Bug with ungenerated chunks

7 years ago
(updated 7 years ago)

So first of all: Awesome mod. I really like the idea and it has been implemented in a nice way.

But there seems to be a bug which crashes my game. So after some testing and guessing I came to the conclusion that it arises from bots, trying to either scan or enter a not yet generated chunk (couldn't yet pinpoint which one it was). So I did some messing around with your code and it seems like I´ve found a solution that works, even though it is slightly performance heavy.
So I added into the squad.lua file in the robolib folder the following lines right after line 373
chunkposition = {x=math.floor(position.x/32+0.5), y=math.floor(position.y/32+0.5)}
xp=-4
while xp < 5 do
yp=-4
while yp < 5 do
if not game.surfaces[1].is_chunk_generated(chunkposition) then
game.surfaces[1].request_to_generate_chunks(position, 128)
xp=5
yp=5
end
yp=yp+1
end
xp=xp+1
end

So essentially this code just checks if the nearby chunks are generated and if not it requests that the get generated.
I've been running my game now for many hours consecutive and let them hunt down bitters and up to now the crash didn´t reappear.

I hope this helps with the development of the mod.
Anyway. Keep up the good work.

7 years ago

Hey, thanks for that! Do you mind making a github account and posting this code as an issue on the repo? It will help me keep track of it and help with formatting too.. https://github.com/kyranf/robotarmyfactorio

Also, I have thought of forcing my droids to not only reveal the area around the, but also generate chunks around them, but concerns from users regarding possible run-away squads causing ever-expanding worlds could cause save files to become huge (bad for multiplayer) and chew up RAM for no reason.

I wonder what case causes the crash though? have you got lua error messages from it, or a full game crash? What version of factorio do you use? There was some chunk-related bugfixing in some time in factorio 13.10-13

7 years ago

Sadly I didn´t get an Lua error but a complete gamecrash (the one where you get an extra window telling you it crashed)
And yes, they do cause a massive map (my save requires by now more than 10 GB of ram and require 340MB disk space each).
Maybe it would be better to instead have them move away from unloaded chunk (have them head towards the middle of the map when ever they get within 100 tiels of an unloaded chunk or so).
Regarding Github: I´ll probably get to it later.

7 years ago

Thanks. And maybe it's related to my map-reveal feature? If i give the chart function too wide of an area, it's possible that the area may include non-generated chunks (which maybe fail to chart??)

7 years ago

Github Issue was posted. Hope it will help with your mod

7 years ago

Just installed version 0.2.2 and unfortunately I'm getting a bug as soon as a squad forms.
It's OK until about the 4th soldier (using clockwork riflebots if that is relevant) then after about 5 seconds it crashes in the LUA saying..

Error while running the event handler:
robotarmy/robolib/squadlua.lib:105:
LuaUnitGroup doesn't contain key surface

I have tried adding 4 droids to both the assembler and the guard station with the exact same result. It also happens with and without rally points

7 years ago

PurpleYouko, you must have Factorio version 0.13.14 or higher. Please update your game.

7 years ago

Awsome. That seems to have fixed it. I didn't realize I had gotten behind the latest version.

New response