Closed nrgorham closed 7 years ago
Has it happened again? What's the rest of the error message? It the error appears to come from a Factorio base game file not a robot army one, unless there's a stack trace and you may have only pasted the last part of it.. Thanks for the report
-------- Original message -------- From: nrgorham notifications@github.com Date: 30/04/2017 01:22 (GMT+00:00) To: kyranf/robotarmyfactorio robotarmyfactorio@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [kyranf/robotarmyfactorio] Error while running event robotarmy::on_tick (ID 0) (#102)
First off, I love the idea of this mod. Watching your swarm of killbots advance on nests is so much more entertaining than tower creeping. But it crashed my game with this error message: Error while running event robotarmy::on_tick (ID 0)
...rary/steamapps/common/Factorio/data/core/lualib/util.lua:5: attempt to index local 'position1' (a number value) This was super early game (maybe 10-15 minutes after getting Logistics). My army had just fought a base and headed back for repairs (I think). I also had a weird power outage (not sure if that's related or not). With the droid console thing, I had changed 2 settings from default. I made the hunting squad size 100 and set the retreat number to 70.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/kyranf/robotarmyfactorio","title":"kyranf/robotarmyfactorio","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/kyranf/robotarmyfactorio"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"Error while running event robotarmy::on_tick (ID 0) (#102)"}],"action":{"name":"View Issue","url":"https://github.com/kyranf/robotarmyfactorio/issues/102"}}}
Unforunately that is all the the error message I see.
I have a save file that's produced the error 3 times now. I can attach it to this if github will let me.
Where would I find the stack trace? I found a robot_army_logs file in the AppData folder robot_army_logs.txt
And the factorio-current file with the crash factorio-current.txt
Can I paste a 6mb save file?
Oh good apparently I can.
Anyway, the error does come from the base game's util script, but since it's happening during your robotarmy:on_tick thing, I would guess (completely out of my butt) that somewhere you're getting a bad result from something and you seem to be passing it to the core game's position function. Maybe something in pathfinding or placing an entity in a crowded space or something. That I have no idea whatsoever about. I know nothing at all about Factorio modding.
Hope some of these files contain something useful to you, but even if they don't, thanks for making this mod.
It looks like your squad size of 100 just isnt' playing nicely.. I saw the huge mess of squads at your production area, used the droid pick-up tool to clean it up and put them back into be respawned. moved the squad size down to 50 and have not had the issue yet. I think the game cannot find a position to place the droid so it fails with that error. If you want squad sizes of 100 then use the flying combat robot unit types.. the normal droids are just a bit too big and its hard to find space to spawn 100 of them around a droid assembler
The error comes from using util.distance() function from the factorio lualib util file. This is used in like 24 places in the mod scripts, so i'll have a look at each use of the function and see if i can work out how the input is being passed as a single integer instead of a position table (of x and y value)
I've done a bit of debugging, getDroidSpawnLocation returns -1 error, however this doesn't seem to get handled correctly in (for example) orderSquadToRetreat.
Maybe return false, or explicitly check for -1 instead of if not <var>
?
ah nice, yeah -1 will not be caught by 'if not' because if not only checks for nil values. Thanks! If there are other instances of not using the -1 return properly, it might be better to actually just return nil on purpose, which would make it more in-line and consistent with the rest of the coding style. What say you? @keryja
If you generally use nil
as an error/invalid value I'd stick with that yup
@keryja thank you my friend, you have saved me a lot of debugging time. I will commit a fix now and see if that helps @nrgorham
For documentation's sake, the way I found the (likely) source was as follows:
data/core/lualib/util.lua
to:function distance(position1, position2)
if type(position1) ~= "table" then
game.players[1].print("Pos1 ~= table")
game.players[1].print(position1)
game.players[1].print(position2)
return 10000
end
if type(position2) ~= "table" then
game.players[1].print("Pos2 ~= table")
game.players[1].print(position1)
game.players[1].print(position2)
return 10000
end
return ((position1.x - position2.x)^2 + (position1.y - position2.y)^2)^0.5
end
orderSquadToRetreat
as that tried to access the x/y propertiesgetDroidSpawnLocation
There was probably a better way to find it, but this worked out in the end.
bug is fixed
First off, I love the idea of this mod. Watching your swarm of killbots advance on nests is so much more entertaining than tower creeping.
But it crashed my game with this error message:
Error while running event robotarmy::on_tick (ID 0) ...rary/steamapps/common/Factorio/data/core/lualib/util.lua:5: attempt to index local 'position1' (a number value)
This was super early game (maybe 10-15 minutes after getting Logistics). My army had just fought a base and headed back for repairs (I think). I also had a weird power outage (not sure if that's related or not).
With the droid console thing, I had changed 2 settings from default. I made the hunting squad size 100 and set the retreat number to 70.