I’m trying to make a sandbox game where objects are created on the fly, as needed/wanted by the player. Things have been going about as smoothly as I can hope, but I hit a minor snag with regards to how the game lists certain objects; specifically, my apples.
[spoiler][code]
#charset “us-ascii”
#include <adv3.h>
#include <en_us.h>
fruitManager : object
fruits = []
;
class Fruit : Food
isEquivalent = true
construct(myName)
{
name = myName;
initializeVocabWith(name+’/fruitfruits’+ pluralName);
}
;
class FruitCollective : MultiLoc, Component
isEquivalent = true
myTreeClass = FruitTree
myItemClass = Fruit
isPlural = true
cannotEatMsg = '{You/He} cannot eat that many <> at once. ’
isListed = nil
isListedInContents = nil
contentsListedInExamine = nil
locationList = []
construct(fClass)
{
myTreeClass = fClass;
local fName = myTreeClass.fruitName;
name = fName + ‘s’;
initializeVocabWith(fName + ‘/’ + name);
fruitManager.fruits += self;
}
dobjFor(Take)
{
verify(){}
check(){}
action()
{
local f = new Fruit(myTreeClass.fruitName);
f.moveInto(gActor);
"{You/He} pick{s} <<f.aName>>. ";
}
}
;
class Plant : Thing
adjName = name
;
//Trees
class Tree: Plant, Fixture ‘tree*trees’
isListed = true
isEquivalent = true
;
class Pine : Tree ‘pine*pines’ ‘pine’
;
//Fruit Trees
class FruitTree : Tree
fruitName = ‘fruit’
fruitDesc = ‘Its branches are heavy with delicious-looking fruit.’
noFruitDesc = ‘There is no fruit on it right now. ’
desc = "This is <>. <<myCollective.isIn(self) ? fruitDesc : noFruitDesc>> "
myCollective = nil
construct()
{
name = fruitName + ’ tree’;
initializeVocabWith(fruitName + ’ tree*trees’);
makeFruit();
}
getFruitCollective()
{
foreach(local i in fruitManager.fruits) //first find existing collective
{
if(self.ofKind(i.myTreeClass)) //does it match?
{
myCollective = i;
return i;
}
}
if(myCollective == nil) //still blank?
{
myCollective = new FruitCollective(self); //make a new one
}
return myCollective;
}
makeFruit()
{
if(myCollective == nil)
{
myCollective = getFruitCollective();
myCollective.moveIntoAdd(self);
}
}
;
class AppleTree : FruitTree
fruitName = ‘apple’
;
[/code][/spoiler]
The problem I’m having is that even though isEquivalent is flagged as true, my fruit, once created, ends up listed as “an apple, an apple, and an apple”, instead of “3 apples” or however many you pick. In fact, it seems anything I defined the construct() method on has this issue. The good news is that I don’t have any disambig errors, so isEquivalent must be doing something useful. However, how can I solve the wording issue?