Map Editor: ability to trigger /editor via Lua

Post Reply
User avatar
TheBloke
Fast Inserter
Fast Inserter
Posts: 123
Joined: Mon Dec 03, 2018 2:48 am
Contact:

Map Editor: ability to trigger /editor via Lua

Post by TheBloke »

I use Map Editor extensively, and would love to have the ability to enter in and out even more quickly. A vanilla Map Editor hotkey would be help a lot, and I hope that might be added at some point, however there would regardless also be benefit from having this be mod controllable. For example, the ability to create a Shortcut Bar button for it.

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] }
However, this does not precisely replicate /editor. When code such as the above is written, the player's character remains in the world, whereas running /editor removes/hides it.

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?

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Map Editor: ability to trigger /editor via Lua

Post by Rseding91 »

Ok.
If you want to get ahold of me I'm almost always on Discord.

User avatar
TheBloke
Fast Inserter
Fast Inserter
Posts: 123
Joined: Mon Dec 03, 2018 2:48 am
Contact:

Re: Map Editor: ability to trigger /editor via Lua

Post by TheBloke »

Thanks very much!

Post Reply

Return to “Implemented mod requests”