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

ddl2829

  • Member
  • *
  • Posts: 2
    • View Profile
(no subject)
« on: September 17, 2005, 06:37:15 PM »
can any1 tell me how i would start ot ocode a item menu that does not use the internalmenu() command?
« Last Edit: December 31, 1969, 06:00:00 PM by ddl2829 »

Xorlak

  • Administrator
  • Member
  • *****
  • Posts: 2225
    • View Profile
    • http://darkagegames.net
(no subject)
« Reply #1 on: September 18, 2005, 12:54:48 PM »
This can be tricky.  I wouldn't recommend attempting this unless you have some prior game making experience.

Probably the best way is to store items in a series of arrays.  For example, you can keep the names of items in your inventory like this:

item[1]$ = "Potion"
item[2]$ = "Ether"
...

Etc.  And how many items of each you have in a parellel array:

itemcount[1]! = 2
itemcount[2]! = 3

You can list these side by side in a menu like this:

Code: [Select]
y!=10
for(i!=1;i! < maxitems!; i!++)
{
  text(10,y!,item[1]$)
  text(10,y!,itemcount[1]!)
  y!++
}

And get a result like:

Code: [Select]
Potion    2
Ether     3

Now, if you want to use an item, you can write a method that runs each time the item is used.  Say Use_Potion() is your potion method.  You can do something like

Code: [Select]
// i! is the number of the item being used
rpgcode("Use_" + item[i!]$)
itemcount[i!]!--

In the above case, if i! is 1, then the Use_Potion() method would be called and the number of potions in stock would be decreased.

That just scratches the surface, but it should give you an idea of where you need to go.
« Last Edit: December 31, 1969, 06:00:00 PM by Xorlak »