• 🏆 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] If/Then/Else with JASS?

Status
Not open for further replies.
Level 10
Joined
Feb 19, 2006
Messages
237
How can do a simple If/Then/Else statement with Jass? More importantly how can i check the value of a Boolean variable using Jass? I set a local variable called "inv" to true by inserting custom script and typing "inv = true" and now i want to CHECK what the value of "inv" is. If it is "true" i want to the text "inv is true" to be shown to all players. If it is "false" i want the text "inv is false" to be shown to all players. Help would be greatly appreciated. :)

EDIT:
I can do the actions "show text to all players" using GUI...I just want to know how i can make a simple GUI/Jass combination trigger that checks the value of a local boolean then does an action depending on what that value is.
 
Level 10
Joined
Feb 19, 2006
Messages
237
Thank you :) however i seem to still have trouble. Here is what im trying to achieve.

EVENT:
--every 1 second of game time
CONDITION:
ACTION:
Pick every unit in playable map area
--local boolean inv = false
--pick every destructable within 200 of picked unit
----if picked destructable is ashenvale tree wall
------then set local variable "inv" to "true"
------add permanent invisibility to picked unit
--if local variable "inv" is "false"
----then removed permanment invisibility from picked unit
----else do nothing

It seems like the problem is with the custom script line "set inv = true" because im getting the error "expected a variable name" when i try to enable the trigger.
 
Level 6
Joined
May 19, 2004
Messages
267
The declaration and the "set" are in two different scopes, I'd suggest using a global.

EDIT: Sorry didn't notice you solved it, should've refreshed the page before I posted.
 
Level 10
Joined
Feb 19, 2006
Messages
237
The declaration and the "set" are in two different scopes, I'd suggest using a global.

EDIT: Sorry didn't notice you solved it, should've refreshed the page before I posted.

I used a global originally but i need local variables because i wanted it to be Multi instancebel...but ya i solved the problem and posted the working trigger on this site for anyone who needs it
 
Level 6
Joined
May 19, 2004
Messages
267
I used a global originally but i need local variables because i wanted it to be Multi instancebel...but ya i solved the problem and posted the working trigger on this site for anyone who needs it

As you aren't using any waits, there isn't any need for a local.

  • Invisibility Near Trees
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • Set inv = False
          • Destructible - Pick every destructible within 200.00 of (Position of (Picked unit)) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Destructible-type of (Picked destructible)) Equal to Ashenvale Tree Wall
                • Then - Actions
                  • Set inv = True
                • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • inv Equal to True
            • Then - Actions
              • Unit - Add Permanent Invisibility to (Picked unit)
            • Else - Actions
              • Unit - Remove Permanent Invisibility from (Picked unit)
Would work fine and is MUI.
 
Status
Not open for further replies.
Top