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

[JASS] Syntax error

Status
Not open for further replies.
Level 1
Joined
May 24, 2008
Messages
3
Problem solved




JASS:
function JumpJass_Actions takes nothing returns nothing
    local unit caster = GetSpellAbilityUnit()
    local location start_position = GetUnitLoc(caster)
    local location ziel_position = GetSpellTargetLoc()
 
    local real x_diff =  GetLocationX(start_position) - GetLocationX(ziel_position)
    local real y_diff = GetLocationY(start_position) - GetLocationY(ziel_position)
    
    set x_diff = Betrag(x_diff)
    set y_diff = Betrag(y_diff)
        
    local real temp = x_diff // SYNTAX ERROR
    local real factor = SquareRoot(temp)/200 //UNDECLARED VARIABLE: factor
    call DamageUnit(GetOwningPlayer(caster), factor, caster)

    set udg_Jumpgate_Ziel[GetConvertedPlayerId(GetOwningPlayer(caster))] = GetSpellTargetLoc()
    set udg_Jumpgate_Unit[GetConvertedPlayerId(GetOwningPlayer(caster))] = CreateUnitAtLoc(GetOwningPlayer(caster), 'e001', start_position, 0.00)
           
endfunction

can someone help me?
I just started to use Jass and cant find my mistake
 
Last edited:
Level 9
Joined
Mar 25, 2005
Messages
252
you can't declare locals in a function after you have done something else than declared locals in it

fix:
JASS:
function JumpJass_Actions takes nothing returns nothing
    local unit caster = GetSpellAbilityUnit()
    local location start_position = GetUnitLoc(caster)
    local location ziel_position = GetSpellTargetLoc()

    local real x_diff = Betrag(GetLocationX(start_position) - GetLocationX(ziel_position))
    local real y_diff = Betrag(GetLocationY(start_position) - GetLocationY(ziel_position))

    local real temp = x_diff
    local real factor = SquareRoot(temp)/200
    call DamageUnit(GetOwningPlayer(caster), factor, caster)

    set udg_Jumpgate_Ziel[GetConvertedPlayerId(GetOwningPlayer(caster))] = GetSpellTargetLoc()
    set udg_Jumpgate_Unit[GetConvertedPlayerId(GetOwningPlayer(caster))] = CreateUnitAtLoc(GetOwningPlayer(caster), 'e001', start_position, 0.00)
endfunction
 
Status
Not open for further replies.
Top