Howdy.
I’m looking for advice on how I might go about combining reports when examining identical items in a shared space.
Specifically, I’ve created an item - say deadwood. If the player collects multiple instances of deadwood and examines the deadwood in their inventory, several identical reports of the same description are printed for each deadwood item.
I figured this could be most efficiently solved through combining reports? I’ve been using Manipulating the Transcript as a guide, and while it includes some fantastic examples, I’m unable to adapt them for the examine action. I would appreciate any advice.
Thanks.
Do you want to combine reports, or do you want the objects to be treated as interchangeable? Because if it’s the latter you probably just want to add isEquivalent to the objects’ base class.
If you do want to use a report manager that’s cool. But I started typing out a lengthy reply with examples before coming to the conclusion that you probably weren’t talking about a bunch of unique, distinguishable pieces of deadwood.
I will try to be more specific, sorry. I was hoping to combine reports. isEquivalent is set to true already, and they are not unique. Just multiple copies of the same item with the same description. The identical descriptions will print for each item, like this:
> examine deadwood
deadwood: The quality is poor, but you're sure you can make something of it yet.
deadwood: The quality is poor, but you're sure you can make something of it yet.
deadwood: The quality is poor, but you're sure you can make something of it yet.
The deadwood is a technically a dispensable tied to an out-of-world dispenser/collective that I am using only to dispense items into the world. I’m wondering if it would be easier to somehow convert singular deadwood into an in-world collective when more than one are present in a container? Here is how I have it set up at present:
class deadwood: Dispensable, Harvestable 'deadwood*deadwoods' 'deadwood'
desc = "The quality is poor, but you're sure you can make something of it yet. "
isEquivalent = true
;
deadwoodCollective: Collective, Dispenser 'bundle/deadwood' 'bundle of deadwood'
"It's a bundle of deadwood. "
myItemClass = deadwood
isCollectiveFor(obj) { return obj.ofKind(deadwood); }
contentsListedInExamine = nil
notifyRemove(obj)
{
local tmp;
if(contents.length < 7)
{
tmp = new deadwood();
tmp.baseMoveInto(self);
}
}
;
+ deadwood;
+ deadwood;
+ deadwood;
+ deadwood;
+ deadwood;
+ deadwood;
+ deadwood;
Hey, love to see new “faces” on the TADS board! Welcome!
I compiled your code as is, with the exception that I eliminated the Harvestable class, and I gave the Collective a + under a Room, upping the deadwood instances to ++.
There were no repeating reports… even when I had all three deadwood instances, X DEADWOOD just gave
>x deadwood
The quality is poor, but you're sure you can make something of it yet.
Hey, thanks for the welcome and the help! I appreciate it.
The harvestable class is just a modified thing class (class Harvestable: Thing) I was planning to do something with down the line and it’s currently empty.
I don’t currently have my code in front of me but I can update with it later today. I have the dispensable deadwood moved into the player inventory via a custom “forage” action rather than the collective and dispensable deadwood already existing in a room. Maybe that’s where the issue lies.
This time I started the Collective out with location=nil. I set it up so that TAKE [dummy object in room] programmatically moves the Collective into inventory.
Still got the “combined” report, when examining deadwood!
Thank you for getting back to me. I moved several instances of deadwood into an empty test room to remove the possibility of the “forage” action or dispenser causing issues. You’re right, using:
>x deadwood
returns the desc:
The quality is poor, but you're sure you can make something of it yet.
I noticed the issue returns however when I use the plural:
>x deadwoods
At this point, I am given several identical descriptions. Is there a way to remedy this?
Certainly, your case seems to be the poster child for the isEquivalent property.
If that wasn’t sufficient for some reason, my second recommendation would have been to create a CollectiveGroup for world-present instances. Notwithstanding my dire drama with it this Feb, it represents a happy medium between isEquivalent and ‘Manipulating the Transcript’ for my WIP.
I’m not sure about your plural question (my first cut would be to add plural to the singular vocab and see what that does, but will defer to others who have a working sample to play with). I did notice though that your Collective does not include in the plural ‘deadwoods’ which the manual seems to require? Don’t know how that would factor into your current behavior, but is that generating any other weirdness?
I would also extend a belated welcome to the board! We do require you change your first name to something that starts with ‘J,’ though as a fellow Mc, I got yr back if you appeal that ruling.
Ah! Thank you so much. I’m not sure how I missed CollectiveGroup, but that seemed to solve my spat with the ExamineAction. I was able to use the examples in Manipulating the Transcript to remedy the multiple reports for the take, give, and drop actions.
Regarding the collective, I haven’t experienced any weirdness - but I haven’t fiddled with it too much since it isn’t world-present. I really only use it as a “spawner” for deadwood.
Thanks again for the help, patience, and welcomes!
Glad it helped! In case you didn’t internalize it earlier, I did trip over a seeming bug in the adv3 implementation, which could manifest if you can scatter them around your game. Strongly recommend you add this code somewhere:
modify Thing
addToSenseInfoTable(sense, tab)
{
inherited(sense, tab);
// JJMcC - if I modified SenseTable by adding myself,
// force my Collective Groups to reevaluate
if (tab.isKeyPresent(self))
foreach (local cur in collectiveGroups)
cur.addToSenseInfoTable(sense, tab); // force update!
}
;