Page 1 of 1

[Twinsen][0.17.3] player.get_active_quick_bar_page is strange

Posted: Fri Mar 01, 2019 5:12 pm
by MightyMooquack
At a minimum, this function seems under-documented, but it may be that some of its behavior constitutes a bug.

The function is given the index of a "screen page," and the documentation doesn't give a clear explanation of what this means. It appears to correspond to the (1-indexed) quick bar row that is visible on the screen. I would think, therefore, that the only meaningful values would be 1 or 2, but the function will happily accept larger values; the meaning of such values is unclear.

The function returns the 0-indexed quick bar page number, so that page 1 is 0, page 2 is 1, and so on up to page 0 being 9. This is confusing and seems inconsistent with the usual way in which Lua works; however, it is convenient when used in combination with player.get_quick_bar_slot, because you can compute an index with page * 10 + slot. Is this behavior intentional? Should the documentation spell this out explicitly?

Along the same lines, the documentation does not explain that player.get_quick_bar_slot and player.set_quick_bar_slot operate on indexes in the range 1 through 100. This is simple enough to determine through basic testing, but it seems like the sort of thing that should be spelled out explicitly.

Re: [0.17.3] player.get_active_quick_bar_page is strange

Posted: Sun Mar 10, 2019 4:59 am
by Risce
I came here to post a bug about this as well.

It seems that `get_active_quick_bar_page` returns a 0-index based page number (where 0 -> the bar that says "1") but that `set_active_quick_bar_page` doesn't accept 0 as a valid argument!

Also, multiple `set_active_quick_bar_page` calls in a mod function seems to be broken. The bars don't actually update.

Re: [0.17.3] player.get_active_quick_bar_page is strange

Posted: Sun Mar 10, 2019 5:35 am
by l1ng0
Personally I couldn't get any obvious reaction to the set... calls, when using them in the console. No updates at all.

Also, as noted, set requires a 1-based argument, but get returns 0-based. (just confirming same behaviour)

I had a mod I was working on for .16 that I'd like to now finish for .17, that would rely on this working, so it will be great when this works!

Dev team is doing an awesome job!

Re: [0.17.3] player.get_active_quick_bar_page is strange

Posted: Sun Mar 10, 2019 2:32 pm
by Sunnova
I got the display update working by doing

player.game_view_settings.show_quickbar = false

making my changes, then doing

player.game_view_settings.show_quickbar = true

Working just fine doing the above, using it my quick bar swap mod

Re: [0.17.3] player.get_active_quick_bar_page is strange

Posted: Sun Mar 10, 2019 2:39 pm
by Risce
I tried that and it was inconsistent.

Re: [0.17.3] player.get_active_quick_bar_page is strange

Posted: Sun Mar 10, 2019 2:58 pm
by Sunnova
Strange indeed, I've not had any problems at all.

Risce wrote: Sun Mar 10, 2019 2:39 pm I tried that and it was inconsistent.

Re: [0.17.3] player.get_active_quick_bar_page is strange

Posted: Sun Mar 10, 2019 10:22 pm
by Risce
Here's my mod. I have been testing with increment and decrement shortcuts. Only the first bar ever changes.

https://github.com/DerrickRice/factorio ... -quickbars

Re: [Twinsen][0.17.3] player.get_active_quick_bar_page is strange

Posted: Tue Mar 12, 2019 10:06 am
by Twinsen
I changed get_active_quick_bar_page to return 1-based index so it should be consistent with the rest.
Also updated the documentation a bit.
Also fixed the quickbar not updating after set_active_quick_bar_page

Index can go beyond the visible number of bars on the screen(up to 10) to account for the interface config setting change. Unfortunately there's no way to easily find out the number of active quickbars on the screen through lua.

Changes are in Version: 0.17.12. Marking this as resolved.

Re: [Twinsen][0.17.3] player.get_active_quick_bar_page is strange

Posted: Tue Mar 12, 2019 7:12 pm
by Risce
<3

Re: [Twinsen][0.17.3] player.get_active_quick_bar_page is strange

Posted: Thu Mar 14, 2019 9:13 pm
by Risce
@Twinsen, this is not resolved. Quickbars 2, 3, and 4 do not update on screen.

https://imgur.com/qAbB8Yi

Re: [Twinsen][0.17.3] player.get_active_quick_bar_page is strange

Posted: Fri Mar 15, 2019 10:52 am
by Twinsen
Risce wrote: Thu Mar 14, 2019 9:13 pm @Twinsen, this is not resolved. Quickbars 2, 3, and 4 do not update on screen.

https://imgur.com/qAbB8Yi
Oops, fixed again properly in Version: 0.17.13