ID:273666
 
I know this has probably been asked many a time, but how do you "stack" items, so that they do not clutter up a user's inventory? And, although i could probably figure it out, how would you set a limit to said stackable items?

Also, I am using objects to represent attacks (because each attack has its own set of stats and stuff, so i thought that would be the best way to do it) and, as it is a pokemon game i am making, each attack has its own pp/mpp stat thing. I'm wondering how i can make this appear in my stats panel?

Attack Stats Code:

//...
statpanel("Attacks")
stat(src.attacks)
//...

obj/attack
var/attacktype
var/power
var/accuracy
var/hittype
var/pp
var/mpp
Tackle
attacktype = "Normal"
power = 35
accuracy = 95
hittype = "Physical"
pp = 10
mpp = 10


How would i make it appear as:
Tackle 10/10
... ...
etc etc/etc

?
For stacking items, use a quantity variable. The quantity variable is increased when the player gets more of the same object, and decreased when the player drops some of the object or uses some.

To display a stat next to an object, change the objects 'suffix' variable.
In response to Warlord Fred
can you elaborate on the suffix variable please?
In response to SadKat Gaming
The 'suffix' variable is a built-in variable for objects. It's type is a text string that doesn't accept formatting. When set, the suffix var will be displayed next to its parent object in statpanels and grids.
In response to Warlord Fred
suffix = "[pp]/[mpp]"


Tried that /\
Didnt work.

How would i use it in this sense?
In response to SadKat Gaming
You need to change the suffix whenever those variables change. You can't define one variable in terms of another one at compile-time like that.
In response to Garthor
So how would that be done?

I'm full of questions me ^.^
In response to SadKat Gaming
Does src.attacks actually hold attack objects? If the attacks are actually in src.contents, use a for() loop to go through src.contents and check the type of each object. If it is an attack, use stat() to display it. If not, do nothing.
In response to Warlord Fred
Oh no, the list, src.attacks, works fine. It will display the users attacks in the attacks section of the statpanel. It's just getting the pp in that i am trying to do.
In response to SadKat Gaming
Use a proc for changing those variables, and in the proc have suffix update as well as changing the variable.

Example:
proc
ChangePP(obj/attack/O, value) // Value should be positive to increase PP, negative to decrease PP
O.pp += value
O.suffix = "[O.pp]/[O.mpp]"


Use procs like that for changing values that are displayed in suffixes.
In response to SadKat Gaming
Yes, I saw the problem after reading Garthor's post.
In response to Warlord Fred
Ok, so is their anyway to do that when the user logs in? My guess is calling that at log-in and using value of 0?