• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[JASS] local integer in an integer loop?

Status
Not open for further replies.
Level 28
Joined
Mar 25, 2008
Messages
2,954
So, i got this loop using a local integer (C)
JASS:
    set C = 1
    loop
        exitwhen C > 8
        set x = ( x + 45.00 )
        set div_cross_ball_pkt_create = PolarProjectionBJ(divine_cross_caster_punkt, 500.00, ( x + 45.00 ))
        call CreateNUnitsAtLoc( 1, 'o01Q', GetOwningPlayer(GetTriggerUnit()), div_cross_ball_pkt_create, bj_UNIT_FACING )
        set judgement_blitz_anfang[C] = GetLastCreatedUnit()
        set divine_cross_ball_punkt[C] = GetUnitLoc(judgement_blitz_anfang[C])
        set C = C + 1
    endloop
Is this even possible or do h have to use a global variable for that?
 
Huh? What is a native function? o.O
The problem with that loop is, it doesn't work - so i thought, it could be caused by that local integer.. i've set all the important locals at the start but nothing happens..
JASS:
    local location divine_cross_caster_punkt
    local location div_cross_ball_pkt_create
    local location array divine_cross_ball_punkt
    local unit array judgement_blitz_anfang
So, what's wrong?
I'm sure, I forgot something
 
no, a local loop variable is just fine, though I think a global one would be more efficient (not sure about that though)
Although the difference would be negligible, I'm pretty sure a local loop variable is more efficient than a global loop variable.

Squiggy, have you actually initialized the locations?
I also don't see c declared at all. Have you written
local integer C = 1 somewhere?
In WE newgen you can see if a function is native by looking at the function. If it's preceded by the word "native", then it's a native. Non-native functions are functions with a visible body, that use natives instead and are usually less efficient than simply using the natives directly.

For instance:
JASS:
function IsUnitDeadBJ takes unit whichUnit returns boolean
    return GetUnitState(whichUnit, UNIT_STATE_LIFE) <= 0
endfunction
This function is not a native function, it checks the unit state of a unit and returns true if it's less than 0. Instead of using "if IsUnitDeadBJ(unit) then", you could just as easily use
'if GetUnitState(whichUnit, UNIT_STATE_LIFE) <= 0 then"
because GetUnitState is a native function.
 
Status
Not open for further replies.
Back
Top