Trigger UI redrawing?!

Place to get help with not working mods / modding interface.
Post Reply
JasonMiles
Burner Inserter
Burner Inserter
Posts: 15
Joined: Thu Sep 21, 2017 9:28 am
Contact:

Trigger UI redrawing?!

Post by JasonMiles »

Hi,
I have a rather long running / command that raises some click events (script.raise_event).
These events cause some UI elements to be drawn, created, closed, ...

As everything happens in one command/function it looks like there is no UI update until the very end.

I would like to see the steps in between though (simply to make it visually followable).

Question: Is there a way to trigger a redraw of the UI via script?
I couldn't find an event to raise or a way to let the script run "asynchronous".

Or is this actually the case already and I'm just to slow/the runtime is not long enough yet?

Thanks

P.S. my search foo returned nothing the like, if this question has been answered already then I'm sorry :)

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Trigger UI redrawing?!

Post by DaveMcW »

I think the UI only draws once per tick. So you will have to break up your command into multiple function calls, probably using script.on_nth_tick() to coordinate them.

JasonMiles
Burner Inserter
Burner Inserter
Posts: 15
Joined: Thu Sep 21, 2017 9:28 am
Contact:

Re: Trigger UI redrawing?!

Post by JasonMiles »

Okay, thanks.

I was afraid this was the answer :)
Off to creating a scheduler and some locking logic then :D

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

Re: Trigger UI redrawing?!

Post by Klonan »

I believe, if you add a `player.show_message_dialog()` function between each addition of the GUI, you will be able to see it being built 1 piece at a time

JasonMiles
Burner Inserter
Burner Inserter
Posts: 15
Joined: Thu Sep 21, 2017 9:28 am
Contact:

Re: Trigger UI redrawing?!

Post by JasonMiles »

Awesome, thanks :)
I'll try that out.

JasonMiles
Burner Inserter
Burner Inserter
Posts: 15
Joined: Thu Sep 21, 2017 9:28 am
Contact:

Re: Trigger UI redrawing?!

Post by JasonMiles »

Follow up question.
If I use the dialog it actually blocks UI rendering. Is there a way to programmatically close it again?
Because otherwise the user has to manually proceed for every step.
Or am I missing something?

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

Re: Trigger UI redrawing?!

Post by Klonan »

JasonMiles wrote:
Mon Nov 19, 2018 7:12 pm
Follow up question.
If I use the dialog it actually blocks UI rendering. Is there a way to programmatically close it again?
Because otherwise the user has to manually proceed for every step.
Or am I missing something?
I thought you would use it for visual debugging only

What is the exact problem you are having with the GUI?

Post Reply

Return to “Modding help”