Author Topic: (no subject)  (Read 2273 times)

Anonymous

  • Member
  • *
  • Posts: 545
    • View Profile
(no subject)
« on: August 20, 2003, 02:39:46 AM »
Okay, I'm trying to do a custom item menu, using G'sMiscPlugin. However, I have encountered some problems, and I have made this little program to demonstrate what goes wrong:

Code: [Select]

:Itemtop

#Getitems("Menu")

#Getitems is a command that gets the filenames of the inventoryitems. For more information, check G'sMiscPlugin, since I'm to lazy to explain more.

Code: [Select]
#Fontsize(13)
#Mwin("1-<Menuitem[1]$>")
#Mwin("2-<Menuitem[2]$>")

#Mwin("3-<Menuitem[3]$>")

#Mwin("4-<Menuitem[4]$>")

Shows all the items in the MWindow. Nothing special.

Code: [Select]
#Itempressed!=1
#While(Itempressed!=1)
{
      #Wait(Keypressed$)
      #If(Keypressed$~="")
      {
            #Castnum(Keypressed$,Keypressed!)
            #If(Keypressed!<=4)
            {
                  #If(Keypressed!>=1)
                  {
                        #Itempressed!=0
                  }
            }
      }
}

Waits for a key to be pressed, if its beetwen one and four, then continue.

Code: [Select]
#Mwincls

#Useitem(Playerhandle[0],Menuitem[Keypressed!]$)
#If(Menuitem[keypressed!]$~="Weirdbook.itm")
{
      #Takeitem(Menuitem[Keypressed!]$)
}

#Mwin("You used <Menuitem[Keypressed!]$>")

#Useitem uses the item on the first player, and unless it's the Weirdbook that's being used, it should be deleted.

Code: [Select]
#Wait(wait$)
#Itemkill!=1
:Itemkill
#If(itemkill!>=5)
{
      #Kill(Menuitem[itemkill!]$)
      #Itemkill!=Itemkill!+1
      #Branch(:Itemkill)
}

And then kill all the variabels. Simple. But hey, if I only have one item and use it, the item is still there on the list if I start the program again, but in the default item menu, its not there. Anyone knows why?
« Last Edit: December 31, 1969, 06:00:00 PM by Anonymous »

Cuzit

  • Member
  • *
  • Posts: 487
    • View Profile
(no subject)
« Reply #1 on: August 21, 2003, 05:32:04 PM »
Ehh... No. Laughing
« Last Edit: December 31, 1969, 06:00:00 PM by Cuzit »

Anonymous

  • Member
  • *
  • Posts: 545
    • View Profile
(no subject)
« Reply #2 on: August 23, 2003, 10:20:30 AM »
So, I guess I'll just have to wait for RPGCode 3 to arrive and then find a better solution, right?
« Last Edit: December 31, 1969, 06:00:00 PM by Anonymous »

MrG

  • Member
  • *
  • Posts: 4
    • View Profile
(no subject)
« Reply #3 on: August 23, 2003, 11:46:22 AM »
No, you don't have to wait for TK3...

You just have an error here:

Code: [Select]
#If(itemkill!>=5)
{
     #Kill(Menuitem[itemkill!]$)
     #Itemkill!=Itemkill!+1
     #Branch(:Itemkill)
}

That #If(itemkill!>=5) should be #if(itemkill!<=5). That should fix it. You should also make that a #While loop, but you don't have to.

Hope that helps..

Mike
« Last Edit: December 31, 1969, 06:00:00 PM by MrG »

Anonymous

  • Member
  • *
  • Posts: 545
    • View Profile
(no subject)
« Reply #4 on: August 23, 2003, 02:09:11 PM »
All right, I think I've figured out something. First of all, thanks, Mr G (Mr G, the same one who made the plugin?), for helping me. However, my problems didn't stop there.

The problem still existed. But I noticed something new. If I entered the default item menu after "using" the item on my "custom" one, I now saw that I had -1 items. Yes. Negative one. That was really strange. The menu used and removed the item twice. How strange! I looked through my code to find some clues and found This...

Quote
                 #If(Keypressed!>=1)
                 {
                       #Itempressed!=0
                       #Branch(:Itemuse)
                 }



Later, just before the #Itemuse command, I found :Itemuse. I don't know why this didn't make it through to the forums, perhaps it was a desperate attempt to rescue it all and forgetting to tell you. If this was why it did happen, I don't know. However, in the case that it wasn't, I changed the code. Here is the new code:

Code: [Select]

#Kill(Menuitem[1]$)
#Kill(Menuitem[2]$)
#Kill(Menuitem[3]$)
#Kill(Menuitem[4]$)
#Kill(Menuitem[5]$)
#Kill(Menuitem[11]$)
#Kill(Keypressed$)
#Kill(Itemcount!)

#Getitems("Menu")
#Fontsize(13)
#Mwin("1-<Menuitem[1]$>")
#Mwin("2-<Menuitem[2]$>")

#Mwin("3-<Menuitem[3]$>")

#Mwin("4-<Menuitem[4]$>")
#Itempressed!=1
#While(Itempressed!=1)
{
      #Wait(Keypressed$)
      #If(Keypressed$~="")
      {
            #Castnum(Keypressed$,Keypressed!)
            #If(Keypressed!<=4)
            {
                  #If(Keypressed!>=1)
                  {
                        #Itempressed!=0

                  }
            }
      }
}
#Mwincls

#Itemcount(Menuitem[Keypressed!]$,Itemcount!)
#If(Itemcount!<0)
{
      #Givenitems!=0
      #Branch(:Giveitems)
}




#Useitem(Playerhandle[0]$,Menuitem[Keypressed!]$)


#If(Menuitem[keypressed!]$~="Weirdbook.itm")
{
      #Takeitem(Menuitem[Keypressed!]$)
}

#Mwin("You used <Menuitem[Keypressed!]$>")

#Wait(wait$)



#Itemcount(Menuitem[Keypressed!]$,Itemcount!)
#Givenitems!=0
#If(Itemcount!<0)
{
:Giveitems
      #If(Givenitems!>Itemcount!)
      {
            #Giveitem(Menuitem[Keypressed!]$)
            #Givenitems!=Givenitems!-1
            #Branch(:Giveitems)
      }
      #Mwin("ERROR!")
}




#Itemkill!=1
:Itemkill
#If(itemkill!<=5)
{
      #Kill(Menuitem[itemkill!]$)
      #Itemkill!=Itemkill!+1
      #Branch(:Itemkill)
}


I added a lot of killing, and fixed what Mr G pointed out. I also added a little part that made sure that the player didn't have a negative value of items, and also told the player that an error had occured. However, the original problem is still there! The item that was used is still on the menu, even though everything else says that it is gone! This is confusing me, and makes we want to cry.
« Last Edit: December 31, 1969, 06:00:00 PM by Anonymous »

Cuzit

  • Member
  • *
  • Posts: 487
    • View Profile
(no subject)
« Reply #5 on: August 24, 2003, 12:00:47 AM »
I'll go get a tissue...
« Last Edit: December 31, 1969, 06:00:00 PM by Cuzit »

MrG

  • Member
  • *
  • Posts: 4
    • View Profile
(no subject)
« Reply #6 on: August 24, 2003, 01:18:51 PM »
Are you using all the same item to test it out, or different items? Are there still four items after you take one away? What exactly comes out for the output after you try to delete the item?

Yeah, same G, by the way. Wink

Mike
« Last Edit: December 31, 1969, 06:00:00 PM by MrG »

Anonymous

  • Member
  • *
  • Posts: 545
    • View Profile
(no subject)
« Reply #7 on: August 27, 2003, 09:17:39 AM »
Al right, sorry for not posting, I've been busy with non-toolkit-stuff, and I probably will be busy for some time forward. Anyway, This is an exact step by step of what I do:

The game starts. I activate a program that gives me a piece of equipment and the menu-only item Weirdbook.itm. On the same board, I activate another program, which gives me a health potion, and lots of lots of gold. I leave the board, and step on a tile that activates the program for item using, which can be seen in another post. Now, in the MWin, this is what can be seen:

1-Weirdbook.itm
2-Healthpotion.itm
3-
4-



Now, if I press, for example, 3, I get an error message which tells me that there isn't any item named ".itm", and the Mwin says that "You used". That's not a problem, and I will add something that fixes that whenever I think I need to.

If I press 1, to use the Weirdbook, then This[/b] appears in the Debug window:

Error: Method not found!-- #FileRead("prg",item_prg$,"tempfile",0,numlines!)


I have no idea what it is or what it's for, and to help you even more, I will now give you the program for the Weirdbook:

#Fontsize(15)

#Mwin("This book cannot be thrown away")
#Wait(awit$)
#mwincls()


Yeah, I know, weird book, huh?



And finally, if I press the famous 2, for the Healthpotion.itm, this is what happens:

The MWin says:  "You used Healthpotion.itm!"

And then, I don't have any health potion anymore, plus that my health increased a little.


So, that's what happens if I use any item ONCE. Now lets look at what happens if I use them Twice!


So, I start over from the very beginning, I get the same items in the same order as above. I use item number 3 first (No item at all) and the very same thing that happened above happen again. Now, If I activate the item menu again, I get the exactly same error message as when I tried to use the item (Ok, that sounded wrong, I meant when I tried to use no item at all). Al right, so you shouldn't actually be able to use no item at all from the very beginning, but still.



So, what if I try to use the weirdbook again? Well, exactly the same thing as above happened, that weird error message appears, and nothing else.



So, now to the exciting part. We all know, that if you use the health potion once, and you only have one from the beginning, you no longer have any health potions left. But, in my strange item menu, it still says that you have a health potion!!! I know! It's the whole reason for this topic to exist! So, what happens when you try to use the virtual potion?
Exactly the same thing as above, only difference is that this time, the word ERROR flashes on the MWin really fast, before it disappears. But do you recover any health? YES! Surprisingly enough, you DO recover some health! Well, now that I look at the code, it's not that surprising, since it doesn't check if you have no items, it only checks if you have LESS than no items. So, it's not that surprising. I'll have to fix that.


Well, what if I actually pick up more than one health potion, then? Well, I just checked. And nothing special happened. You lost one item each time you used a potion, and everyone is happy.


But what if you pick up the items in a different order? Now THIS proved to be an important question. I tried to pick up the potion FIRST, and the book after. I used the book on my custom little menu, and that confusing error message appeared. However, if I used the potion, then the potion would disappear. But if I looked on my custom menu again, I wouldn't have any items at all!! That's right, This is how it looked:


1-
2-
3-
4-


I was so shocked! And in the real menu, I still had the weirdbook! How monumentally confusing!


And what if I try to use more items? To experiment with this, I created an item called fgiyr. I got the name adfter randomly pressing some buttons on my keyboard. Anyway, I try to use the fgiyrs, which I by the way bought in a non-custom shop. If I used them when they were bought last, they just disappeard aftyer I had used them, just like they should.
However, I created a little program which only purpose should be to give me a fgiyr. So, i used it twive, and got two fgiyrs. Then I got the other items, the book and the potion. And I used the fgiyr. First, one fgiyr disappeared. Evrything else remained intact, even the weirdbook, EVEN on my custom menu. Scary. Then I used the other fgiyr. And THEN everything disappeared on my custom menu, and it was really really empty.
So, I guess that when you run out of the item which appears first, all the variables die forever and cannot be used again. Or something. Probably not.



I hope this helps anyone who wants to help me. It probably doesn't, but maybe, somewhere........
« Last Edit: December 31, 1969, 06:00:00 PM by Anonymous »

Anonymous

  • Member
  • *
  • Posts: 545
    • View Profile
(no subject)
« Reply #8 on: September 16, 2003, 10:21:44 AM »
So, I guess noone can help me?
« Last Edit: December 31, 1969, 06:00:00 PM by Anonymous »