gui - radio button and sprite button

Place to get help with not working mods / modding interface.
Post Reply
sore68
Fast Inserter
Fast Inserter
Posts: 123
Joined: Mon May 02, 2016 8:39 am
Contact:

gui - radio button and sprite button

Post by sore68 »

Hi~
I make gui - radio buttons
radio.png
radio.png (62.29 KiB) Viewed 2838 times
and code

Code: Select all

frame = player.gui.left.add{type="frame", name="at_request_button"}
frame_table = frame.add{type="table", name="at_request_button", colspan = 1}
frame_table.add{type = "radiobutton", name = "at_request_all_radio", state = false, caption = "Change the request slot of the selected all turrets at the bottom."}
frame_table.add{type = "radiobutton", name = "at_request_near_radio", state = false, caption = "Change the request slot of the selected nearby turrets at the bottom."}
...
My problem is select radio button. I want select only one, not more...
Can I bind radio buttons? of Is it possible only through on_gui_click or on_gui_checked_state_changed?



----------
Oh delete table and add direction in frame, It does the action I want. :D
hmm.. Not change;;; just action true/false code... :(
Last edited by sore68 on Fri Dec 02, 2016 3:09 pm, edited 1 time in total.

User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: gui - radio button

Post by prg »

From the documentation:
"radiobutton": Identical to checkbox except circular.
Seems like you need to uncheck them manually.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5152
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: gui - radio button

Post by Klonan »

prg wrote:From the documentation:
"radiobutton": Identical to checkbox except circular.
Seems like you need to uncheck them manually.
Yep they will need to be unchecked manuall... which is each:

LuaGuiElement.state = false

sore68
Fast Inserter
Fast Inserter
Posts: 123
Joined: Mon May 02, 2016 8:39 am
Contact:

Re: gui - radio button

Post by sore68 »

prg wrote:...
Klonan wrote:...

Thanks for letting me know! :D

User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2636
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: gui - radio button

Post by steinio »

You could make a suggestion for adding a group tag for radiobuttons. Every item with the same group name can only have one of the group selected and disables all other items of the group automatically.

Greetings steinio
Image

Transport Belt Repair Man

View unread Posts

sore68
Fast Inserter
Fast Inserter
Posts: 123
Joined: Mon May 02, 2016 8:39 am
Contact:

Re: gui - radio button

Post by sore68 »

steinio wrote:You could make a suggestion for adding a group tag for radiobuttons. Every item with the same group name can only have one of the group selected and disables all other items of the group automatically.

Greetings steinio

Oh! That's what I was looking for!
Can you explain a bit more about [adding a group tag]???
Last edited by sore68 on Fri Dec 02, 2016 3:27 pm, edited 2 times in total.

sore68
Fast Inserter
Fast Inserter
Posts: 123
Joined: Mon May 02, 2016 8:39 am
Contact:

Re: gui - radio button

Post by sore68 »

A new problem has come to me.
sb.png
sb.png (139.41 KiB) Viewed 2797 times

Code: Select all

frame.add{type = "sprite-button", name = string.sub(frame.name, 1, 15)..ammo_name[1], sprite = "item/"..ammo_name[1]}
s.png
s.png (331.66 KiB) Viewed 2797 times

Code: Select all

frame.add{type = "sprite", name = string.sub(frame.name, 1, 15)..ammo_name[1], sprite = "item/"..ammo_name[1]}

Above is when using the sprite button, and below is when using the sprite.
Does the sprite of the sprite button have a different meaning??

User avatar
Earendel
Factorio Staff
Factorio Staff
Posts: 711
Joined: Sun Nov 23, 2014 11:57 am
Contact:

Re: gui - radio button and sprite button

Post by Earendel »

The sprite in a sprite button does not cause the button to expand. Try adding style="my-button-style" to your button and define the style:

Code: Select all

data.raw["gui-style"]["default"]["my-button-style"] =
{
	type = "button_style",
	parent = "button_style",
	minimal_width = 32,
	minimal_height = 32,
	top_padding = 0,
	right_padding = 0,
	bottom_padding = 0,
	left_padding = 0,
}

sore68
Fast Inserter
Fast Inserter
Posts: 123
Joined: Mon May 02, 2016 8:39 am
Contact:

Re: gui - radio button and sprite button

Post by sore68 »

Earendel wrote:The sprite in a sprite button does not cause the button to expand. Try adding style="my-button-style" to your button and define the style:

Code: Select all

data.raw["gui-style"]["default"]["my-button-style"] =
{
	type = "button_style",
	parent = "button_style",
	minimal_width = 32,
	minimal_height = 32,
	top_padding = 0,
	right_padding = 0,
	bottom_padding = 0,
	left_padding = 0,
}
OH!! Thanks for providing me with a guide. :D :D

Post Reply

Return to “Modding help”