[0.18.x] Editor mode inconsistencies causing issues.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

[0.18.x] Editor mode inconsistencies causing issues.

Post by bobingabout »

The Scenario:
If a player uses the console to type /editor, or a mod uses the script LuaPlayer.toggle_map_editor(), then the current character entity disappears and is unreferenceable via LuaPlayer.character.
In contrast, if a mod sets LuaPlayer.set_controller{type = defines.controllers.editor}, the character entity is disconnected from the player, left standing there.

Assume /editor was used to enter editor mode, and you want to exit with a script... Since the character entity is in this unreferencable limbo state, if you set the controller to another character, the one in limbo is gone forever. You would need to use the LuaPlayer.toggle_map_editor() command first to check if one is created, then switch to the other character you intended.
Assume a script was used to enter editor mode using the set_controller command, and you exit with /editor command, you're now a god controller.

The second situation can be fixed, as on_player_toggled_map_editor event is triggered, so assuming the script that called LuaPlayer.set_controller{type = defines.controllers.editor} keeps track of the entity, it can be connected again.
The first situation is the problem case... although it is possible to use LuaPlayer.toggle_map_editor() to exit and restore the character entity, there's no way to tell if there's a limbo character entity that needs to be restored first. The only way to do it safely would be to use LuaPlayer.toggle_map_editor() and check to see if you have a character or not, then set one, doing whatever needs to be done to the restored limbo character.

The Suggestion:
Add something on LuaPlayer (I don't care what exactly) to be able to check if there is a character in limbo when you're in editor mode.

I don't have a problem that that two methods have different results, my issue is there's no way to tell which was used, and if there's a character entity in limbo.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14890
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.18.x] Editor mode inconsistencies causing issues.

Post by Rseding91 »

Ok, I added LuaPlayer::stashed_controller_type read for the next release.
If you want to get ahold of me I'm almost always on Discord.
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: [0.18.x] Editor mode inconsistencies causing issues.

Post by bobingabout »

Thank you. This should be useful.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
Post Reply

Return to “Implemented mod requests”