HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Where's the error coming from?

11-10-2006, 03:08 AM#1
darkwulfv
Collapse JASS:
function Eat_Conditions takes nothing returns boolean
  return (GetSpellAbilityId() == 'A003')
endfunction

function If_Conditions takes nothing returns boolean
    return ( udg_i != 1 )
    return ( GetUnitState(GetEnumUnit(), UNIT_STATE_LIFE) > .405 )
endfunction

function Group_Actions takes nothing returns nothing
  local unit u = GetTriggerUnit()
  local unit u2  
    if ( function If_Conditions ) then
      set u2 = CreateUnit( GetOwningPlayer(u), 'e000', GetUnitX(u), GetUnitY(u), 270.0 )
        call IssueTargetOrder( u2, "firebolt", u)
        call RemoveUnit(u2)
        set udg_i = 1
    else
        call PauseUnit(u, true )
        call IssueImmediateOrder(u, "stop" )
        call PauseUnit(u, false )
  endif
set u = null
set u2 = null
endfunction

function Eat_Actions takes nothing returns nothing
  local group g = CreateGroup()
  local unit u = GetTriggerUnit()
  local location l = GetUnitLoc(u)
  local real x = GetLocationX(l)
  local real y = GetLocationY(l)
  local rect r = RectFromCenterSizeBJ(l, 20.0, 20.0)
set g = GetUnitsInRectAll(r)
    call ForGroup( g, function Group_Actions )
endfunction

It's telling me that the line with "endif" has an error "Cannot convert code to boolean. Can anyone tell me why it's doing this? It seems ok to me... And yes, there are some leaks and stuff. I intend on patching those as soon as I figure out what's bugging up.
11-10-2006, 07:50 AM#2
[VDM]Amn
if the boolean variant is the problem
u can always use 0 and 1 for a boolean
am i right?
11-10-2006, 08:11 AM#3
Wyvernoid
if ( function If_Conditions ) then This sentence is wrong. "function If_Conditions" is a variable of the type "code", but the statement "if" needs a boolean variable. Change it to this:
if ( If_Conditions() ) then And the "If_Conditions()" executes the function and returns a boolean variable. Then your trigger go right.

BTW, this trigger
Collapse JASS:
function If_Conditions takes nothing returns boolean
    return ( udg_i != 1 )
    return ( GetUnitState(GetEnumUnit(), UNIT_STATE_LIFE) > .405 )
endfunction
The second return does nothing. What do you mean by writing these two statements?
11-10-2006, 09:58 AM#4
Freakazoid
Sorry for the off-topic but your back ? , it hasn't been 3 years, and thats me at one point in your sig x)
11-10-2006, 11:05 AM#5
blu_da_noob
Keep it on topic please. We do have a forum dedicated to the rest. And the problem seems to have been solved.
11-10-2006, 02:09 PM#6
darkwulfv
Quote:
The second return does nothing. What do you mean by writing these two statements?
Those returns are to check that I isn't equal to one, and that the picked unit (these conditions take place in a loop) is dead.... ooops. I should switch that to less than. It's for an eating ability, and its used to detect corpses, and add the mana regen that comes with the ability. It can only detect one, or it will bug up, hence why theres a return to make sure that I isn't equal to one. I might change it to I < 1...
Thanks for your help, I wouldn't have caught that one myself.
EDIT: Yup, I just saved and it parses correctly. I'll have to remember this for later.
11-10-2006, 02:35 PM#7
The)TideHunter(
Quote:
Originally Posted by darkwulfv
Those returns are to check that I isn't equal to one, and that the picked unit (these conditions take place in a loop) is dead.... ooops. I should switch that to less than. It's for an eating ability, and its used to detect corpses, and add the mana regen that comes with the ability. It can only detect one, or it will bug up, hence why theres a return to make sure that I isn't equal to one. I might change it to I < 1...
Thanks for your help, I wouldn't have caught that one myself.
EDIT: Yup, I just saved and it parses correctly. I'll have to remember this for later.

You shouldent have 2 return lines in a function really for what you want.
If Wc3's parser sees a return when its using it, it will not read the rest of the function.
So the seconds return does nothing atall but waste memory.

If you want to check them both, use:

Collapse JASS:
function If_Conditions takes nothing returns boolean
    return ((udg_i != 1) and (GetUnitState(GetEnumUnit(), UNIT_STATE_LIFE) > .405))
endfunction
11-10-2006, 10:12 PM#8
darkwulfv
ahh, thanks for that. I'll remeber that one too.