• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Loop Integer A With Custom UI

Status
Not open for further replies.
Level 7
Joined
Nov 6, 2019
Messages
186
Is is possible to use Loop Integer with Custom UI Text

  • SetStats
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 7, do (Actions)
        • Loop - Actions
          • -------- Health --------
          • Set VariableSet UICurrentHP[(Integer A)] = (Integer((Life of SetHeroGS[(Integer A)])))
          • Set VariableSet UIMaxHP[(Integer A)] = (Integer((Max life of SetHeroGS[(Integer A)])))
          • Set VariableSet CustomString = (|cffff0000 + ((String(UICurrentHP[(Integer A)])) + (|r/|cffff0000 + ((String(UIMaxHP[(Integer A)])) + |r))))
          • Custom script: call BlzFrameSetText(PlayerHPC[(Integer A)], udg_CustomString)
          • -------- Mana --------
          • Set VariableSet UICurrentMana[(Integer A)] = (Integer((Mana of SetHeroGS[(Integer A)])))
          • Set VariableSet UIMaxMana[(Integer A)] = (Integer((Max mana of SetHeroGS[(Integer A)])))
          • Set VariableSet CustomString = (|cff0000ff + ((String((Mana of SetHeroGS[(Integer A)]))) + (|r/|cff0000ff + ((String((Max mana of SetHeroGS[(Integer A)]))) + |r))))
          • Custom script: call BlzFrameSetText(PlayerMPC[(Integer A)], udg_CustomString)
 
Level 7
Joined
Nov 6, 2019
Messages
186
OK i set it like so, i believe thats what you said to do.

But it still doesnt work.

EDIT: so this is my full setup trying to figure out.

This is in GUI.

  • StatsUpGUI
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 7, do (Actions)
        • Loop - Actions
          • -------- FriendlyHP --------
          • Set VariableSet UICurrentHP[(Integer A)] = (Integer((Life of FriendlySet[(Integer A)])))
          • Set VariableSet UIMaxHP[(Integer A)] = (Integer((Max life of FriendlySet[(Integer A)])))
          • Set VariableSet CustomString = (|cffff0000 + ((String(UICurrentHP[(Integer A)])) + (|r/|cffff0000 + ((String(UIMaxHP[(Integer A)])) + |r))))
          • Custom script: call BlzFrameSetText(PlayerHPC[GetForLoopIndexA()], udg_CustomString)
          • -------- EnemyHP --------
          • Set VariableSet UICurrentHP[(Integer A)] = (Integer((Life of EnemySet[(Integer A)])))
          • Set VariableSet UIMaxHP[(Integer A)] = (Integer((Max life of EnemySet[(Integer A)])))
          • Set VariableSet CustomString = (|cff800080 + ((String(UICurrentHP[(Integer A)])) + (|r/|cff800080 + ((String(UIMaxHP[(Integer A)])) + |r))))
          • Custom script: call BlzFrameSetText(TargetHPC[GetForLoopIndexA()], udg_CustomString)
          • -------- FriendlyMP --------
          • Set VariableSet UICurrentMana[(Integer A)] = (Integer((Mana of FriendlySet[(Integer A)])))
          • Set VariableSet UIMaxMana[(Integer A)] = (Integer((Max mana of FriendlySet[(Integer A)])))
          • Set VariableSet CustomString = (|cff0000ff + ((String(UICurrentMana[(Integer A)])) + (|r/|cff0000ff + ((String(UIMaxMana[(Integer A)])) + |r))))
          • Custom script: call BlzFrameSetText(PlayerMPC[GetForLoopIndexA()], udg_CustomString)
          • -------- EnemyMP --------
          • Set VariableSet UICurrentMana[(Integer A)] = (Integer((Mana of EnemySet[(Integer A)])))
          • Set VariableSet UIMaxMana[(Integer A)] = (Integer((Max mana of EnemySet[(Integer A)])))
          • Set VariableSet CustomString = (|cff008080 + ((String(UICurrentMana[(Integer A)])) + (|r/|cff008080 + ((String(UIMaxMana[(Integer A)])) + |r))))
          • Custom script: call BlzFrameSetText(PlayerMPC[GetForLoopIndexA()], udg_CustomString)
          • -------- Gold --------
          • Set VariableSet UIGold[(Integer A)] = ((Player((Integer A))) Current gold)
          • Set VariableSet CustomString = (|cff808000 + ((String(UIGold[(Integer((Life of (Triggering unit))))])) + |r))
          • Custom script: call BlzFrameSetText(GoldInfoC[GetForLoopIndexA()], udg_CustomString)
          • -------- Lumber --------
          • Set VariableSet UIWood[(Integer A)] = ((Player((Integer A))) Current lumber)
          • Set VariableSet CustomString = (|cff008000 + ((String(UIWood[(Integer A)])) + |r))
          • Custom script: call BlzFrameSetText(LumberInfoCopyC[GetForLoopIndexA()], udg_CustomString)
          • -------- Power --------
          • Set VariableSet UICurrentPower[(Integer A)] = ((Player((Integer A))) Food used)
          • Set VariableSet UIMaxPower[(Integer A)] = ((Player((Integer A))) Food max)
          • Set VariableSet CustomString = (|cff008080 + ((String(UICurrentPower[(Integer A)])) + (|r.|cff008080 + ((String(UIMaxPower[(Integer A)])) + |r))))
          • Custom script: call BlzFrameSetText(PowerInfoC[GetForLoopIndexA()], udg_CustomString)
This is it in Custom Text if this helps figure it out.

JASS:
function Trig_StatsUpJass_Actions takes nothing returns nothing
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 7
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        // FriendlyHP
        set udg_UICurrentHP[GetForLoopIndexA()] = R2I(GetUnitStateSwap(UNIT_STATE_LIFE, udg_FriendlySet[GetForLoopIndexA()]))
        set udg_UIMaxHP[GetForLoopIndexA()] = R2I(GetUnitStateSwap(UNIT_STATE_MAX_LIFE, udg_FriendlySet[GetForLoopIndexA()]))
        set udg_CustomString = ( "|cffff0000" + ( I2S(udg_UICurrentHP[GetForLoopIndexA()]) + ( "|r/|cffff0000" + ( I2S(udg_UIMaxHP[GetForLoopIndexA()]) + "|r" ) ) ) )
        call BlzFrameSetText(PlayerHPC[GetForLoopIndexA()], udg_CustomString)
        // EnemyHP
        set udg_UICurrentHP[GetForLoopIndexA()] = R2I(GetUnitStateSwap(UNIT_STATE_LIFE, udg_EnemySet[GetForLoopIndexA()]))
        set udg_UIMaxHP[GetForLoopIndexA()] = R2I(GetUnitStateSwap(UNIT_STATE_MAX_LIFE, udg_EnemySet[GetForLoopIndexA()]))
        set udg_CustomString = ( "|cff800080" + ( I2S(udg_UICurrentHP[GetForLoopIndexA()]) + ( "|r/|cff800080" + ( I2S(udg_UIMaxHP[GetForLoopIndexA()]) + "|r" ) ) ) )
        call BlzFrameSetText(TargetHPC[GetForLoopIndexA()], udg_CustomString)
        // FriendlyMP
        set udg_UICurrentMana[GetForLoopIndexA()] = R2I(GetUnitStateSwap(UNIT_STATE_MANA, udg_FriendlySet[GetForLoopIndexA()]))
        set udg_UIMaxMana[GetForLoopIndexA()] = R2I(GetUnitStateSwap(UNIT_STATE_MAX_MANA, udg_FriendlySet[GetForLoopIndexA()]))
        set udg_CustomString = ( "|cff0000ff" + ( I2S(udg_UICurrentMana[GetForLoopIndexA()]) + ( "|r/|cff0000ff" + ( I2S(udg_UIMaxMana[GetForLoopIndexA()]) + "|r" ) ) ) )
        call BlzFrameSetText(PlayerMPC[GetForLoopIndexA()], udg_CustomString)
        // EnemyMP
        set udg_UICurrentMana[GetForLoopIndexA()] = R2I(GetUnitStateSwap(UNIT_STATE_MANA, udg_EnemySet[GetForLoopIndexA()]))
        set udg_UIMaxMana[GetForLoopIndexA()] = R2I(GetUnitStateSwap(UNIT_STATE_MAX_MANA, udg_EnemySet[GetForLoopIndexA()]))
        set udg_CustomString = ( "|cff008080" + ( I2S(udg_UICurrentMana[GetForLoopIndexA()]) + ( "|r/|cff008080" + ( I2S(udg_UIMaxMana[GetForLoopIndexA()]) + "|r" ) ) ) )
        call BlzFrameSetText(PlayerMPC[GetForLoopIndexA()], udg_CustomString)
        // Gold
        set udg_UIGold[GetForLoopIndexA()] = GetPlayerState(ConvertedPlayer(GetForLoopIndexA()), PLAYER_STATE_RESOURCE_GOLD)
        set udg_CustomString = ( "|cff808000" + ( I2S(udg_UIGold[R2I(GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit()))]) + "|r" ) )
        call BlzFrameSetText(GoldInfoC[GetForLoopIndexA()], udg_CustomString)
        // Lumber
        set udg_UIWood[GetForLoopIndexA()] = GetPlayerState(ConvertedPlayer(GetForLoopIndexA()), PLAYER_STATE_RESOURCE_LUMBER)
        set udg_CustomString = ( "|cff008000" + ( I2S(udg_UIWood[GetForLoopIndexA()]) + "|r" ) )
        call BlzFrameSetText(LumberInfoCopyC[GetForLoopIndexA()], udg_CustomString)
        // Power
        set udg_UICurrentPower[GetForLoopIndexA()] = GetPlayerState(ConvertedPlayer(GetForLoopIndexA()), PLAYER_STATE_RESOURCE_FOOD_USED)
        set udg_UIMaxPower[GetForLoopIndexA()] = GetPlayerState(ConvertedPlayer(GetForLoopIndexA()), PLAYER_STATE_FOOD_CAP_CEILING)
        set udg_CustomString = ( "|cff008080" + ( I2S(udg_UICurrentPower[GetForLoopIndexA()]) + ( "|r.|cff008080" + ( I2S(udg_UIMaxPower[GetForLoopIndexA()]) + "|r" ) ) ) )
        call BlzFrameSetText(PowerInfoC[GetForLoopIndexA()], udg_CustomString)
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction

//===========================================================================
function InitTrig_StatsUpJass takes nothing returns nothing
    set gg_trg_StatsUpJass = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_StatsUpJass, 1.00 )
    call TriggerAddAction( gg_trg_StatsUpJass, function Trig_StatsUpJass_Actions )
endfunction

EDIT: Only thing am missing from completing my set up correctly :)
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,013
You need to be more specific. What "doesn't work" about it? All variables made in the GUI variable editor have a hidden udg_ prefix you need to add when referring to them with JASS (custom scripts). It looks like you're not doing that for PlayerMPC[] and PlayerHPC[].
 
Level 7
Joined
Nov 6, 2019
Messages
186
You need to be more specific. What "doesn't work" about it? All variables made in the GUI variable editor have a hidden udg_ prefix you need to add when referring to them with JASS (custom scripts). It looks like you're not doing that for PlayerMPC[] and PlayerHPC[].
The entire update doesn’t work

PlayerHPC[] and rest in custom script, is a Text Box in the Custom Ui, using RUID it isn’t a variable, it’s the text box name

As in RUID there PlayerHPC[0] to [6] as there is 7 different custom UI text boxes to Update per Text Box on the Custom UI

4A8DF93F-9124-459F-A7AC-1F91D5F72D25.png


So as you can See, The Custom Script is to update the Custom UI text box

Red and Blue left side,
Dark Magenta and Dark Teal right side,
Gold, Lumber and Power Texts in middle

As to get working with multiple players, [7] each one of them text boxes has 7 Circle Arrays

So was hoping Loop Integer works with Custom Text Box Updating, so I don’t have to do the update once each per Player, so 59 thinks
 
Level 39
Joined
Feb 27, 2007
Messages
5,013
PlayerHPC[0..6] is the range you want to use, but Index A is looping from 1 to 7. So instead you need to do PlayerHPC[bj_forLoopAIndex - 1], and similarly for all the other BlzFrameSet calls.

Or you could change the loop bounds from 1-7 to 0-6 and leave it as it is now.
 
Level 7
Joined
Nov 6, 2019
Messages
186
PlayerHPC[0..6] is the range you want to use, but Index A is looping from 1 to 7. So instead you need to do PlayerHPC[bj_forLoopAIndex - 1], and similarly for all the other BlzFrameSet calls.

Or you could change the loop bounds from 1-7 to 0-6 and leave it as it is now.
I did change loop bounds to 0 and 6, it set every text box to 0 so that didn’t work

Also issue with that, the Text Boxes go from 00 to 06

And the set internet go from 1 to 7 I believe.

As if I use SetHeroGS[1] or SetHeroGS[Player Red] it links to the same thing so isn’t set player I’d go from 1 to 7

I will try 0 to 6 again, and if that don’t work try -1
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,013
My guess is that was because the other array variables EnemySet[] and FriendlySet[] as well as the way you are getting player lumber/gold/power don't account for players in the 0..6 range instead of 1..7. Instead just try changing the index:
You need to do PlayerHPC[bj_forLoopAIndex - 1], and similarly for all the other BlzFrameSet calls.
 
Level 7
Joined
Nov 6, 2019
Messages
186
My guess is that was because the other array variables EnemySet[] and FriendlySet[] as well as the way you are getting player lumber/gold/power don't account for players in the 0..6 range instead of 1..7. Instead just try changing the index:
TY for help, the - 1 worked perfectly, i just not to sort out my other issues, if you know anything about them.

1. My inv in a test map worked perfectly, but in the official map, the inventory slots dont work, dunno why.
2. for some reason if i have CustomUI enabled, the players hero makes no UnitSounds
3. if i decided to add map, to figure out how to get it to show and move to specific location.

but main things now work.
 
Status
Not open for further replies.
Top