• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Dumb bug

Status
Not open for further replies.
Level 8
Joined
Aug 4, 2006
Messages
357
Hey everyone. I just started learning JASS today so forgive me if this is a dumb question. Why won't this line of code compile properly?

"set udg_allPlayers = GetPlayersMatching(Condition(GetPlayerController(GetFilterPlayer()) == MAP_CONTROL_USER AND GetPlayerSlotState(GetFilterPlayer()) == PLAYER_SLOT_STATE_PLAYING))"

In World Editor, it says "Expected ' ". Using JassCraft says there's a syntax error, along with 12 "Statement outside of function" errors.

Also, what is the difference between a boolean and boolexpr?

Thanks,
 
Level 5
Joined
Dec 20, 2008
Messages
67
boolexpr must be a function which returns boolean ...


function PlayerFilter takes nothing returns boolean
return GetPlayerController(GetFilterPlayer()) == MAP_CONTROL_USER AND GetPlayerSlotState(GetFilterPlayer()) == PLAYER_SLOT_STATE_PLAYING
endfunction

...
set udg_allPlayers = GetPlayersMatching(Condition(function PlayerFilter))
 
Level 8
Joined
Aug 4, 2006
Messages
357
thanks for trying to help, but i pasted exactly what you wrote into JassCraft (without the "..." of course), and it still came up with 4 errors.

1 function PlayerFilter takes nothing returns boolean
2 return GetPlayerController(GetFilterPlayer()) == MAP_CONTROL_USER AND GetPlayerSlotState(GetFilterPlayer()) == PLAYER_SLOT_STATE_PLAYING
3 endfunction
4
5 set udg_allPlayers = GetPlayersMatching(Condition(function PlayerFilter))

Line 2: syntax error
Line 3: Return types not correct or nonexistant returns
Line 5: syntax error
Line 5: Statement outside of function
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
"and" must not be with capital letters.
Making the code like this:
JASS:
function PlayerFilter takes nothing returns boolean
    return GetPlayerController(GetFilterPlayer()) == MAP_CONTROL_USER and GetPlayerSlotState(GetFilterPlayer()) == PLAYER_SLOT_STATE_PLAYING
endfunction
 
Status
Not open for further replies.
Top