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
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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