Undefined function.

Flare

Stops copies me!
Reaction score
662
I'm trying to make my first JASS spell, but for some reason, I'm getting an Undefined function error when I save (it's the only error I have so far).

(Most of the comments can be ignored, they are just for personal reference)

JASS:
scope CrimsonFlash
//Alter this to change the speed of the fireballs, how often fireballs spawn, the rawcode of your base ability, and how often the fireballs move
globals
    constant integer spellid = 'A000'
    constant real distance = 30
    constant real slideperiod = 0.04
    constant real spawnperiod = 0.25
    constant real angleincrease = 35
    constant real initangle = GetRandomReal (1, 360)
endglobals

//Data used to create fireballs and set their facing angle
struct Firespawn
    unit fireowner
    real spawnrate //This will increase with level, when the spell works in the first place
endstruct



//Data used to move the fireballs, and determine when they expire
struct Firemovement
    unit fireunit //The dummy fireball unit
    real x1
    real x2
    real y1
    real y2
    real anglerad
    real angledeg
    integer ticks
endstruct
 
//Spell conditions
function Spell_Conditions takes nothing returns boolean
    return GetSpellAbilityId () == spellid
endfunction

//Spell actions
function Spell_Actions takes nothing returns nothing
    local real angle
    local timer t1 = CreateTimer ()
    local Firespawn data = Firespawn.create ()
    call SetTimerStructA (t1, data)
    set data.fireowner = GetTriggerUnit ()
    call TimerStart (t1, spawnperiod, true, function Timer1Actions) //Error saying that function Timer1Actions is undefined
endfunction

function Timer1Actions takes nothing returns nothing
    local Firespawn data
    local timer t1 = GetExpiredTimer ()
    local real spawnangle
    set data = GetTimerStructA(t1)
    set spawnangle = initangle
    set spawnangle = spawnangle + angleincrease
endfunction



//Trigger Init
function InitTrig_Spell takes nothing returns nothing
    local trigger  Spell = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Spell, function Spell_Actions )
    call TriggerRegisterAnyUnitEventBJ (Spell, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition (Spell, Condition (function Spell_Conditions))
endfunction
endscope
 

Hatebreeder

So many apples
Reaction score
381
Well, I think you used ABC wrong...
JASS:
function Timer1Actions takes nothing returns nothing
    local Firespawn data
    local timer t1 = GetExpiredTimer ()
    local real spawnangle
    set data = GetTimerStructA(t1)
    set spawnangle = initangle
    set spawnangle = spawnangle + angleincrease
endfunction

This should be over the Actions Part.
 

SerraAvenger

Cuz I can
Reaction score
234
Try taking out the comments just as a test, I had problems concerning them too...

Apart from that, make sure you've got SetTimerStructA and GetTimerStructA as functions

And do this:

JASS:
//Spell actions

function Timer1Actions takes nothing returns nothing
    local Firespawn data
    local timer t1 = GetExpiredTimer ()
    local real spawnangle
    set data = GetTimerStructA(t1)
    set spawnangle = initangle
    set spawnangle = spawnangle + angleincrease
endfunction

function Spell_Actions takes nothing returns nothing
    local real angle
    local timer t1 = CreateTimer ()
    local Firespawn data = Firespawn.create ()
    call SetTimerStructA (t1, data)
    set data.fireowner = GetTriggerUnit ()
    call TimerStart (t1, spawnperiod, true, function Timer1Actions) //Error saying that function Timer1Actions is undefined
endfunction


hth, Davey

Edit: and again I was typing too slow ; O
Aceheart is right ofc
 

SerraAvenger

Cuz I can
Reaction score
234
uhm... meaning?

That the compiler goes from line to line, top to bottom.
Thus it only knows things that it actually had read before, so if you call a function that you add after the point of calling, the compiler has never seen the function before. Thus he says "WTF? I can't call this function, I've never seen it!!!", and gives you an error message.

Hth, Davey
 

soulreaping

New Member
Reaction score
17
I hate seeing people assigning the expired timer that is needed to pull out the attached struct to a local variable.

It makes nothing faster, and requires nullification.

Simply do this:
JASS:

local Struct s = GetTimerStructA(GetExpiredTimer())


Easier.
 

GoGo-Boy

You can change this now in User CP
Reaction score
40
I hate seeing people assigning the expired timer that is needed to pull out the attached struct to a local variable.

It makes nothing faster, and requires nullification.

Simply do this:
JASS:

local Struct s = GetTimerStructA(GetExpiredTimer())


Easier.

Ahh nice, gonna use this right now ;)
 

0zaru

Learning vJASS ;)
Reaction score
60
EDIT: Oh was this solved? I read the last question, and posted then I read an Edit from Flare...

local Struct s = GetTimerStructA(GetExpiredTimer()) <--- This function goes in the TimerActions, It's a short form to get the struct. Also remember to null local timers, etc
 
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