• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Unexpected End of Line

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,338
Hi,

Not sure why this error keeps popping up, but here is the error and code.

2dgtizm.png


JASS:
 method addMonster takes unit u returns boolean
        local integer i = 0 //counter for looping
        local MonsterStruct m = MonsterStruct.create()
        if totalMonsters < MAX_MONSTERS:
            m.destroy()
            return false //failed to add a new monster
        else:  //we know we have room for the new monster
            set m.monster = u
            set m.id = GetUnitTypeId(u)
            set m.index = monsterId2Index(m.id)
            set m.heroLevel = GetHeroLevel(u)
            set m.playerId = this.playerId
            if totalActive < MAX_ACTIVE_MONSTERS: //check to see if the party has an open spot
                set m.active = true
                loop
                    exitwhen i > MAX_ACTIVE_MONSTERS
                    if activeMonsters[i] == 0:
                        set activeMonsters[i] = m
                    endif
                    set i = i + 1
                endloop
                set totalActive = totalActive + 1
            else: //totalInactive < MAX_ACTIVE_MONSTERS
                set m.active = false
                loop
                    exitwhen i > MAX_INACTIVE_MONSTERS
                    if inactiveMonsters[i] == 0:
                        set inactiveMonsters[i] = m
                    endif
                    set i = i + 1
                endloop
                set totalInactive = totalInactive + 1
            endif
            totalMonsters = totalMonsters + 1 //increment the total monster count
            return true //we successfully added a new monster
        endif
        endmethod
 
Level 15
Joined
Aug 7, 2013
Messages
1,338
if totalMonsters < MAX_MONSTERS: -> if totalMonsters < MAX_MONSTERS then
totalMonsters = totalMonsters + 1 -> set totalMonsters = totalMonsters + 1

Also what line is the error on

":" may be allowed in vJass but I'm not sure.

Thank you very much! Everything works now, and that other error did come up too, but it does not allow colons after else I think.
 
Status
Not open for further replies.
Top