Boolean Compile Error

D

dArKzEr0

Guest
Code:
call ForGroupBJ( GetUnitsInRangeOfLocMatching( 600, casterPoint, Condition(GetBooleanAnd( (IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), GetOwningPlayer(casterUnit))==true) , (IsUnitAliveBJ(GetFilterUnit())==true))) ))

I'm getting a compile error "Invalid argument type (boolean)" and I can't figure out why, anyone care to provide a bit of insight?

-darks
 
D

Dino.pl

Guest
It must be Condition(function xxx)
And function xxx must return a boolean.

And it's faster to use and instead of GetBooleanAnd
Code:
function GetBooleanAnd takes boolean valueA, boolean valueB returns boolean
    return valueA and valueB
endfunction
And you don't have to write ==true.
And it's much faster to use
Code:
GetUnitState(whichUnit, UNIT_STATE_LIFE) > 0
instead of
Code:
IsUnitAliveBJ
Hmm, was I helpful?
 
D

dArKzEr0

Guest
Ya, thanks a lot. Can you have locals in a function defined before the boolean function inside the function?

Code:
function WithinRangeAndAlive takes nothing returns boolean
   return GetBooleanAnd(IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), GetOwningPlayer([I][B]casterUnit[/B][/I])), IsUnitAliveBJ(GetFilterUnit())
endfunction

If not, how do I get around that?

Also, could you explain (if you know) why you have to use a function (why my method didn't work)?

-darkz
 

SFilip

Gone but not forgotten
Reaction score
634
because Condition must take function as its parameter i suppose.

> And you don't have to write ==true.
you dont have to, but its recommended that you do. acehart and phyrex1an mentioned that some functions dont work well if you dont use == true or == false.
 

emjlr3

Change can be a good thing
Reaction score
395
if in the same function, something like

Code:
IsUnitEnemy(unit,player)

works fine

however if its in another function, and u use it as a boolexpr

you should do

Code:
IsUnitEnemy(unit,player)==true/false

it bugs sometimes, duno y

that is my general rule of thumb
 
D

Dino.pl

Guest
> acehart and phyrex1an mentioned that some functions dont work well if you dont use == true or == false.
But some do.

> Ya, thanks a lot. Can you have locals in a function defined before the boolean function inside the function?
You can have locals at the beggining of every function.
 

SFilip

Gone but not forgotten
Reaction score
634
> But some do.
is it so hard to simply write == true every time you check some boolean? i think it isn't.
 
D

Dino.pl

Guest
> is it so hard to simply write == true every time you check some boolean? i think it isn't.
I don't write it in PHP, so I don't write it in JASS.
If something doesn't work, I add == true.
 
D

dArKzEr0

Guest
Dino.pl said:
> Ya, thanks a lot. Can you have locals in a function defined before the boolean function inside the function?
You can have locals at the beggining of every function.

I think you misunderstood, or maybe I wasn't clear.
What I meant was, can you use a local variable in the boolexpr that is defined in the main function?

function
boolexpr( localvariable )
endfucntion

function
local localvariable
endfunction

I assume the answer is no. What I'm looking for is an alternative. Can I set the function to "take unit" so that I call "WithinRangeAndAlive(casterUnit)" and it uses the local where it's supposed to be? I hope I'm making sense...

Forgive the noobness, I know a fair bit of Java, but this is the first time I attempt to use JASS, and the syntax is not nearly as nice.

-darkz
 

SFilip

Gone but not forgotten
Reaction score
634
Dino.pl said:
> is it so hard to simply write == true every time you check some boolean? i think it isn't.
I don't write it in PHP, so I don't write it in JASS.
If something doesn't work, I add == true.
PHP != JASS
its diffrent. i dont use == true in php, i dont use = true in pascal yet i do in jass. your choice though...better to write it always than making yourself wonder one day why the hell this condition wont work.
 
D

dArKzEr0

Guest
I tried this:

Code:
function IsEnemy takes unit casterUnit returns boolean
   return ( IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), GetOwningPlayer(casterUnit))==true)
endfunction

function IsAlive takes nothing returns boolean
   return ( IsUnitAliveBJ(GetFilterUnit())==true )
endfunction

function IsEnemyAndAlive takes unit casterUnit returns boolean
   return GetBooleanAnd(IsEnemy(casterUnit), IsAlive())
endfunction

function
   local unit casterUnit = XXXX
   ...
   call ForGroupBJ(GetUnitsInRangeOfLocMatching( 600, casterPoint, Condition(IsEnemyAndAlive(casterUnit)) ))
   ...
endfunction

And I'm getting the same "Invalid argument type (boolean)" compile error.

-darkz
 
D

Dino.pl

Guest
> What I meant was, can you use a local variable in the boolexpr that is defined in the main function?
Why don't you test yourself?

> I assume the answer is no.
Gratz!

> What I'm looking for is an alternative. Can I set the function to "take unit" so that I call "WithinRangeAndAlive(casterUnit)" and it uses the local where it's supposed to be?
If you mean something like that, the answer is "yes, you can!" (but again, why don't you test yourself?)
Code:
function saySoaD takes string s returns nothing
    call BJDebugMsg(s)
endfunction

function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing 
    local string txt = "System of a Down rox!"
    call saySoaD(txt)
endfunction

function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_001 = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Untitled_Trigger_001, 2 )
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction
EDIT:
> And I'm getting the same "Invalid argument type (boolean)" compile error.
Dino.pl said:
It must be Condition(function xxx)
And function xxx must return a boolean.
It must be
Condition(function IsEnemyAndAlive(casterUnit))
, not
Condition(IsEnemyAndAlive(casterUnit))
.
 
D

dArKzEr0

Guest
Dino.pl said:
> What I meant was, can you use a local variable in the boolexpr that is defined in the main function?
Why don't you test yourself?

> I assume the answer is no.
Gratz!

> What I'm looking for is an alternative. Can I set the function to "take unit" so that I call "WithinRangeAndAlive(casterUnit)" and it uses the local where it's supposed to be?
If you mean something like that, the answer is "yes, you can!" (but again, why don't you test yourself?)
Code:
function saySoaD takes string s returns nothing
    call BJDebugMsg(s)
endfunction

function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing 
    local string txt = "System of a Down rox!"
    call saySoaD(txt)
endfunction

function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_001 = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Untitled_Trigger_001, 2 )
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction


Hmm... seems your genius-like wit was about 20 seconds too late. I tested everything myself. Gratz! to me, but it still isn't working.

-darkz

Edit://
>> And I'm getting the same "Invalid argument type (boolean)" compile error.
>Quote:
>Originally Posted by Dino.pl
>It must be Condition(function xxx)
>And function xxx must return a boolean.

Dude, I tried doing that. IsEnemyAndAlive(unit) is a function.
 

SFilip

Gone but not forgotten
Reaction score
634
return GetBooleanAnd(IsWithinRange(casterUnit), IsAlive())
i dont think you can call it that way...try
return GetBooleanAnd(Condition(function IsWithinRange), Condition(IsAlive))
yet the problem here is that you cant transfer casterUnit. however you can define it in that function as long as its a part of the original trigger.
local casterUnit = GetSpellAbilityUnit()
 
D

Dino.pl

Guest
Don't listen to SFilip, it doesn't make sense :)
(look at my edit)
 
D

dArKzEr0

Guest
@SFilip
I tried what you said and a few variations of it and I got a plethora of syntax errors each time.

@Dino.pl
I tried this:

Code:
function IsEnemy takes unit casterUnit returns boolean
   return ( IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), GetOwningPlayer(casterUnit))==true)
endfunction

function IsAlive takes nothing returns boolean
   return ( IsUnitAliveBJ(GetFilterUnit())==true )
endfunction

function IsEnemyAndAlive takes unit casterUnit returns boolean
   return GetBooleanAnd(IsEnemy(casterUnit), IsAlive())
endfunction

function
   ...
   local unit casterUnit
   ...
   call ForGroupBJ(GetUnitsInRangeOfLocMatching( 600, casterPoint, Condition(function IsEnemyAndAlive(casterUnit)) ))
   ...
endfunction

and I got: " Expected ' " compile error

So I changed the main function to:

Code:
function
   ...
   local unit casterUnit
   ...
   call ForGroupBJ(GetUnitsInRangeOfLocMatching( 600, casterPoint, Condition(function 'IsEnemyAndAlive(casterUnit)') ))
   ...
endfunction

and I got: " Expected a function name " compile error

I misunderstood earlier because I thought you were using "function" as a variable.

-darkz

Edit://
I also tried this:

Code:
function IsEnemy takes nothing returns boolean
   local unit casterUnit = GetSpellAbilityUnit()
   return ( IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), GetOwningPlayer(casterUnit))==true)
endfunction

function IsAlive takes nothing returns boolean
   return ( IsUnitAliveBJ(GetFilterUnit())==true )
endfunction

function IsEnemyAndAlive takes nothing returns boolean
   return GetBooleanAnd(IsEnemy(), IsAlive())
endfunction

function
   ...
   local unit casterUnit
   ...
   call ForGroupBJ(GetUnitsInRangeOfLocMatching( 600, casterPoint, Condition(function 'IsEnemyAndAlive') ))
   ...
endfunction

Edit2://
and still got "expected function name"

So I changed the main function to:
Code:
function
   ...
   local unit casterUnit
   ...
   call ForGroupBJ(GetUnitsInRangeOfLocMatching( 600, casterPoint, Condition(function IsEnemyAndAlive) ))
   ...
endfunction

and I got "invalid number of arguments"

This damned boolexpr does not like me.
 
D

Dino.pl

Guest
You have no function name in your main function :D
And you don't need the '
 
D

dArKzEr0

Guest
dArKzEr0 said:
So I changed the main function to:
Code:
function
   ...
   local unit casterUnit
   ...
   call ForGroupBJ(GetUnitsInRangeOfLocMatching( 600, casterPoint, Condition(function IsEnemyAndAlive) ))
   ...
endfunction

and I got "invalid number of arguments"

This damned boolexpr does not like me.

I checked the arguments of GetUnitsInRangeOfLocMatching() and I have them right.

"This damned boolexpr does not like me."

-darkz
 

SFilip

Gone but not forgotten
Reaction score
634
lol i though you just weren't writing the function's name here...well it must be
function <name> takes nothing returns nothing
in order to work

and if return GetBooleanAnd(IsEnemy(casterUnit), IsAlive()) works then return GetBooleanAnd(IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), GetOwningPlayer(casterUnit))==true, IsUnitAliveBJ(GetFilterUnit())==true) should work aswell. then you will only need one function.
 
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