HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

"Cannot Convert Boolean to Boolexpr" Error

03-19-2008, 08:01 PM#1
Salbrismind
Collapse JASS:
call GroupEnumUnitsInRange(engroup, ax, ay, 250, IsPlayerEnemy(GetOwningPlayer(GetEnumUnit()), GetOwningPlayer(GetSpellAbilityUnit())) == true)

I need some help, why is this giving me the error: "Cannot Convert Boolean to Boolexpr"?

Thanks in advance.
03-19-2008, 08:10 PM#2
Troll-Brain
a boolexper is a function with no argument (takes nothing) and returns a boolean

So you need to use globals or the cache for use your conditions.
also you can use only one boolexpr
03-19-2008, 08:12 PM#3
Ammorth
You need to stick the boolean check in a function which returns a boolean and then use Condition(function FunctionName) to get the boolexpr
03-19-2008, 08:12 PM#4
Rising_Dusk
A boolean is not a boolexpr. You'd need to do it like this:
Expand JASS:
03-19-2008, 08:17 PM#5
Salbrismind
Wow, am I getting worse at this or what? Thank you guys, it may seem like I don't know what I'm doing but you just helped me pass another stepping stone to vJass mastery. Also thank you all for your quick posts!

Edit:
Quote:
Originally Posted by Rising_Dusk
A boolean is not a boolexpr. You'd need to do it like this:
Expand JASS:

Sorry for posting so quick without reading your code, but why did you use "set bj_meleeNearestMine = ..." I tried compiling without it and it still worked.
03-19-2008, 08:23 PM#6
Troll-Brain
there is no VJass here :p
03-20-2008, 04:18 AM#7
Pyrogasm
He used bj_meleeNearestMine as a global variable to pass the unit which cast the spell to the boolexpr function. He could have easily wrote either of the following two instead:
Collapse JASS:
globals
    private unit U
endglobals

function MyBoolExpr takes nothing returns boolean
    return IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), GetOwningPlayer(U))
endfunction

function Rawr takes nothing returns nothing
    local boolexpr b = Condition(function MyBoolExpr)
    // Declare other variables
    
    set U = GetSpellAbilityUnit()
    call GroupEnumUnitsInRange(engroup, ax, ay, 250, b)
endfunction
Or, the optimized way:
Collapse JASS:
globals
    private player P
endglobals

function MyBoolExpr takes nothing returns boolean
    return IsUnitEnemy(GetFilterUnit(), P)
endfunction

function Rawr takes nothing returns nothing
    local boolexpr b = Condition(function MyBoolExpr)
    // Declare other variables
    
    set P = GetOwningPlayer(GetTriggerUnit())
    call GroupEnumUnitsInRange(engroup, ax, ay, 250, b)
endfunction
03-20-2008, 10:20 AM#8
Rising_Dusk
I don't like player variables, too many bad memories of Player(-1).
03-20-2008, 01:46 PM#9
Anitarf
You still could have used the IsUnitEnemy native instead of IsPlayerEnemy, though. :)
03-20-2008, 07:45 PM#10
Rising_Dusk
Hey, I just copied and pasted what was in his original function, lay off! :(
03-20-2008, 07:47 PM#11
Salbrismind
Quote:
Originally Posted by Anitarf
You still could have used the IsUnitEnemy native instead of IsPlayerEnemy, though. :)

Oh, I'll do that. I never knew that existed because this was Gui converted code.