ID:147346
 
Okay Im trying to finish up this system by tonight so if someone could help REAL fast, thanks. Okay heres the problem, Im getting a runtime because im referancing to a list that is empty, but to the code before that proc is called, i check if its empty then, and if it is, return, so it shouldnt be going to that proc to referance the list. Heres the code where it checks and goes

            if(monstergroup.len)
if(monsterinparty)
UrMonsterBattle(enemy)
spawn()MasterBattle(enemy,enemy2)
else
spawn()MasterBattle(enemy,enemy2)
return
else
return

I clearly check in that if(monstergroup.len) and if it isnt, it shouldnt be going to UrMonsterBattle, which has the error because its referanceing to the list which is empty. Why is it going to the proc anyway? Please help!
Your interpretation of the error is wrong. If the if() is passing, then either the list is not empty, or it is being emptied within the other proc. Either way the problem lies in that other proc, and the exact text of the runtime error is important.

Lummox JR
In response to Lummox JR
But I only get the runtime, when the battle is over and it should end. Like, I kill all the monsters, so monstergroup is empty, then I get the runtime, any other time, I get the battle like it should be. But only when all the monsters are dead, i get it.
In response to Lummox JR
Not only that, it happens when battle is supposed to end, but when I Kill the last monster, UrMonsterBattle() isnt even supposed to be called then!
In response to Metroid
Metroid wrote:
But I only get the runtime, when the battle is over and it should end. Like, I kill all the monsters, so monstergroup is empty, then I get the runtime, any other time, I get the battle like it should be. But only when all the monsters are dead, i get it.

You still haven't provided nearly enough context, including the exact text of the error, to diagnose anything. You're just posting vague nothings.

Lummox JR
In response to Lummox JR
Ahh sorry I forgot here
runtime error: list index out of bounds
proc name: UrMonsterBattle (/mob/proc/UrMonsterBattle)
source file: Summon.dm,215
usr: Metroid (/mob/Newchar)
src: Metroid (/mob/Newchar)
call stack:
Metroid (/mob/Newchar): UrMonsterBattle(Red Slime (/mob/monster/Area1/RedSlime))
Metroid (/mob/Newchar): MasterBattle(Red Slime (/mob/monster/Area1/RedSlime), /list (/list))
Metroid (/mob/Newchar): Bump(Red Slime (/mob/monster/Area1/RedSlime))
Now if im incorperating it right, the runtime is being made because of a call to a list, that has nothing in it, but as I said before, it shouldnt be going to the proc, here the proc anyway.
mob
proc
UrMonsterBattle(mob/enemy)
if(monstergroup.len)
for(var/index in monstergroup)
if(!ismob(index))
monstergroup-=index
var/mob/M=monstergroup[1] //error line
var/monstername=initial(M.name)
monstername="[monstername][plural(monstergroup)]"
if(src.monsterinparty.poisoned == 1)
src.monsterinparty.hp /= 30
src.monsterinparty.hp = round(src.monsterinparty.hp)
P << "The [src.monsterinparty] suffered from poison damage!"
sleep(10)
var
poisstop = rand(0,4)
if(src.monsterinparty.hp <= 0)
P.Deathcheck(src.monsterinparty)
return
if(poisstop == 2)
P << "The poison slipped out of the [src.monsterinparty]'s body!"
src.monsterinparty.poisoned = 0
sleep(10)
switch(input("[src.monsterinparty.name]: Master! I encountered [monstergroup.len] [monstername]! What do you want me to do, Master? I'll target myself, just give me a command!","Command Your Monster!") in list("Attack","Spell"))
if("Attack")
UrMonsterAttack()
if("Spell")
UrMonsterSpell(enemy)

Now it shouldnt even be getting to the error line, and yet it does, any help?
In response to Metroid
Now if im incorperating it right, the runtime is being made because of a call to a list, that has nothing in it, but as I said before, it shouldnt be going to the proc, here the proc anyway.

When stuff isn't acting the way it should you should start outputing debug info. Output the size and contents of the list at the begining of the proc and see why it's getting to that point.
In response to Metroid
You have two horrible problems here.

First and foremost, you're not using spawn() when calling this same proc or the other one like it, in the final if/else. That will lead to infinite recursion; never do this.

Second, you get the list index error because you're removing items from the list in a loop just before that line, but you never bail out of the proc if the list is emptied.

Lummox JR