Ghost Mode

by dudditz

Toggle "ghost mode", making all items you place a ghost item regardless of what's in your inventory. Bascially, it holds down Shift for you. With ghost mode enabled, using the pipette tool (Q) to pick an item will also always pick a ghost item. Ghost mode can be toggled via the default key binding Shift + G or the shortcut bar."

Utilities
9 months ago
1.1 - 2.0
1.01K

b Ghost mode shortcut button toggles no matter which button is clicked

1 year, 8 months ago
(updated 1 year, 8 months ago)

I have the Ghost Mode mod installed, with the shortcut button shown on my toolbar. I have several other mods installed as well, some of which also have a shortcut button. There seems to be a problem where the Ghost Mode button toggles on and off, no matter which shortcut button is pressed. It seems that your code is intercepting button-press messages which are intended for other mods.
I have experimented a little, and I think I have found a solution. In your 'control.lua' file, find this section of code:

script.on_event(defines.events.on_lua_shortcut,
function(event)
local player = game.get_player(event.player_index)
toggle_ghost_mode(player)
end
)

and amend it like this:

script.on_event(defines.events.on_lua_shortcut,
function(event)
if event.prototype_name == "ghost_mode_toggle_shortcut" then
local player = game.get_player(event.player_index)
toggle_ghost_mode(player)
end
end
)

This should ensure that your code only responds to button presses which were specifically intended for the Ghost Mode mod.
(Sorry about the lack of indentation - sadly, it seems that these messages don't take any notice of tabs or leading spaces.)

1 year, 8 months ago

Nice catch, thanks! Fixed.