Syntax Errors Hilight every piece of code

D.V.D

Make a wish
Reaction score
73
Well, I wanted to make a slide in my trigger with timers but I get these wierd Syntax Errors hilighting every line of my code. Here's the code:
JASS:

function Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A004' ) ) then
        return false
    endif
    return true
endfunction

function StopLaser takes nothing returns boolean
    if ( not ( udg_Loop == 200 ) ) then
        return false
    endif
    return true
endfunction

function KillLaser takes nothing returns nothing
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = udg_Array
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call KillUnit( udg_Laser[GetForLoopIndexA()] )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction

function Laser takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local unit Missile = GetLastCreatedUnit()
    local unit Explode
    local location p2 = GetUnitLoc(Missile)
    local location p3 = PolarProjectionBJ(p2, 12.00, GetUnitFacing(Caster))
    local timer t = GetExpiredTimer()
    call SetUnitPositionLoc( Missile, p3 )
    call CreateNUnitsAtLocFacingLocBJ( 1, 'h006', GetOwningPlayer(Caster), p2, p2 )
    set udg_Laser[udg_Array] = GetLastCreatedUnit()
    call SetUnitTimeScalePercent( udg_Laser[udg_Array], 0.00 )
    set udg_Array = ( udg_Array + 1 )
    set udg_Loop = udg_Loop + 1
    call TimerStart(t, 0.01, true, function Laser)
    if ( StopLaser() ) then
       set p2 = GetUnitLoc(Missile)
       call CreateNUnitsAtLocFacingLocBJ( 1, 'h004', GetOwningPlayer(Caster), p2, p2 )
       set Explode = GetLastCreatedUnit()
       call KillUnit( Missile )
       call UnitApplyTimedLifeBJ( 1.00, 'BTLF', Explode )
       call DestroyTimer(t)
       call KillLaser()
    else
    endif
endfunction

function Actions takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local unit Missile
    local location p0 = GetUnitLoc(Caster)
    local location p1 = PolarProjectionBJ(p0, 100.00, GetUnitFacing(Caster))
    local location p2
    local integer i = 1
    local integer e = 200
    local timer t = CreateTimer()
    call AddSpecialEffectTargetUnitBJ( "left hand", Caster, "Bibang.mdx" )
    call TriggerSleepAction( 0.50 )
    call DestroyEffectBJ( GetLastCreatedEffectBJ() )
    call CreateNUnitsAtLocFacingLocBJ( 1, 'h007', GetOwningPlayer(Caster), p1, p0 )
    set Missile = GetLastCreatedUnit()
    set p2 = GetUnitLoc(Missile)
    set udg_Array = 1
    set udg_Loop = 1
    call TimerStart(t, 0.01, true, function Laser)
endfunction

//===========================================================================
function InitTrig_Kamehameha_Copy takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function Conditions ) )
    call TriggerAddAction( t, function Actions )
endfunction


Any help?
 

ZeratuelX

New Member
Reaction score
6
Heres the syntax errors I'm getting:

Line 18: Undeclared variable: t
Line 43: udg_Laser not an array

Does your syntax checker give you any specific messages?
 

D.V.D

Make a wish
Reaction score
73
Im getting like 20 syntax errors. I don't know, it says for some variables expect endlines for like this: local integer i = 20 and then every function with the variable that was highlighted will be saying expected a name.

EDIT: Counted, I have 40 errors and laser is a array and I declared the timer t to see if it will be fixed.
 

Azlier

Old World Ghost
Reaction score
461
Could you post the exact syntax errors? Oh, and since you don't have NewGen, naming functions things like Actions won't work out well. Odds are, you have more than one trigger with the actions function named Actions...

I don't see the exact source of syntax errors, but you should know that you can't directly get the triggering unit and stuff from timer callbacks. And in your timer callback, you are restarting the timer 't'. There are problems with this:
1. There is no such variable 't' in that function.
2. Having a timer callback start another timer for itself indefinitely doesn't strike me as brilliant.
3. GetExpiredTimer(), hello?
 

D.V.D

Make a wish
Reaction score
73
Sorry, frogot about GetExpiredTimer. Im not gonna post 40 syntax errors, that will take forever. The second trigger using a function Actions is disabled. Why does it matter anyways? The Timer stuff Im gonna have to learn a bit and in the function that slides, I added the Timer t.
 

Azlier

Old World Ghost
Reaction score
461
>Why does it matter anyways?
Functions, unless specific to a scope or library, cannot have the same name.


>Im not gonna post 40 syntax errors, that will take forever.
Thou shalt* post syntax errors, unless you wish for us to keep guessing!

You need to attach the triggering unit and such to the timer. But, for that, you need a stack of arrays and H2I. Why else do you think we use all these attachment systems? Fun? Challenge?

*Gotta love those random archaisms.
 

D.V.D

Make a wish
Reaction score
73
Ill upload the map, just give me a second.

EDIT: Uploaded map on the first post.
 

saw792

Is known to say things. That is all.
Reaction score
280
Just post the first two or three syntax errors, they generally fix the rest. I doubt anybody will download your map to sift through.
 

ZeratuelX

New Member
Reaction score
6
OK a few problems. First, in your map you have 1 variable defined and that is udg_Loop. You need to define udg_Array and udg_Laser in your variables editor. Second, locals are only used for that function unless they are passed as an argument. It's better to define globals that can be used throughout all functions if you planning to use the same variable.

After you create Array (Integer Array) and Laser (Unit Array) in your variables editor. Try this jass code:

JASS:
function Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A004' ) ) then
        return false
    endif
    return true
endfunction

function Laser takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local unit Missile = GetLastCreatedUnit()
    local location p2 = GetUnitLoc(Missile)
    local location p3 = PolarProjectionBJ(p2, 12.00, GetUnitFacing(Caster))
    local timer t = CreateTimer()
    call SetUnitPositionLoc( Missile, p3 )
    call CreateNUnitsAtLocFacingLocBJ( 1, 'h006', GetOwningPlayer(Caster), p2, p2 )
    set udg_Laser[udg_Array] = GetLastCreatedUnit()
    set udg_Array = ( udg_Array + 1 )
    call TimerStart(t, 0.01, true, function Laser)
endfunction

function Actions takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local unit Missile
    local unit Explode
    local location p0 = GetUnitLoc(Caster)
    local location p1 = PolarProjectionBJ(p0, 100.00, GetUnitFacing(Caster))
    local location p2
    local integer i = 1
    local integer e = 200
    local timer t = CreateTimer()
    call AddSpecialEffectTargetUnitBJ( "left hand", Caster, "Bibang.mdx" )
    call TriggerSleepAction( 0.50 )
    call DestroyEffectBJ( GetLastCreatedEffectBJ() )
    call CreateNUnitsAtLocFacingLocBJ( 1, 'h007', GetOwningPlayer(Caster), p1, p0 )
    set Missile = GetLastCreatedUnit()
    set p2 = GetUnitLoc(Missile)
    set udg_Array = 1
    call TimerStart(t, 0.01, true, function Laser)
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = udg_Array
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call KillUnit( udg_Laser[GetForLoopIndexA()] )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call CreateNUnitsAtLocFacingLocBJ( 1, 'h004', GetOwningPlayer(Caster), p2, p2 )
    set Explode = GetLastCreatedUnit()
    call KillUnit( Missile )
    call UnitApplyTimedLifeBJ( 1.00, 'BTLF', Explode )
    call RemoveLocation(p0)
    call RemoveLocation(p1)
    call RemoveLocation(p2)
endfunction

//===========================================================================
function InitTrig_Kamehameha_Copy takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function Conditions ) )
    call TriggerAddAction( t, function Actions )
endfunction
 

D.V.D

Make a wish
Reaction score
73
I didn't want to make most of my variables as globals, Laser and the other variable are already arrays. Im gonna try your code now.

EDIT: Worked but what did you change?

EDIT2: The game lags so much you need task manager to turn it off.
 

wraithseeker

Tired.
Reaction score
122
This is super inefficent

JASS:
call SetUnitPositionLoc( Missile, p3 )

to
JASS:
call SetUnitPosition(Missle,x,y)


JASS:
call CreateNUnitsAtLocFacingLocBJ( 1, 'h007', GetOwningPlayer(Caster), p1, p0 )

to

JASS:
set explode = CreateUnit(GetOwningPlayer(Caster),'h007',x,y,what angle?)


That removed a extra one line , efficent isn't it :)


JASS:
call TimerStart(t, 0.01, true, function Laser)


You called this from your actions already and why does it has to be 0.01? it would lag bits with sense , try a value from something like 0.03 ~ 0.04


Use X and Y instead of Locations , so you can use the natives instead of the BJS.

Add this to your actions function at the top.
JASS:
local integer i = 0
exitwhen i > 1
set i = i + 1


Also I don't get what are you doing with the loop function, it runs only once so why even bother looping it?

What is UDG_laser ? use locals pff!

JASS:
call UnitApplyTimedLifeBJ( 1.00, 'BTLF', Explode )


to
JASS:
call UnitApplyTimedLife(Explode,'BTLF',1)


Don't forget to

JASS:
set caster = null
set missle = null
set explode = null
set p1 = null
set p0 = null
set p2 = null


Hope this post helped you <3 , took me a long time to write out . I think I posted all the mistakes u have now. Go and amend it or tomorrow morning i'll look out for this thread and reply if you have problems.
 

D.V.D

Make a wish
Reaction score
73
I don't use X/Y's because I don't get them and every time someone tried to help me with them, it always messed up. The timed life I forgot to change, thanks. The original version of this code worked perfectly in GUI and it didn't lag so I don't see why this one lags so much you can't do anything. There's a mistake in the code. 0.01 doesn't lag as much as you guys think it does. I've seen maps that for every slide, they used 0.01 and it doesn't lag at all.
 

Artificial

Without Intelligence
Reaction score
326
JASS:
function Laser takes nothing returns nothing
    [...]
    local timer t = CreateTimer()
    [...]
    call TimerStart(t, 0.01, true, function Laser)
endfunction

Let's take a little timeline.
Code:
[B]time - what happens[/B]

0.00 - t0 (a timer) is created as a 0.01 repeating timer with Laser as its callback

0.01 - t0 expires and Laser is called.
       Laser creates a new timer (t1) and starts it as a 0.01
       repeating timer with Laser as its callback

0.02 - t0 expires and Laser is called.
       Laser creates a new timer (t2) and starts it...
       t1 expires and Laser is called.
       Laser creates a new timer (t3) and starts it...

0.03 - t0 expires and Laser creates t4 and starts it...
       t1 expires and Laser creates t5 and starts it...
       t2 expires and ...
       t3 expires and ...

0.04 - t0 expires...
       t1 expires...
       t2 expires...
       t3 expires...
       t4 expires...
       t5 expires...
       t6 expires...
       t7 expires...

0.05 - t0 expires...
       t1 expires...
       t2 expires...
       t3 expires...
       t4 expires...
       t5 expires...
       t6 expires...
       t7 expires...
       t8 expires...
       t9 expires...
       t10 expires...
       t11 expires...
       t12 expires...
       t13 expires...
       t14 expires...
       t15 expires...

0.06 - t0
       t1
       t2
       t3
       t4
       t5
       t6
       t7
       t8
       t9
       t10
       t11
       t12
       t13
       t14
       t15
       t16
       t17
       t18
       t19
       t20
       t21
       t22
       t23
       t24
       t25
       t26
       t27
       t28
       t29
       t30
       t31

0.07 - t0
       t1
       t2
       t3
       t4
       t5
       t6
       t7
       t8
       t9
       t10
       t11
       t12
       t13
       t14
       t15
       t16
       t17
       t18
       t19
       t20
       t21
       t22
       t23
       t24
       t25
       t26
       t27
       t28
       t29
       t30
       t31
       t32
       t33
       t34
       t35
       t36
       t37
       t38
       t39
       t40
       t41
       t42
       t43
       t44
       t45
       t46
       t47
       t48
       t49
       t50
       t51
       t52
       t53
       t54
       t55
       t56
       t57
       t58
       t59
       t60
       t61
       t62
       t63

And so on...

Shouldn't be too hard to guess what you might wanna remove from the function Laser? :p
 

D.V.D

Make a wish
Reaction score
73
So I should make a variable that when it reaches like 200, its supposed to destroy the timer?
 

D.V.D

Make a wish
Reaction score
73
Updated Code, the unit doesn't slide and the units in SlideActions aren't created.
 

D.V.D

Make a wish
Reaction score
73
JASS:
function Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == &#039;A004&#039; ) ) then
        return false
    endif
    return true
endfunction

function StopLaser takes nothing returns boolean
    if ( not ( udg_Loop == 200 ) ) then
        return false
    endif
    return true
endfunction

function KillLaser takes nothing returns nothing
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = udg_Array
    loop
        exitwhen bj_forLoopAIndex &gt; bj_forLoopAIndexEnd
        call KillUnit( udg_Laser[GetForLoopIndexA()] )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction

function Laser takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local unit Explode
    local location p2 = GetUnitLoc(udg_u[0])
    local location p3 = PolarProjectionBJ(p2, 12.00, GetUnitFacing(Caster))
    local timer t = GetExpiredTimer()
    call SetUnitPositionLoc( udg_u[0], p3 )
    call CreateNUnitsAtLocFacingLocBJ( 1, &#039;h006&#039;, GetOwningPlayer(Caster), p2, p2 )
    set udg_Laser[udg_Array] = GetLastCreatedUnit()
    call SetUnitTimeScalePercent( udg_Laser[udg_Array], 1.00 )
    set udg_Array = ( udg_Array + 1 )
    set udg_Loop = udg_Loop + 1
    call TimerStart(t, 0.01, true, function Laser)
    if ( StopLaser() ) then
       set p2 = GetUnitLoc(udg_u[0])
       call CreateNUnitsAtLocFacingLocBJ( 1, &#039;h004&#039;, GetOwningPlayer(Caster), p2, p2 )
       set Explode = GetLastCreatedUnit()
       call KillUnit( udg_u[0] )
       call UnitApplyTimedLifeBJ( 1.00, &#039;BTLF&#039;, Explode )
       call DestroyTimer(t)
       call KillLaser()
    else
    endif
endfunction

function Actions takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local location p0 = GetUnitLoc(Caster)
    local location p1 = PolarProjectionBJ(p0, 100.00, GetUnitFacing(Caster))
    local location p2
    local integer i = 1
    local integer e = 200
    local timer t = CreateTimer()
    call AddSpecialEffectTargetUnitBJ( &quot;left hand&quot;, Caster, &quot;Bibang.mdx&quot; )
    call TriggerSleepAction( 0.50 )
    call DestroyEffectBJ( GetLastCreatedEffectBJ() )
    call CreateNUnitsAtLocFacingLocBJ( 1, &#039;h007&#039;, GetOwningPlayer(Caster), p1, p0 )
    set udg_u[0] = GetLastCreatedUnit()
    set p2 = GetUnitLoc(udg_u[0])
    set udg_Array = 1
    set udg_Loop = 1
    call TimerStart(t, 0.01, true, function Laser)
endfunction

//===========================================================================
function InitTrig_Kamehameha_Copy takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function Conditions ) )
    call TriggerAddAction( t, function Actions )
endfunction


Here's your code.
 

D.V.D

Make a wish
Reaction score
73
The missile is the only thing madde and it slides but, when it slides, its supposed to make other units on the way and the explosion at the end isn't made either.

So this part of the code isn't happening(explosion):
JASS:
    if ( StopLaser() ) then
       set p2 = GetUnitLoc(udg_u[0])
       call CreateNUnitsAtLocFacingLocBJ( 1, &#039;h004&#039;, GetOwningPlayer(Caster), p2, p2 )
       set Explode = GetLastCreatedUnit()
       call KillUnit( udg_u[0] )
       call UnitApplyTimedLifeBJ( 1.00, &#039;BTLF&#039;, Explode )
       call DestroyTimer(t)
       call KillLaser()
    else
    endif


And the laser:
JASS:
    call CreateNUnitsAtLocFacingLocBJ( 1, &#039;h006&#039;, GetOwningPlayer(Caster), p2, p2 )
    set udg_Laser[udg_Array] = GetLastCreatedUnit()
    call SetUnitTimeScalePercent( udg_Laser[udg_Array], 1.00 )
    set udg_Array = ( udg_Array + 1 )
    set udg_Loop = udg_Loop + 1
 
General chit-chat
Help Users

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top