• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Local Variables

Status
Not open for further replies.
Level 9
Joined
Apr 5, 2008
Messages
443
Okay, so I was making a map and I realized that I needed to use local variables to make the triggers work just right; so naturally I checked the tutorials section and sure enough I found how to create them and set them, but what if you wanted to create them and set them in one function? I use the GUI function Custom Script and I ended up with this trigger to be what I wanted, however it does not compile properly and I am pretty sure it has to do with the me not using the Local function correctly.

  • Camera01
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Array[1] Equal to 1
        • Then - Actions
          • Custom script: local unit Entering_unit
          • Custom script: set my_unit = udg_Hero()
        • Else - Actions
          • Do nothing
      • Custom script: call CameraSetupApplyForPlayer( true, gg_cam_Camera_001, GetOwningPlayer (Entering_unit()) , 1.00 )
If you find anything wrong with this trigger, please tell me. Anyway I believe there is a way to make and set the local in one function because the simple fact that in every other programing language I have used it has a function that allows you to do just that.
 
Level 15
Joined
Feb 15, 2006
Messages
851
  • Camera01
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Array[1] Equal to 1
        • Then - Actions
          • Custom script: local unit Entering_unit
          • Custom script: set Entering_unit = udg_Hero
        • Else - Actions
          • Do nothing
      • Custom script: call CameraSetupApplyForPlayer( true, gg_cam_Camera_001, GetOwningPlayer (Entering_unit) , 1.00 )
test it now and tell me...
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
Nope, you still made 1 mistake:

  • Camera01
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Custom script: local unit Entering_unit
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Array[1] Equal to 1
        • Then - Actions
          • Custom script: set Entering_unit = udg_Hero
        • Else - Actions
          • Do nothing
      • Custom script: call CameraSetupApplyForPlayer( true, gg_cam_Camera_001, GetOwningPlayer (Entering_unit) , 1.00 )
 
Level 9
Joined
Apr 5, 2008
Messages
443
Nope, you still made 1 mistake:

  • Camera01
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Custom script: local unit Entering_unit
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Array[1] Equal to 1
        • Then - Actions
          • Custom script: set Entering_unit = udg_Hero
        • Else - Actions
          • Do nothing
      • Custom script: call CameraSetupApplyForPlayer( true, gg_cam_Camera_001, GetOwningPlayer (Entering_unit) , 1.00 )

Although I don't think this is what I want because this would make it create a new local every time would it not, or would it realize that the local already exists and ignore the command to create one? I will test it.
 
Status
Not open for further replies.
Top