Set Spawn


Commands to manage player/force spawn point

Utilities
4 years ago
0.17 - 0.18
48

b Your mod interacts badly with others that make Forces.

4 years ago

Your code, around line 30 of your control, assumes that any newly created force has a spawn position.

My mod https://mods.factorio.com/mod/Factorio-Tiberium makes a force that does not. And I imagine there are several others as well.

Before you go trying to use something's, well, anything, you should be checking that it exists first.

if turret.prepare_range then turret.prepare_range = turret.prepare_range*2 end

That checks for the existence of a turret's prepare_range, and then does stuff, if it exists.

If you need more than that, i can help.

4 years ago
(updated 4 years ago)

I wasn't aware that a force could have no spawn point; the API docs don't mention this. I'll push out a fix a little later, as well as bump the Factorio version while I'm at it.

4 years ago

Welp. Now you know!

I got this report, and was wondering why the hell my mod crashed like this. Then I noticed the other mod name.

4 years ago
(updated 4 years ago)

So it turns out that forces indeed default to a spawn position of {0, 0}, which isn't a problem. The problem, however, is that I'm a goof misread that how arguments are passed to event callbacks. I was assuming the new LuaForce was being passed when in reality it's within the actual table that gets passed. Whoops. πŸ€¦β€β™‚οΈ

4 years ago

As long as you figured it out and fixed it.

4 years ago

Alright, I pushed a new version. Let me know if you run into any other issues. πŸ™‚

New response