• 🏆 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!

[JASS] How to use the Jass library via GUI?

Status
Not open for further replies.
Level 7
Joined
Jun 1, 2009
Messages
104
I want to implement this library in my GUI map.

But I have no idea:
  • how to make it run via GUI trigger?
  • how to convert a state of private boolean array Reforged into GUI Global boolean array? Or do I just need to declare the IsReforged boolean array in my map?
  • where the hell one could find a TimerUtils lib? It seems to be erased everywhere by time... It says it's optional, but I'm not sure of side effects if it's missing...

I've tried to create a trigger named DetectReforged with this library and call it by
  • Custom script: call DetectReforged.Init()
but it fails:

DetectReforged is not of a type that allows . syntax

Will appreciate any help!

Edit: I've found some debug messages in the script. Turned them on. It seems this library runs automatically after map initialization...
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,511
See this code here, this is where the Reforged boolean array is set for each player:
vJASS:
    private function AssignReforgedFlag takes nothing returns nothing
        set Reforged[GetPlayerId(GetTriggerPlayer())] = GetSyncedBoolean()
    endfunction
But we want to use a GUI variable, so create your own Boolean array in the Variable Editor.
Then simply set your GUI variable in this function instead:
vJASS:
    private function AssignReforgedFlag takes nothing returns nothing
        set udg_ReforgedFlag[GetPlayerId(GetTriggerPlayer())] = GetSyncedBoolean()
    endfunction
udg_ is the prefix that tells Jass code that you're referencing a GUI variable instead of a variable created in Jass.
 
Level 18
Joined
Oct 17, 2012
Messages
820
Instead of that chunky library + its requirements, you could actually use this sweet function.
JASS:
function IsReforged takes nothing returns boolean
    return GetLocalizedString("REFORGED") != "REFORGED"
endfunction

At Map Initialization, set a boolean variable to the return value of the above function via custom script.

  • Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: set udg_IsReforged = IsReforged()
  • Check
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • IsReforged Equal to True
        • Then - Actions
          • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
        • Else - Actions
 
Level 7
Joined
Jun 1, 2009
Messages
104
udg_ is the prefix that tells Jass code that you're referencing a GUI variable
Thank you! I've remembered that prefix, but I thought it was for GUI only. Now it works as intended.

Instead of that chunky library + its requirements, you could actually use this sweet function.
That would be an ideal way! But will it work in multiplayer?
My goal is to fix the unit's size differences in classic and reforged modes. It can ruin gameplay when some units take half of the screen space if one plays reforged. My idea was:

  • For each (Integer FixScale[0]) from 1 to Max_Player_Number, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • IsReforged[FixScale[0]] Equal to Да
          • Active_Player[FixScale[0]] Equal to Да
        • Then - Actions
          • Set VariableSet PlayerLocal = (Player(FixScale[0]))
          • Custom script: if GetLocalPlayer() == udg_PlayerLocal then
          • Animation - Change BOSS_Unit[TEI_BOSS_Spawn]'s size to (180.00%, 180.00%, 180.00%) of its original size
          • Custom script: endif
        • Else - Actions
All I needed is to get IsReforged array true or false. Should I set IsReforged boolean with the same method?

  • TEST
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer A) from 1 to Max_Player_Number, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Active_Player[(Integer A)] Equal to Да
            • Then - Actions
              • Set VariableSet PlayerLocal = (Player((Integer A)))
              • Custom script: if GetLocalPlayer() == udg_PlayerLocal then
              • Custom script: set udg_IsReforged[bj_forLoopAIndex] = IsReforged()
              • Custom script: endif
            • Else - Actions

Just tested it, failed to compile
Ok, I've changed IsReforged trigger into a custom script trigger and now it compiles. Testing it...
 
Level 7
Joined
Jun 1, 2009
Messages
104
You don't need a boolean array

You mean it's just:

  • For each (Integer FixScale[0]) from 1 to Max_Player_Number, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Active_Player[FixScale[0]] Equal to Да
        • Then - Actions
          • Set VariableSet PlayerLocal = (Player(FixScale[0]))
          • Custom script: set udg_IsReforged = IsReforged()
          • Custom script: if GetLocalPlayer() == udg_PlayerLocal and udg_IsReforged == true then
          • Animation - Change BOSS_Unit[TEI_BOSS_Spawn]'s size to (180.00%, 180.00%, 180.00%) of its original size
          • Custom script: endif
        • Else - Actions
? Sweet!

Just tested it. Maybe I've made something wrong, but it's not working :wconfused:
I have no reforged, and I've set IsReforged as true by default, but it still changes the unit's size for me.
 
Last edited:
Status
Not open for further replies.
Top