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

[Solved] "Missing end block" compilation error

Status
Not open for further replies.
Level 12
Joined
Nov 3, 2013
Messages
989
I can't seem to find where the missing end block is...

When I disabled this trigger it disappeared so it's somewhere here.

All it's supposed to do is split all 12 players + 3 neutrals into 3 teams.

JASS:
function Trig_Map_Inital_Player_Team_Settings_Actions takes nothing returns nothing
    local integer i = 0
    local integer j
    local player p
    loop
        exitwhen i > 14
        p = Player(i)
        j = 0
        if ModuloInteger(i, 3) == 0 then                                    // team 0
            call ForceAddPlayer( udg_mapInit_playerG_team[0], p )
            loop
                if j == i then j = j + 1 endif
                exitwhen j > 14
                if ModuloInteger(j, 3) == 0 then
                    call SetPlayerAllianceStateBJ( p, Player(j), bj_ALLIANCE_ALLIED_VISION )
                else
                    call SetPlayerAllianceStateBJ( p, Player(j), bj_ALLIANCE_UNALLIED )
                endif
                set j = j + 1
            endloop
        elseif ModuloInteger(i, 3) == 1 then                                //Team 1
            call ForceAddPlayer( udg_mapInit_playerG_team[1], p )
            loop
                if j == i then j = j + 1 endif
                exitwhen j > 14
                if ModuloInteger(j, 3) == 1 then
                    call SetPlayerAllianceStateBJ( p, Player(j), bj_ALLIANCE_ALLIED_VISION )
                else
                    call SetPlayerAllianceStateBJ( p, Player(j), bj_ALLIANCE_UNALLIED )
                endif
                set j = j + 1
            endloop
        elseif ModuloInteger(i, 3) == 2 then                                //team 2
            call ForceAddPlayer( udg_mapInit_playerG_team[2], p )
            loop
                if j == i then j = j + 1 endif
                exitwhen j > 14
                if ModuloInteger(j, 3) == 2 then
                    call SetPlayerAllianceStateBJ( p, Player(j), bj_ALLIANCE_ALLIED_VISION )
                else
                    call SetPlayerAllianceStateBJ( p, Player(j), bj_ALLIANCE_UNALLIED )
                endif
                set j = j + 1
            endloop
        else
            //call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 15, "fuck's wrong?")
        endif
        set i = i + 1
    endloop
endfunction

//===========================================================================
function InitTrig_Map_Inital_Player_Team_Settings takes nothing returns nothing
    set gg_trg_Map_Inital_Player_Team_Settings = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Map_Inital_Player_Team_Settings, function Trig_Map_Inital_Player_Team_Settings_Actions )
endfunction
 
Level 12
Joined
Nov 3, 2013
Messages
989
if j == i then j = j + 1 endif
Is this even legit??

I thought so? Why wouldn't it?

edit: apparently that was it (And I also took the oppertunity to add in all the missing "set") lol >.<

edit 2: Maybe it works in some other programming languages because you use the {} brackets instead of just indents I guess?

You know like writing if true/false then { do thing } endif
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
the problem here is that Jass is made in such a way that everything has to be placed on separate line, so every expression must occupy one and only one line, and no two expressions can be in same line, so you have to split it
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
540
the problem here is that Jass is made in such a way that everything has to be placed on separate line, so every expression must occupy one and only one line, and no two expressions can be in same line, so you have to split it

what you describe is usually called a statement.
expressions are things you can return or use as an argument to a function call or things you an assign a variable to or things you can use as an array index or ... aka. values.
 
Level 12
Joined
Nov 3, 2013
Messages
989
Yeah, I'd probably make even more mistakes if I had to remember to always use the brackets or semicolons.

I just didn't realise that I couldn't put one liners on one line like I've done elsewhere.

Learning new things is for when I come to the point that what I already know is insufficient for my needs.
 
Level 7
Joined
Oct 19, 2015
Messages
286
I also had trouble with semicolons when I started writing in zinc (had no trouble with brackets though), but you get used to it. I still forget them from time to time, but it's the first thing I check when I get a compile error so the errors get fixed quickly and aren't really an issue. Nowadays however, when I occasionally still go back to JASS (like when I'm writing examples for people who don't use zinc), I find it really tedious to write all those "call"s and "set"s and "end*"s and "globals" and so on and so on. So I'd recommend zinc as well.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,232
I thought so? Why wouldn't it?
Because JASS syntax does not permit that?

edit 2: Maybe it works in some other programming languages because you use the {} brackets instead of just indents I guess?
Other languages such as C/C++ and Java have special syntax cases to support such lines. Specifically they support blocks of a single statement without having to declare a block.
Code:
if (sometest)
    dosomething();
Also they are not line aware to some extent due to the end of statement terminator so you can chain many statements together on the same line, although not recommended due to how unreadable it makes things.
Code:
dosomething(); dosomething(); dosomething(); dosomethingelse(); dosomethingevenmore();
Or in the previous case...
Code:
if (sometest) dosomething();

JASS just does not support this due to how the language syntax is specified.
 
Level 7
Joined
Oct 19, 2015
Messages
286
Other languages such as C/C++ and Java have special syntax cases to support such lines. Specifically they support blocks of a single statement without having to declare a block.
Code:
if (sometest)
    dosomething();
Forgot to mention, this is also true in zinc, you don't need the brackets for one-statement blocks.
 
Status
Not open for further replies.
Top