Problem with code, i need help QUICK!

Discuss any general programming issues here
Post Reply
Posts: 978
Joined: Sun Feb 14, 2010 7:11 pm

Problem with code, i need help QUICK!

Post by Bugala »

I have 3 and half hours left, and i have problem with my code that i cant figure out what is wrong iwith it.

I have this part: (showing only critical parts and didint copy paste, so might have typos this one)

1: Function p_InsertItemButton(n)
2: InsertLayer(nextfreeanim, #ANIM, 1, x, y)
3: SetLayerName(nextfreeanim, "item"..n)
4: NextFrame("item"..n, x, y)
5: MakeButton(1+n, #LAYERBUTTON, "item"..n, True, False, itembutton)
6: nextfreeanim=nextfreeanim+1
7: EndFunction

I have two different pickable items in game.

When i pick eitheer one of them, this works fine and works as its supposed.

However, if I already have one and then pick the other one, then it crashed at line 4 givin me error message:
"Specified Layer is not an anim layer"

When i used Debug to check values of n and nextfreeanim, they show this:

first time (with one item only):
n=1, nextfreeanim=0

Second time(when trying to pick other item when already having other)
n=2, nextfreeanim=1

So it goes exactly as i suspected. So why does it give me that eerror?

Any suggestions?

Post Reply