Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Advanced Object Use: Very specific problem

For my ambitious RPG, I've used Sharpe's advice about objects to lay the foundations for a pretty cool inventory system. But there's just one thing it can't do based on my current knowledge.

Here's what I've got.

/%-This is in the StoryInit passage-%/
<<set $cArm = {
id: 0,
type: 1,
status: 0,
property1: "Placeholder",
property2: "Etc",
property3: "Etc",
}>>

<<set $platemail = {
id: 101,
type: 1,
status: 0,
property1: "Placeholder",
property2: "Etc",
property3: "Etc",
}>>
Every item has an object set up in the StoryInit passage, with items of like type having the same number and position of properties.

the .id property is a unique number given to each item in the game. It helps reduce clutter when I need to reference specific items, but once my knowledge grows more advanced (one element of which I'm trying to do with this thread) it should be able to do a lot more.

The status property indicates whether the object is held, worn, in the shop, or in the backpack. My methodology for allowing those items to show up in their respective places is primitive but it works - massive lists of if statements. The downside, of course, is that this means there's only ever one copy of an item, but for my game's purposes so far that's fine. For bonus points, maybe this can be made more elegant and/or powerful.

"c" stands for current, so "cArm" is current armor. These are for equippable items; there is another, placeholder object for each equippable item slot. Expressions and variables and such all reference to the cArm, cWeap, and other item objects.

To "equip" an item all we do is just
<<set $cArm = $platemail>>
This works great for my purposes - however, there's one thing it can't do: unequip the old armor. "You equip your platemail. You are now carrying your studded leather."

Because of how the rest of my inventory works (and again, it's primitive and I wouldn't mind advice on how to bring it up to snuff), to do this I have to change the .status property of the existing item. Which is tough because the original object that was copied into the "cArm" object is no longer an element of the equation. All the properties are the same, but it's a different object entirely. So aside from a ridiculous wall of if conditionals, how could I go about doing that?

Aside from massive system overhauls, my best target strategy is to reference the .id property. Have a statement that calls the object whose .id property is the same as the (old) cArm object's property, and change another property within it. Then after that, the new armor object is copied into cArm. However, I've searched for such language and couldn't find it.

I hope the optimal solution isn't too complex, less for my sake and more so that it's the least difficult of a chore for you guys. I totally get it if it's too much, but thanks regardless.

Comments

  • Perhaps I'm missing the point, but could you have an "item" that sets the unequipped status?

    <<set $cArm = $unequipped>>
Sign In or Register to comment.