[Jass] Simple, quick question!

RandomUser1

Member
Reaction score
0
Firstly i'd like to say i tried to create this in the JASS area but everytime i click Create a New etc.. it says "502 BadGateway".

Anyway i just have a quick question. Which is better. NOTE: There are multiple Elseif's i just cut it to make this short but there are about 18 Arenas a player can claim.

JASS:
    local player p = GetTriggerPlayer()
    local integer i = GetPlayerId(p) + 1
    local real x = GetLocationX(GetUnitLoc(udg_Hero<i>))
    local real y = GetLocationY(GetUnitLoc(udg_Hero<i>))
    if RectContainsCoords(gg_rct_B1, x, y) then
        if udg_ArenaClaimed[1] == false and udg_PlayerOwnsArena == 0 then
</i></i>


I am "assuming" that it would be better to just register the unit location x, y first as a local as opposed to checking it in every elseif . . .

JASS:
    local player p = GetTriggerPlayer()
    local integer i = GetPlayerId(p) + 1
    if RectContainsCoords(gg_rct_B1, GetUnitX(udg_Hero<i>), GetUnitY(udg_Hero<i>)) then
        if udg_ArenaClaimed[1] == false and udg_PlayerOwnsArena == 0 then
</i></i>


instead of the trigger constantly checking the location of x, y?
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
It doesnt make a difference to a computer.
Do what is more readable and more easier to maintain.
 

jonas

You can change this now in User CP.
Reaction score
63
Do what is more readable and more easier to maintain.
I concur.

It doesnt make a difference to a computer.
Well, it might, but the difference is so low you won't notice.


Although unrelated to your original question:
JASS:
    ... GetLocationX(GetUnitLoc(udg_Hero<i>))
    ... GetLocationY(GetUnitLoc(udg_Hero<i>))
</i></i>

Now I haven't checked but I would assume that GetUnitLoc allocates a location. The GetUnitX is certainly better style and doesn't.
 
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