Update GUI

Place to get help with not working mods / modding interface.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Update GUI

Post by darkfrei »

Hi all!

How to update GUI properties?

When I added

Code: Select all

		player.gui.left.add{type = "frame", name = "frameTick", direction = "horizontal"}
		player.gui.left.frameTick.add{type ="table", name = "tabTick", colspan = 2}
		local tab = player.gui.left.frameTick.tabTick
		tab.add{type = "label", name = "label_tick", caption = "Tick"}
		tab.add{type = "button", name = "tick_value", caption = game.tick}
Then it works only on GUI-creation-event, but not on every tick.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Update GUI

Post by darkfrei »

Is it the best solution to destroy and make new one on every tick?
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3749
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Update GUI

Post by DaveMcW »

Code: Select all

player.gui.left.frameTick.tabTick.tick_value.caption = game.tick
robertpaulson
Long Handed Inserter
Long Handed Inserter
Posts: 92
Joined: Sun Jun 18, 2017 2:21 pm
Contact:

Re: Update GUI

Post by robertpaulson »

DaveMcW wrote:

Code: Select all

player.gui.left.frameTick.tabTick.tick_value.caption = game.tick
do you still have to put it in a function that runs per tick? or this will automatically refresh? is so how do you make it run every 60ticks? =game.tick%60?
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Update GUI

Post by darkfrei »

robertpaulson wrote:
DaveMcW wrote:

Code: Select all

player.gui.left.frameTick.tabTick.tick_value.caption = game.tick
or this will automatically refresh?
No, it can't be automatically refreshed.
Post Reply

Return to “Modding help”