Hello. I’m back again, battling my own token/representative system. I would like some advice if possible.
So, I have some container objects that are kept in the player inventory. On taking certain items, those items are redirected into those container objects instead of directly into the player’s inventory (this helps with organization and also paves the way for “token” items, which are singular items that I use to represent a quantity of that item). While it functions how I want, this has created some issues with actions. Here are the two specific issues I’m dealing with:
First issue: Taking non-token (regular) items
For example, I have a custom container - a lunch pail. And I have an item that belongs to that container - a teacup.
Under the teacup, I have something like this:
dobjFor(Take)
{
action()
{
if(!self.isIn(myLunchPail))
{
self.moveInto(myLunchPail);
"You tuck the <<self.name>> into your lunch pail. ";
}
else
{
"You're already carrying the <<self.name>>. ";
exit;
}
}
}
Which works great for explicit take commands. The issue comes with DropAction, PutInAction, etc. See below:
> drop teacup
(first taking the teacup from the lunch pail)
You're already carrying the teacup.
This is OK for items that I don’t want to the player to be able to explicitly remove, such as with tokens, but with non-token items, this is obviously undesirable.
I’ve tried emptying the precond list on both DobjFor(Take) & DobjFor(Drop), which has little effect. I could remove the else clause on the DobjFor(Take) code, but then this allows me to endlessly tuck the teacup into the lunch pail because it’s not technically in the player inventory.
Is there a way to define the lunch pail as part of the player inventory for these kinds of actions? That would allow me to remove the DobjFor entirely, eliminating this issue. Or maybe there’s a way to remove implicit actions completely under the teacup DobjFor(Drop)?
Second Issue: Taken token items.
The thing with token items is that they’re meant to be representatives and not something you can actually interact with beyond examination. Some background with token system: I have a token class, which are uninteractable items that represent a real world item. Then, I have a false token class which is the real world counterpart of a token. False tokens can be interacted with, and when taken, are transformed into false tokens and moved into their respective container.
For example, I’m carrying a knapsack (my container), which is holding a token (a stick). I want to keep the stick in the actor scope list so that I’m able to observe the stick and prevent an issue like this:
> x stick
You don't see a stick here.
To resolve this, I’ve done something like this under the token class:
dobjFor(Examine){verify(){}}
dobjFor(Feel){verify(){}}
dobjFor(Smell){verify(){}}
dobjFor(Take)
{
verify()
{
illogical('You\'re already carrying that. ');
}
}
dobjFor(Default)
{
verify()
{
illogical('That isn\'t something you can do with this particular item. ');
}
}
Which works, if a bit clunky. The biggest problem I have is when there are both sticks in the knapsack and sticks on the ground. The sticks on the ground are false tokens, thus able to interacted with, while the sticks in the knapsack are regular token. Something like this can occur:
> take sticks
Taken
You're already carrying that.
The behavior is completely functional, but I get an undesired message. It appears as if the parser is trying to take every ‘stick’ in scope. Using a singular ‘take stick’ works fine, no undesired message. The issue is with the plural.
Is there a way to remove my regular tokens class from the scope of specific actions entirely? Without altering the examine behavior or other desired actions? Could I be going about Tokens inappropriately - like, maybe I should look into turning the class into a topic of some kind instead of a physical item?
I assume both of these issues could be resolved with action scopes. I’ve poked around Redefining the Scope, but I’m struggling to successfully apply what I’ve learned there to already existing actions like Take, which require complete replacement or modification. This makes me think I could be going about it wrong? Should I go about tackling the issue inside of the actions themselves, or through the objects/classes?
Thanks.