Is there a way to make an item only have a certain amount of uses before they get destroyed?
Depending on your methodology...
Hackers way... and only reasonable to use if the object is only used a few times
More Elegant Way
FOR THE USE OBJECT SCRIPT (I also copy-pasted this on the 'push' verb on the button of the machine)
if (fart machine.TimesUsedCount = 0) {
msg ("You push the button and a squeaky sounding fart emits from the machine.")
fart machine.TimesUsedCount = fart machine.TimesUsedCount + 1
}
else if (fart machine.TimesUsedCount = 1) {
msg ("You push the button and a wet, rumbling noise emits from the machine.")
fart machine.TimesUsedCount = fart machine.TimesUsedCount + 1
}
else if (fart machine.TimesUsedCount = 2) {
msg ("You push the button and the fart machine produces a VERY loud sound similar to the explosion of a hand grenade followed by a ker-thunk.")
fart machine.TimesUsedCount = fart machine.TimesUsedCount + 1
SetObjectFlagOn (fart machine, "broken")
}
else {
msg ("You push the button, but the machine does nothing. Must be broken.")
}
FOR THE LOOK AT DESCRIPTION:
if (GetBoolean(fart machine, "broken")) {
msg ("It's a fart machine, but you think it is broken. It appears to do nothing.")
}
else {
msg ("It's a fart machine with a button on it.")
}
Hopefully that is clear enough. If you need clarification, please ask!
^If it is an object that you use a BUNCH, indicate that and I will help there too. It's a little different, but not too bad.
a simple example (using scripting only, might be missing some stuff and/or wrong syntax, too lazy to test it)
create ("room_x")
object_variable = create ("potion")
object_variable.parent = room_x
object_variable.quantity = GetRandomInt (1,9)
object_variable.consume => {
this.quantity = this.quantity - 1
}
list add (object_variable.displayverbs, "consume")
list add (object_variable.inventoryverbs, "consume")
object_variable.changedquantity => {
if (object_variable.quantity = 0) {
destroy (object_variable.name)
}
}