• 🏆 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!

[Solved] Help with error (local unit u)

Status
Not open for further replies.
Level 11
Joined
Oct 9, 2015
Messages
721
I'm getting this error (image) when I try to use the custom script: local unit u

can anyone help me, please?
 

Attachments

  • 2017-03-28.png
    2017-03-28.png
    3.8 MB · Views: 74
Level 7
Joined
Mar 10, 2013
Messages
366
Corrected syntax, same error:
First, it's not the same error, it's another error.
It's expecting a endif statement after your declaration.
JASS:
[...]
else
    local unit u
endif

I don't want to be rude but, seriously, you really can't read the compilation errors?
 
Level 7
Joined
Mar 10, 2013
Messages
366
I didn't saw the difference on them, sorry. I'm using gui and trying to implement a unit recycler on my map but I'm having no success.

See the red square. It's trying to help you with the bugs you're having, that's the use of the compiler, point you syntax errors.
I don't know if you're familiar with programming languages or the problem is with JASS itself. Either way, I suggest you give it a try and read about it a bit.

If you're using GUI these syntax errors don't make much sense. Can you show the whole trigger you're trying to do? Maybe it will make it more easy to help.
 

Attachments

  • Screenshot (3).png
    Screenshot (3).png
    281.5 KB · Views: 35
Level 23
Joined
Feb 6, 2014
Messages
2,466
Also, local variables can only be declared at the top of the functions. Example
Correct:
JASS:
function foo takes nothing returns nothing
    local unit f
    local integer o
    call BJDebugMsg("bar")
endfunction

Incorrect:
JASS:
function foo takes nothing returns nothing
    local unit f
    call BJDebugMsg("bar")
    local integer o //must go before any function calls or if statements
endfunction
 
Status
Not open for further replies.
Top