It is possible to somewhat achieve this by using code such as:
Code: Select all
global.characters = {}
local player = game.players[event.player_index]
global.characters[event.player_index] = player.character
player.set_controller { type = defines.controllers.editor }
--- later, to revert
local player = game.players[event.player_index]
player.set_controller { type = defines.controllers.character, character = global.characters[event.player_index] }
Furthermore, if the player accidentally runs /editor after he/she has used set_controller to activate Editor, they will be put back into the world without re-attaching to their orphaned character. They must then manually re-attach to that character; the mod could not easily help them do this.
A direct analogue for /editor would thus be helpful. Perhaps LuaPlayer::toggle_map_editor() or something similar?