I added some dropdown lists to one of my screens. However, I can’t figure out how to retrieve the values. how do I figure out which list item is selected?
Never mind. The function
UI_GetDropdownListBoxSelectedCustomDataString does what I need.
I can’t figure out how to make a listbox item “selected” by default other than item #1. I can use
UI_SelectDropDownListboxItemIndex to set it after the screen is loaded, but can’t figure out how to do so in the screen’s source code.
Can’t you use the UI_SelectDropDownListboxItemIndex function in the onShow “parameter” of the screen ?
I didn’t know about that parameter, thanks!
there are an onHide and an onUpdate too if needed.
Be careful with the code in onUpdate, because it’s easy to create an infinite loop with it. You will need to have a variable in its code which you will change after the first run, to be sure that it’s not running endlessly.
In several scripts I am passing data to the GUI by writing to a file and then reloading the GUI screen. Which event is the correct one in this case?
Also, I noticed the
onUpdate event firing many many times. I don’t quite understand how to prevent this. For instance I have:
onUpdate = "print('updated')",
But this fills the log completely after a while of doing nothing as far as I can tell. Could you give an example?
onShow seems to do what I need. Still curious to know more about
onShow activates when the screen loads(is shown) or reloads, so yes, it was the one you needed.
onHide activates when the screen closes.
onUpdate runs continuously (it repeats) while the screen is visible (thus it’s very easy to be trapped in an endless hanging loop if you use a while or for without any correct control)
You can control what is happening by using control variables, for example :
onUpdate = [[
if control_var == nil then
control_var = 1
if control_var <= 10 then
control_var = control_var + 1
which should print “updated” only during the 10 first code runs.
The control can be done with anything really, a num, a boolean, or even a variable written in a file which you can read by using a dofilepath.
I noticed that the
onUpdate event fires even when the game is paused. That could come in handy.
Are there any other events in the same family as
onShow? I am in particular looking for something like an
That was not your initial question
(all found by editing the HomeworldRM.exe)