|
Post by megamushroom on Mar 24, 2004 17:29:32 GMT -5
ok, im not bad at coding, well, not too bad, but i cant figure out my inventory. I want it so that if I use all of one item, then the item above it moves into its slot. i can do this, but the item simpl replicates its self, so i tried moveing it the deleting itself, but i get an array out of bound error. here is my code simplifyed:
for (w=0;w<=4;w+=1){ if item[w]=""{ item[w+1]=item[w]}}
and my items are set out as:
item[0]="Potion" item[1]="Herb" item[2]="" item[3]="Ether" item[4]="Wonder dust"
i have got it so that when you click the sprite, it draws the text, and when you releasr the button, it runs the script to organise it.
i can send the file to someone via email, but my host is down at the moment, need to upgrade to a different one.
Thanks
|
|
|
Post by IsmAvatar on Mar 24, 2004 19:23:00 GMT -5
According to the code you gave us, there is no reason for the array to be out of bounds. just so you know, the bounds are: 1) no negative numbers 2) no fractions 3) must be less than 32000
this error normally occurs when you do something like this:
where m = 0: item[m-1] = item[m] (not an actual code)
|
|
|
Post by TheRPGNOOb on Mar 25, 2004 14:20:51 GMT -5
I used somewhat the same method to create an inventory, however mine is purely sprite-based (it was easier for me) My problem is that I want it to split into two or more rows instead of just a verticle column. If you think you can help, I'll gladly send you what I have so far.
|
|
|
Post by megamushroom on Mar 25, 2004 16:24:19 GMT -5
hmm, ism, I gave you the none errored code here is the errored code: for (w=0;w<=4;w+=1){ if item[w]=""{ item[w]=item[w+1] item[w+1]="" }} yes, please the example would be a great help, even just for reference!
|
|
|
Post by IsmAvatar on Mar 25, 2004 17:45:23 GMT -5
The only reason that code would give an error is if you didn't initialize arrays 0 through 5 first (notice that I did include 5)
|
|
|
Post by megamushroom on Mar 26, 2004 12:52:10 GMT -5
initialise them as in item[0]="Blah"? I have done that still, have you got the code for what i need?
|
|
|
Post by IsmAvatar on Mar 26, 2004 15:20:08 GMT -5
If you're certain you have initialized those*, then there's no reason in the code you gave me that you should be receiving that error.
*NOTE, YOU MUST ESPECIALLY MAKE SURE YOU HAVE INITIALIZED ARRAY 5!!!
|
|
|
Post by megamushroom on Mar 26, 2004 18:50:22 GMT -5
wow, i really should read things through, of course it was the 5th array thanks RPGNoob, your inventory is very nice, i am just looking at it now
|
|