[kovarex] [0.17.79] LuaGuiElement switch created in on_player_created broken

This subforum contains all the issues which we already resolved.
Post Reply
jan1i3
Inserter
Inserter
Posts: 34
Joined: Sun Dec 09, 2018 1:36 pm
Contact:

[kovarex] [0.17.79] LuaGuiElement switch created in on_player_created broken

Post by jan1i3 »

* The hitbox of a switch - the area where you click it to change the state - seems to not consider the left_label_caption
* The right_label_tooltip seems to be offset somehow so that it simply doesn't appear ever.
* The entire width is determined incorrectly, as you can see here
WidthWrong.png
WidthWrong.png (26.44 KiB) Viewed 586 times
* The switch does not fire any events (tested on_gui_click and on_gui_switch_state_changed)

expected behavior: well,
the hitbox should be where the switch visually is at
the right_label_tooltip should pop up when hovering the right label
the width should consider both labels and the switch itself
the switch should fire events when clicked and state changed


as a comparison, a switch created using commands afterwards works as expected (see expected behavior)

Code: Select all

/c game.player.gui.screen.frame1.add{
  type = "switch",
  name = "sw3",
  left_label_caption = "left",
  left_label_tooltip = "left tooltip",
  right_label_caption = "right, also with more text",
  right_label_tooltip = "right tooltip",
}
ThirdSwitch.png
ThirdSwitch.png (56.94 KiB) Viewed 586 times

reproduce:
load the example mod
create a new world
try pressing the switches
try pressing the button (which does trigger events -> game.print gets run)
try hovering the 2nd switch's lables
add the new switch with the command (see above)
try that switch (also tirggers events)


here is the code for the mod, to make it easier to see what it does:

Code: Select all

script.on_event(defines.events.on_player_created, function(event)
  local player = game.get_player(event.player_index)
  local frame = player.gui.screen.add{
    type = "frame",
    direction = "vertical",
    caption = "test",
    name = "frame1",
  }
  frame.force_auto_center()
  frame.add{
    type = "switch",
    name = "sw_1",
  }
  frame.add{
    type = "switch",
    name = "sw_2",
    switch_state = "left",
    allow_none_state = false,
    left_label_caption = "left",
    right_label_caption = "right with more text",
    left_label_tooltip = "left tooltip",
    right_label_tooltip = "right tooltip",
  }
  frame.add{
    type = "button",
    name = "btn_1",
  }
end)

script.on_event(defines.events.on_gui_click, function(event)
  game.print("clicked " .. event.element.type .. " " .. tostring(event.element.caption or event.element.name))
end)
script.on_event(defines.events.on_gui_switch_state_changed, function(event)
  game.print("switched " .. event.element.type .. " " .. tostring(event.element.caption or event.element.name))
end)
Attachments
SimpleTest_0.0.1.zip
(794 Bytes) Downloaded 17 times
factorio-current.log
(8.81 KiB) Downloaded 18 times
Also known as JanSharp. jan1i3 was/is my old name ;)

jan1i3
Inserter
Inserter
Posts: 34
Joined: Sun Dec 09, 2018 1:36 pm
Contact:

Re: [0.17.79] LuaGuiElement switch created in on_player_created broken

Post by jan1i3 »

Switches loaded from a save have the exact same issues.

reproduce:
load the example mod
create a new world
add the new switch with the command (see above)
try that switch (tirggers events)
save the game
load that game
try that switch again (does not tirgger events)
Also known as JanSharp. jan1i3 was/is my old name ;)

kovarex
Factorio Staff
Factorio Staff
Posts: 7563
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [kovarex] [0.17.79] LuaGuiElement switch created in on_player_created broken

Post by kovarex »

Hello, thanks for the report, it is fixed for the next release.

jan1i3
Inserter
Inserter
Posts: 34
Joined: Sun Dec 09, 2018 1:36 pm
Contact:

Re: [kovarex] [0.17.79] LuaGuiElement switch created in on_player_created broken

Post by jan1i3 »

Thanks :D
Also known as JanSharp. jan1i3 was/is my old name ;)

Post Reply

Return to “Resolved Problems and Bugs”

Who is online

Users browsing this forum: No registered users