Page 1 of 1

How to check if game is running in editor?

Posted: Mon May 27, 2019 10:40 am
by ownlyme
Every time i edit my map, i have to rename my control.lua or it will screw up literally everything.
for me, this is not a too big deal - but if the end-user wants to change something, he/she won't be able to.
on the on_player_joined event and the on_player_created event, the player still has a character and is controller_type 1.
the editor's gui is not detectable either.

Re: How to check if game is running in editor?

Posted: Mon May 27, 2019 11:11 am
by Bilka
Just check if the player is using the editor controller in your events. Or use https://lua-api.factorio.com/latest/eve ... map_editor.

I'm curious though, how do things get screwed up?

Re: How to check if game is running in editor?

Posted: Mon Jun 03, 2019 3:26 pm
by ownlyme
cause the script is placing and replacing lots of stuff on init^^
i fixed it now by delaying the player controller check by 1 tick and only then triggering the init...

Re: How to check if game is running in editor?

Posted: Thu Jun 06, 2019 9:00 pm
by Rseding91
ownlyme wrote:
Mon Jun 03, 2019 3:26 pm
cause the script is placing and replacing lots of stuff on init^^
i fixed it now by delaying the player controller check by 1 tick and only then triggering the init...
That's... not how you make mods in Factorio.

If your mod is written correctly it will never care about the map editor being a thing. You can also run the game tick forward while editing through the map editor so you didn't actually fix anything.

Re: How to check if game is running in editor?

Posted: Thu Jun 06, 2019 10:57 pm
by ownlyme
Rseding91 wrote:
Thu Jun 06, 2019 9:00 pm
ownlyme wrote:
Mon Jun 03, 2019 3:26 pm
cause the script is placing and replacing lots of stuff on init^^
i fixed it now by delaying the player controller check by 1 tick and only then triggering the init...
That's... not how you make mods in Factorio.

If your mod is written correctly it will never care about the map editor being a thing. You can also run the game tick forward while editing through the map editor so you didn't actually fix anything.
huh?
i created alternative versions of the trees afterwards, with a bigger collision box (cause the creep's pathfinding is still suboptimal)
also i was too lazy to place the base's walls in a perfect circle, so i did that with tiles^^
Guess thats still fixable but it also puts a gui into every player's face ... and i have so many global variables and i don't even know how much other stuff that checking for editor status was the simplest solution...
https://mods.factorio.com/mod/dota ^^