Page 1 of 1

[1.0.0] is_shortcut_toggled always returns false for built-in shortcuts

Posted: Mon Nov 16, 2020 10:51 am
by eradicator
What?

It seems impossible to detect the status of 'toggle-alt-mode' or 'toggle-personal-roboport'.

So what?

I'd like to show some extra info to the player when they have both of these enabled, but the api seems to have no access to them. LuaPlayer.is_shortcut_toggled('toggle-alt-mode') also always returns "false". Presumably because they're not "custom" shortcuts, but it's highly misleading to have a function respond with a wrong answer if it's not supposed to work at all for that purpose.

Regarding alt mod there's even an event on_player_toggled_alt_mode. But it doesn't tell me what the new state is either. So either i'm missing something blatantly obvious or the whole event is pointless.

Re: [1.0.0] is_shortcut_toggled always returns false for built-in shortcuts

Posted: Mon Nov 16, 2020 11:56 am
by kovarex
This state is not part of the game state, so you can't read it.

Re: [1.0.0] is_shortcut_toggled always returns false for built-in shortcuts

Posted: Mon Nov 16, 2020 11:59 am
by Bilka
You can access alt mode state with https://lua-api.factorio.com/latest/Con ... ntity_info and the personal roboport state with https://lua-api.factorio.com/latest/Lua ... ing_robots.

Re: [1.0.0] is_shortcut_toggled always returns false for built-in shortcuts

Posted: Wed Nov 18, 2020 8:44 pm
by eradicator
kovarex wrote: Mon Nov 16, 2020 11:56 am This state is not part of the game state, so you can't read it.
In that case why does the function return anything at all? Why does it not raise an error instead of giving a misleading wrong answer.
Bilka wrote: Mon Nov 16, 2020 11:59 am You can access alt mode state with https://lua-api.factorio.com/latest/Con ... ntity_info and the personal roboport state with https://lua-api.factorio.com/latest/Lua ... ing_robots.
Thank you again very much for going the extra step and posting links!
Very well hidden it is there in GameViewSettings, can't even find it with a full-text search on the full Classes overview page. I would ask for an addition to the documenation but i'm not sure where to even add that. Though i would appreciate a more explicit comment on is_shortcut_toggled, explaining that the function lies into your face when you ask it about built-in shortcuts (unless @kovarex changes his mind).