How to check if game is running in editor?

Things that already exist in the current mod API
User avatar
ownlyme
Filter Inserter
Filter Inserter
Posts: 445
Joined: Thu Dec 21, 2017 8:02 am
Contact:

How to check if game is running in editor?

Post 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.
creator of 55 mods
My api requests/suggestions: ui relative for overlay||Grenade arc||Player Modifiers||textbox::selection||Singleplayer RCON||disable car's ground sounds
Bilka
Factorio Staff
Factorio Staff
Posts: 3415
Joined: Sat Aug 13, 2016 9:20 am
Contact:

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

Post 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?
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
User avatar
ownlyme
Filter Inserter
Filter Inserter
Posts: 445
Joined: Thu Dec 21, 2017 8:02 am
Contact:

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

Post 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...
creator of 55 mods
My api requests/suggestions: ui relative for overlay||Grenade arc||Player Modifiers||textbox::selection||Singleplayer RCON||disable car's ground sounds
Rseding91
Factorio Staff
Factorio Staff
Posts: 15852
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post 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.
If you want to get ahold of me I'm almost always on Discord.
User avatar
ownlyme
Filter Inserter
Filter Inserter
Posts: 445
Joined: Thu Dec 21, 2017 8:02 am
Contact:

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

Post 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 ^^
creator of 55 mods
My api requests/suggestions: ui relative for overlay||Grenade arc||Player Modifiers||textbox::selection||Singleplayer RCON||disable car's ground sounds
Post Reply

Return to “Already exists”