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

Unexpected End of Line

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,337
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,337
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