sman1975
Emperor
Hello,
I'm working on a function that cycles through all a player's units. For certain type of units, e.g. Mech Infantry, the function should pop up a window asking for an "Action A" or an "Action B" button to be pressed. Based on which button is pressed, a different function would be called.
So far, the popup looks good, so I think it's put together properly.
The issue is, when I cycle through my units, using:
The button callbacks look like this:
The code dutifully cycles through all my units, and when it encounters a Mech Infantry unit, it shows the popup for the first unit. But then the for loop continues through all the units and ends.
So, I press either ButtonA or ButtonB, and the correct function is called for that first unit. Once this ends, game play continues as normal, and no additional popups are called, even though there are several Mech Infantry units in play.
So, I guess my question is - how do I force the for loop to wait for the button press before iterating to the next unit?
I'm working on a function that cycles through all a player's units. For certain type of units, e.g. Mech Infantry, the function should pop up a window asking for an "Action A" or an "Action B" button to be pressed. Based on which button is pressed, a different function would be called.
So far, the popup looks good, so I think it's put together properly.
The issue is, when I cycle through my units, using:
Code:
for pUnit in pPlayer:Units() do
if pUnit:GetUnitType() == GameInfoTypes.UNIT_MECHANIZED_INFANTRY then
ContextPtr:SetHide(false)
end
end
The button callbacks look like this:
Code:
function OnRehire()
-- Processing Rehire request code
ContextPtr:SetHide(true)
end
Controls.Rehire:RegisterCallback(Mouse.eLClick, OnRehire)
function OnDisband()
-- Processing Disband request code
ContextPtr:SetHide(true)
end
Controls.Disband:RegisterCallback(Mouse.eLClick, OnDisband)
The code dutifully cycles through all my units, and when it encounters a Mech Infantry unit, it shows the popup for the first unit. But then the for loop continues through all the units and ends.
So, I press either ButtonA or ButtonB, and the correct function is called for that first unit. Once this ends, game play continues as normal, and no additional popups are called, even though there are several Mech Infantry units in play.
So, I guess my question is - how do I force the for loop to wait for the button press before iterating to the next unit?