Howdy.
Newbie question, but how do I add multiples of an item to player inventory. I’ve been using this:
exampleObject.moveInto(me);
And while it works, I can’t move more than one “exampleObject” into “me”. Is there a way to specify a quantity for “exampleObject”? Am I just going about this the wrong way?
I’ve been thumbing through TADS3 documentation for a hot minute and I can’t find or have overlooked the solution. Sorry it’s staring me straight in the face.
Thanks.
You can only have one object named exampleObject in your game, so multiple instances of it can’t exist to move. You could move a list of objects with code like this:
foreach(local obj in objList)
obj.moveInto(me);
Or if you want to move count objects of the SampleObject class you could do something like:
This will keep moving objects of the SampleObject class into me either until count objects have been moved or the game runs out of SampleObjects to move.
I would echo the primary issue would be if exampleObject is defined as a single object, and not a Multi-Inst or something. Eric’s SampleObject would be a way to define a class whose instances could respond the way you want (you would need to define what verbs invoke the moveMulti function, probably a custom version of Take).
CollectiveGroups allow you to collect individual instances into a group for reporting, examining and optionally manipulating. See section 15.3 of the adv3 documentation (not sure what section adv3lite?)
As an FYI, there is a subtle bug in CollectiveGroup in adv3 for objects that can be spread around the game. Should you go down that path, documented here.