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

[vJASS] Question about Boolean Conditions

Status
Not open for further replies.
Level 4
Joined
May 12, 2017
Messages
28
Something I've been wondering about for a while now after looking at how Jass is generated by the editor and how Jass is laid out in map files I've looked at...

Is this valid code to write in Jass? [I come from a C# background where this is just inefficient and stupid]
JASS:
scope DummyScope initializer onInit
  globals
    boolean ToolsPatrol = false
  endglobals

  private function Action takes nothing returns nothing
    ... ToolsPatrol is set to true in another scope which runs BEFORE this code
    if (ToolsPatrol) then
      call DisplayTimedTextToPlayer(GetOwningPlayer(GetTriggerUnit()), 0, 0, 10, "Global TriggerPatrol Exists")
    else
      call DisplayTimedTextToPlayer(GetOwningPlayer(GetTriggerUnit()), 0, 0, 10, "Global TriggerPatrol Doesn't Exist")
    endif
  endfunction

  private function onInit takes nothing returns nothing
    ... Add Action for Trigger along with Event
  endfunction
endscope

The following code has an "== true" added to the if statement, something that I'm not a fan of personally and hope this isn't actually needed
JASS:
scope DummyScope initializer onInit
  globals
    boolean ToolsPatrol = false
  endglobals

  private function Action takes nothing returns nothing
    ... ToolsPatrol is set to true in another scope which runs BEFORE this code
    if (ToolsPatrol == true) then
      call DisplayTimedTextToPlayer(GetOwningPlayer(GetTriggerUnit()), 0, 0, 10, "Global TriggerPatrol Exists")
    else
      call DisplayTimedTextToPlayer(GetOwningPlayer(GetTriggerUnit()), 0, 0, 10, "Global TriggerPatrol Doesn't Exist")
    endif
  endfunction

  private function onInit takes nothing returns nothing
    ... Add Action for Trigger along with Event
  endfunction
endscope

I am not experienced with how vJass works and currently does not have access to a computer which has capabilities to use JGNP or WEX to test the functions in question, I was hoping to get an answer before I have access again so I don't waste my time.

Compare the two Scopes and the only change is the "== true" check... Is this a required element or is the GUI -> Jass Generator simply that stupid?
 
Status
Not open for further replies.
Top