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

Bugs that are actually features.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

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

Post 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.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
kovarex
Factorio Staff
Factorio Staff
Posts: 8298
Joined: Wed Feb 06, 2013 12:00 am
Contact:

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

Post by kovarex »

This state is not part of the game state, so you can't read it.
Bilka
Factorio Staff
Factorio Staff
Posts: 3604
Joined: Sat Aug 13, 2016 9:20 am
Contact:

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

Post 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.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

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

Post 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).
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Post Reply

Return to “Not a bug”