• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] "Expected" Errors

Status
Not open for further replies.
Level 6
Joined
Aug 27, 2008
Messages
210
Here is my triggers, im making a map where it will track the mouse wherever i place neutral passive units (please dont question this idea), if any1 can help, pls respond
PHP:
globals
trackable array udg_trackables
location array udg_trackablepoints
trigger udg_MouseTrig
real udg_X
real udg_Y
integer udg_trackablenum
endglobals

fuction Trig_MouseTriggerActions takes nothing returns nothing
local integer int = 1
loop
    exitwhen int == trackablenum
    if GetTriggeringTrackable() == udg_trackables[int] then
        set udg_X = GetLocationX(udg_trackablepoints[int])
        set udg_Y = GetLocationY(udg_trackablepoints[int])
    endif
    set int = int + 1
endloop
endfunction

function InitTrig_MouseTrigger takes nothing returns nothing
set udg_MouseTrig = CreateTrigger()
local group trackableus GroupEnumUnitsOfPlayer(CreateGroup(), Player(PLAYER_NEUTRAL_PASSIVE), true)
loop
    local integer int 1
    local unit first FirstOfGroup(trackableus)
    exitwhen unit == "null"
                                           //(haven't put model here yet)
    set udg_trackables[int] = CreateTrackable("", GetLocationX(GetUnitLoc(first)), GetLocationX(GetUnitLoc(first)), GetRandomInt(0, 360))
    set udg_trackablepoints[int] = GetUnitLoc(first)
    call GroupRemoveUnit(trackableus, first)
    call RemoveUnit(first)
    call TriggerRegisterTrackableTrackEvent(udg_MouseTrig, udg_trackables[int])
    set int = int + 1
endloop
set trackablenum = int
set int = "null
set first = "null"
call TriggerAddAction(udg_MouseTrig, function Trig_MouseTriggerActions)
endfunction
 
Level 6
Joined
Aug 27, 2008
Messages
210
Well, thnx, i fixed that, but that's not all, for the first 10 lines it says "Expected end of line."
PHP:
globals
trackable array udg_trackables
location array udg_trackablepoints
trigger udg_MouseTrig
real udg_X
real udg_Y
integer udg_trackablenum
endglobals

fuction Trig_MouseTriggerActions takes nothing returns nothing
local integer int = 1
loop
    exitwhen int == trackablenum
    if GetTriggeringTrackable() == udg_trackables[int] then
        set udg_X = GetLocationX(udg_trackablepoints[int])
        set udg_Y = GetLocationY(udg_trackablepoints[int])
    endif
    set int = int + 1
endloop
endfunction

function InitTrig_MouseTrigger takes nothing returns nothing
set udg_MouseTrig = CreateTrigger()
local group trackableus GroupEnumUnitsOfPlayer(CreateGroup(), Player(PLAYER_NEUTRAL_PASSIVE), true)
local integer int 1
loop
    local unit first FirstOfGroup(trackableus)
    exitwhen unit == null
    set udg_trackables[int] = CreateTrackable("", GetLocationX(GetUnitLoc(first)), GetLocationX(GetUnitLoc(first)), GetRandomInt(0, 360))
    set udg_trackablepoints[int] = GetUnitLoc(first)
    call GroupRemoveUnit(trackableus, first)
    call RemoveUnit(first)
    call TriggerRegisterTrackableTrackEvent(udg_MouseTrig, udg_trackables[int])
    set int = int + 1
endloop
set trackablenum = int
set int = null
set first = null
call TriggerAddAction(udg_MouseTrig, function Trig_MouseTriggerActions)
endfunction
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
Well, you missed alot;)

In the first function, it should be:

function Trig_MouseTriggerActions takes nothing returns nothing
since, you wrote fuction.

exitwhen int == trackablenum
does not work. You have no variable called that. Add udg_trackablenum and it will be fine

In the second function you hae to fix the following:

set udg_MouseTrig = CreateTrigger()
which can't be placed before locals. Create it after the locals.

local group trackableus GroupEnumUnitsOfPlayer(CreateGroup(), Player(PLAYER_NEUTRAL_PASSIVE), true)
you forgot a = syntax. The correct line should be
local group trackableus = GroupEnumUnitsOfPlayer(CreateGroup(), Player(PLAYER_NEUTRAL_PASSIVE), true)

local integer int 1
the same goes here, add =

local unit first FirstOfGroup(trackableus)
you CANNOT create locals inside a loop. Locals must be placed first, at the beginning of the function. And you also miss a = sign here.

exitwhen unit == null
doesnt work, correction: exitwhen first == null

set int = null
you cannot set an integer to null. If you want to reset the int, set it to 0. Though, you dont have to do that for integers... just remove the line.

set first = null
is not really needed as well. You already have exitwhen first == null which means the variable will be nulled.

That should be all I guess... If you have more issues paste the new code back, but its better if you use
JASS:
tags instead.

~Eccho~

Edit: I forgot one:
set trackablenum = int
same as before, change it to udg_trackablenum
 
Level 6
Joined
Aug 27, 2008
Messages
210
OK, i fixed all that, here's the new code, plus the errors it says i have:
PHP:
globals //Expected end of line
trackable array udg_trackables //Expected end of line
location array udg_trackablepoints //Expected end of line
trigger udg_MouseTrig //Expected end of line
real udg_X //Expected end of line
real udg_Y //Expected end of line
integer udg_trackablenum //Expected end of line
endglobals

function Trig_MouseTriggerActions takes nothing returns nothing
local integer int = 1
loop
    exitwhen int == udg_trackablenum //Expected a name
    if GetTriggeringTrackable() == udg_trackables[int] then //Expected a name
        set udg_X = GetLocationX(udg_trackablepoints[int]) //Expected a variable name
        set udg_Y = GetLocationY(udg_trackablepoints[int]) //Expected a variable name
    endif //Expected 'endloop'
    set int = int + 1
endloop
endfunction

function InitTrig_MouseTrigger takes nothing returns nothing
local group trackableus = GroupEnumUnitsOfPlayer(CreateGroup(), Player(PLAYER_NEUTRAL_PASSIVE), true) //Invalid argument type (boolean), Expected ')' (boolean)
local integer int = 1
set udg_MouseTrig = CreateTrigger() //Expected a variable name (boolean), Expected a code statement (boolean)
local unit first
loop
    set first = FirstOfGroup(trackableus) //Expected a variable name (boolean)
    exitwhen first == null //Expected a name (boolean)
    set udg_trackables[int] = CreateTrackable("", GetLocationX(GetUnitLoc(first)), GetLocationX(GetUnitLoc(first)), GetRandomInt(0, 360)) //Expected a variable name (boolean)
    set udg_trackablepoints[int] = GetUnitLoc(first) //Expected a variable name (boolean)
    call GroupRemoveUnit(trackableus, first) //Expected a name (boolean)
    call RemoveUnit(first) //Expected a name (boolean)
    call TriggerRegisterTrackableTrackEvent(udg_MouseTrig, udg_trackables[int]) //Expected a name (boolean)
    set int = int + 1 //Expected a variable name (boolean)
endloop
set udg_trackablenum = int //Expected a variable name (boolean)
call TriggerAddAction(udg_MouseTrig, function Trig_MouseTriggerActions) //Expected a name (boolean)
endfunction
// And forever afterwards it says "Expected 'endloop' (boolean)"
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
JASS:
local integer int = 1 
set udg_MouseTrig = CreateTrigger() //Expected a variable name (boolean), Expected a code statement (boolean) 
local unit first 
loop 
...

This is still not right. The last local must be placed before the set udg_MouseTrig....

Also, Poot is probably right. If you dont have Newgen you cant create global blocks like that. In that case you have to do like you usually do when you create a variable in the normal world editor.

I also meant use
JASS:
 tags instead of PHP ones. It doesnt matter that much though
 
Level 6
Joined
Sep 13, 2008
Messages
261
OK, got Newgen, now it just says errors on this line: Can't convert boolean to boolexpr, and can't convert nothing to group.
JASS:
local group trackableus = GroupEnumUnitsOfPlayer(CreateGroup(), Player(PLAYER_NEUTRAL_PASSIVE), true)

You need to replace the word true with a boolexpr.
Boolexpr
Thats a link I found if you need more info the first part should help.
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
Also, sorry for not pointing that out, but I didnt see it first

local group trackableus = GroupEnumUnitsOfPlayer(CreateGroup(), Player(PLAYER_NEUTRAL_PASSIVE), true)

Cannot convert boolean to boolexpr has howl already explained. You need to replace it with a boolexpr. An example of a function used as a boolexpr could be this one:
JASS:
function AntiLeak_True takes nothing returns boolean
 return true
endfunction
Instead of writing "true" like you did, write Filter(function AntiLeak_True) or Condition(function AntiLeak_True) . There are no huge difference by these two... they both extends a boolexpr.

Now it would still say: Cant convert nothing to group. The reason is because the GroupEnumUnitsOfPlayer function takes some parameters but doesnt return any.
So, if you want to do it right it would be:
PHP:
local group trackableus = CreateGroup()
call GroupEnumUnitsOfPlayer(trackableus, Player(PLAYER_NEUTRAL_PASSIVE), Filter(function AntiLeak_True))
 
Status
Not open for further replies.
Top