• 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.

[JASS] Undefined function?

Status
Not open for further replies.
Level 23
Joined
Nov 29, 2006
Messages
2,482
Hm, I can't find any thing wrong with the codes I did below.
Suggestions anyone?

JASS:
function InitVehicles takes nothing returns nothing
    local group g = CreateGroup()
    local boolexpr e = Condition(function HasVehicleValue)
    call GroupEnumUnitsOfPlayer(g, Player(15), e)
    call DestroyBoolExpr(e)
    // more codes
    set e = null
endfunction

function HasVehicleValue takes nothing returns boolean
    return GetUnitAbilityLevel(GetFilterUnit(), 'A002') != 0
endfunction

JassCraft is returning an error message saying Undefined function on the local boolexpr e = Condition(function HasVehicleValue) line.
Oh and, what does the message mean?

What is wrong :S? Maybe I might have missed something...

/regards
 
Level 11
Joined
Feb 18, 2004
Messages
394
Undefined function means that the syntax checker can not find the function.

It works just fine if you order it the other way, as such:

JASS:
function HasVehicleValue takes nothing returns boolean
    return GetUnitAbilityLevel(GetFilterUnit(), 'A002') != 0
endfunction

function InitVehicles takes nothing returns nothing
    local group g = CreateGroup()
    local boolexpr e = Condition(function HasVehicleValue)
    call GroupEnumUnitsOfPlayer(g, Player(15), e)
    call DestroyBoolExpr(e)
    // more codes
    set e = null
endfunction

Also, don't use JASS Craft, use NewGen... (Includes syntax highlighting in the trigger editor itself, prevents the editor from crashing, etc.)
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
I though Jasscraft was good... It have all those native function which you easily can cooperate with.

I have no idea how it is with Newgen... Ill find it right away.

Anyway thanks =)

"I cant rep you again"^.^
 
Level 11
Joined
Feb 18, 2004
Messages
394
http://wc3campaigns.net/showthread.php?t=90999

to get the function finder on the side and below the editing part of a custom-text trigger (like in JASSCraft), minimize it. (You can open the function finder window by pressing the "Function List" button that appears on a custom text trigger.)

CTRL+Click any function to open that functions definition in the function finder.
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
Same function, Another issue.

Okay so here comes my next problem.

it says everything is fine when looking at the code:
JASS:
globals
    real array udg_setX
    real array udg_setY
    real array udg_setF
constant integer VEHICLE_VALUE = 'A002' //custom value ability for vehicles
endglobals
function HasVehicleValueA takes nothing returns boolean
    return GetUnitAbilityLevel(GetFilterUnit(), VEHICLE_VALUE) != 0
endfunction
function InitVehicles takes nothing returns nothing
    local integer i = 0
    local group g = CreateGroup()
    local unit u
    local boolexpr e = Condition(function HasVehicleValueA) 
    call GroupEnumUnitsOfPlayer(g, Player(15), e)
    loop
        set u = FirstOfGroup(g)
        exitwhen g == null
        call GroupRemoveUnit(g,u)
        set udg_setX[i] = GetUnitX(u)
        set udg_setY[i] = GetUnitY(u)
        set udg_setF[i] = GetUnitFacing(u)
        call SetUnitAbilityLevel(u, VEHICLE_VALUE, i+2)
        set i = i+1
    endloop
    call DestroyBoolExpr(e)
    set e = null
    set u = null
endfunction

But when I use newgen and tests the map, it displays a red debug message saying:
Hit op limit in InitVehicles()

So what does that mean, and how do you fix it?

Also, I thought it was possible to run a function by using the code call InitVehicles()

I get an error message shutting the down the game when loading the map that way,
so I had to use
call ExcecuteFunc("InitVehicles")

But thats what I should right?
 
Level 9
Joined
Mar 25, 2005
Messages
252
Didn't test this but should work:
JASS:
globals
    real array udg_setX
    real array udg_setY
    real array udg_setF
constant integer VEHICLE_VALUE = 'A002' //custom value ability for vehicles
endglobals
function HasVehicleValueA takes nothing returns boolean
    return GetUnitAbilityLevel(GetFilterUnit(), VEHICLE_VALUE) != 0
endfunction
function InitVehicles takes nothing returns nothing
    local integer i = 0
    local group g = CreateGroup()
    local unit u

    // no need to destroy boolexprs (except those created with And(), Or() or Not()) so no need to store them either
    call GroupEnumUnitsOfPlayer(g, Player(15), Condition(function HasVehicleValueA)) 
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null // fix
        call GroupRemoveUnit(g,u)
        set udg_setX[i] = GetUnitX(u)
        set udg_setY[i] = GetUnitY(u)
        set udg_setF[i] = GetUnitFacing(u)
        call SetUnitAbilityLevel(u, VEHICLE_VALUE, i+2)
        set i = i+1
    endloop
    call DestroyGroup(g)
    set g = null
    set u = null
endfunction

Looking at the original code it seems like you were assuming that the group becomes null when there are no units in it. That is not the case.

Also, I thought it was possible to run a function by using the code call InitVehicles()

I get an error message shutting the down the game when loading the map that way,

When you hit the op limit in a library initializer, InitTrig or the like the game shuts down, elsewhere JNPG kicks in, gives you an error message and the game goes on.
 
Level 6
Joined
Sep 4, 2007
Messages
157
hmm thats odd i just tryed it in my map to see what happens and it works just fine for me didnt crash or give me an error. I dont know if you used a normal trigger i added it to the custom script part of the triggers and use
JASS:
call InitVehicles()
and it worked fine for me
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
DiscipleOfLife said:
Didn't test this but should work:
JASS:
globals
    real array udg_setX
    real array udg_setY
    real array udg_setF
constant integer VEHICLE_VALUE = 'A002' //custom value ability for vehicles
endglobals
function HasVehicleValueA takes nothing returns boolean
    return GetUnitAbilityLevel(GetFilterUnit(), VEHICLE_VALUE) != 0
endfunction
function InitVehicles takes nothing returns nothing
    local integer i = 0
    local group g = CreateGroup()
    local unit u

    // no need to destroy boolexprs (except those created with And(), Or() or Not()) so no need to store them either
    call GroupEnumUnitsOfPlayer(g, Player(15), Condition(function HasVehicleValueA)) 
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null // fix
        call GroupRemoveUnit(g,u)
        set udg_setX[i] = GetUnitX(u)
        set udg_setY[i] = GetUnitY(u)
        set udg_setF[i] = GetUnitFacing(u)
        call SetUnitAbilityLevel(u, VEHICLE_VALUE, i+2)
        set i = i+1
    endloop
    call DestroyGroup(g)
    set g = null
    set u = null
endfunction

Looking at the original code it seems like you were assuming that the group becomes null when there are no units in it. That is not the case.

When you hit the op limit in a library initializer, InitTrig or the like the game shuts down, elsewhere JNPG kicks in, gives you an error message and the game goes on.

Oh damn I saw that now-.- I didn't assume that the group becomes null. It was accidentally set exitwhen == g instead of u. I just didn't see it with my own eyes >.<

Oh and yea, I see, Ive never knew when I should use boolexpr anyway. Thanks that both you and DSG made that clear for me.

b_a_d nope its written in newgen via "custom script". But yea it could be, just like Diciple said, about the op limit.
---

Yep its working now=) thanks alot folks
 
Status
Not open for further replies.
Top