Using a global defined variable in a custom script

MaQleod

New Member
Reaction score
0
I have a global array (StartPosition[]) which gets assigned during the trigger based on the owner of the triggering unit.
during the script I run this custom script command:
call ReviveHeroLoc(OURHERO, GetRectCenter(GetPlayableMapRect()), true )

This is based on the revive hero tutorial. Instead of GetPlayableMapRect(), I want to use StartPosition[0] so the hero revives at the starting location of it's owner, but if I change it out, I get an error. How do I input a global variable into the custom script?

Jared
 

Guest3z

New Member
Reaction score
22
when replacing GetPlayableMapRect() in the custom script make sure to put udg_ infront of your variable name

so I believe you would want "udg_StartPosition[0]"

edit- You also dont need GetRectCenter( ) of "GetRectCenter(GetPlayableMapRect())" so..

call ReviveHeroLoc(OURHERO, udg_StartPosition[0], true )
 

MaQleod

New Member
Reaction score
0
but OURHERO is local, it was declared via custom script earlier in the trigger. StartPosition[] is global and is declared using the variable gui in the trigger editor.
 

Sevion

The DIY Ninja
Reaction score
413
[ljass]call ReviveHeroLoc(OURHERO, udg_StartPosition[0], true)[/ljass] doesn't work?

Unless you spelled one of the variables wrong, then it should work fine.

But why 0? All heroes will be revived at the same place.
 

MaQleod

New Member
Reaction score
0
thats the whole point of why I'm changing this. I don't want the heroes reviving in the same spot, I want them to reappear in a different spot based on the player who owns them. This is all assigned elsewhere.
I had mispelled something, but with that fixed, I learned something else:

It does need the GetRectCenter() portion or it does not return a valid structure for the coordinates for ReviveHeroLoc().
 

Sevion

The DIY Ninja
Reaction score
413
[ljass]call ReviveHeroLoc(OURHERO, udg_StartPosition[GetPlayerId(GetOwningPlayer(OURHERO) + 1], true)[/ljass]

That should work. StartPosition is set in GUI, correct? Otherwise, remove the + 1.

What are you talking about with GetRectCenter? StartPosition is a location, isn't it?
 

MaQleod

New Member
Reaction score
0
It is a region, but the compiler wouldn't accept it without GetRectCenter(). So however that function returns data, it is what ReviveHeroLoc() is looking for. I'm not sure where to find what the actual functions look like to see how they return data, so I can't say for certain why.
I had looked at GetOwningPlayer() as an option, but I was not sure what exactly it returned and how to differentiate that between the existing players, but that would have worked to with some conditionals to determine the correct starting region for the player and return the coordinates and I wouldn't have needed to use the global variable. Either way, what I have works.
 

MaQleod

New Member
Reaction score
0
but in what format? I can't do a boolean comparison if I don't know what I'm looking for, it will always fail.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top