Thanks tomasb. I’ll see what I’m doing wrong there. Maybe adding a new directory is what was causing the problem.
I’m having another instantiation issue with a class object. I’m setting isEquivalent, but it still seems to add a new one for each one I take. Also there’s a disambiguation issue between the wild sorrel main object, and the ones held in inventory.
[code]trailSideSorrel : Food
name = ‘sorrel’
vocabWords = ‘sorrel*sorrels’
desc = “Spinach greens about a foot high. Some leaves are growing a little more gnarled than
others, while a couple are riddled with holes.”
location = brownieForestAroundHouse
disambigName = ‘wild sorrel’
dobjFor(Take)
{
action()
{
sorrel = new Food('sorrel', 'sorrel*sorrels');
sorrel.set_desc('Sorrel herb. Commonly called spinach.');
sorrel.disambigName = 'owned sorrel';
sorrel.uses = 1;
sorrel.nutrition = 12;
sorrel.shelfLife = 75;
sorrel.canRot = true;
sorrel.hasEffect = nil;
sorrel.isFresh = true;
sorrel.isPlural = true;
sorrel.isEquivalent = true;
sorrel.vocabLikelihood = 10;
sorrel.location = gActor.getOutermostRoom();
sorrel.moveInto(gActor);
"<<me.name>> takes some of the fresh sorrel leaves.";
}
}
;[/code]
food class
modify Food
name = ''
vocabWords = ''
desc = ""
uses = 1
nutrition = 1
shelfLife = 75
isEquivalent = true
canRot = true
hasEffect = nil
isDry = nil
isBurnt = nil
isFresh = nil
isSalty = nil
isSour = nil
isSweet = nil
isSpicy = nil
isSavery = nil
isBitter = nil
isRotten = nil
construct(nameSet, vocabSet)
{
name = nameSet;
vocabWords = vocabSet;
initializeVocabWith(vocabWords);
}
set_desc(descSet)
{
desc = descSet;
}
dobjFor(Eat)
{
action()
{
if(gActor.hungerBar + 1 >= gActor.maxHunger)
{
// used
if(self.canRot)
{
self.uses -= 1;
}
if(self.uses <= -1)
{
self.uses = -1;
}
if(gActor == me)
{
if(gDobj.isPlural)
{
message = '<<me.name>> places some of {the dobj/he} into
<<me.return_pronoun('his/her', me.gender)>> mouth. ';
}else{
message = '<<me.name>> places {the dobj/he} into
<<me.return_pronoun('his/her', me.gender)>> mouth. ';
}
if(isFresh)
{
message += '<<one of>>Fresh and delicious.
<<or>> It tastes good.
<<or>> It\'s great.
<<or>> Couldn\'t be fresher. ';
}
if(isDry)
{
message += ' <<one of>>it\'s a bit dry and textury to chew on.<<or>> It\'s so dry,
it\'s hard to chew.<<end>>';
me.thirstBar -=1;
if(me.thirstBar < 0)
{
me.thirstBar = 0 ;
}
}
if(isSalty)
{
message += 'It\'s quite salty to the tongue.';
me.thirstBar -= 2;
if(me.thirstBar < 0)
{
me.thirstBar = 0 ;
}
}
if(isBurnt)
{
message += '<<one of>>This is like eating charcoal.<<or>> This is worst than chewing
on a burn, fresh from a campfire.';
}
if(isSpicy)
{
message += '<<one of>>{The dobj/he} is spicy, causing the taste buds to dance.<<or>>
It\'s so spicy it makes the mouth a little dry.<<end>>';
me.thirstBar -=1;
if(me.thirstBar < 0)
{
me.thirstBar = 0 ;
}
}
if(isSour)
{
message += '<<one of>> Bitterness causes <<me.return_pronoun('his/her', me.gender)>> lips
to pucker.';
}
if(isSovory)
{
message += 'It\'s a bit savory on the palate.';
}
if(isRotten)
{
message += '{the dobj/he} tastes putrid. It\'s rotten!';
}
"\n\b";
// handle eating of non-rotten food
if(!self.isRotten)
{
me.hungerBar += self.nutrition;
"<<message>>\n";
"\t Hunger +<<self.nutrition>>\n";
}else{
me.hungerBar -= self.nutrition;
"<<message>>\n";
"\t Hunger -<<self.nutrition>>\n";
// character also looses around 10% of max life
amount = new BigNumber(me.hpMax * 0.25, 2);
amount = amount.getCeil();
realAmount = new BigNumber(rand(amount) + (amount + (amount/2)), 2);
realAmount = realAmount.getCeil();
me.hp -= realAmount;
"\t Hp -<<realAmount>>\n";
if(me.hp < 0)
{
me.hp = 0;
}
// end eating rotten food
}
if(me.hungerBar > me.maxHunger)
{
me.hungerBar += me.maxHunger;
}
// BUG: add effect code for food.
// hasEffect
// apply the effect in the food.
// end if gActor == me (handle eat for npx)
}else{
// BUG : handle rotten food for NPC
if(gDobj.isPlural)
{
message = '<<me.name>> places some of {the dobj/he} into
<<me.return_pronoun('his/her', me.gender)>> mouth. ';
}else{
message = '<<me.name>> places {the dobj/he} into
<<me.return_pronoun('his/her', me.gender)>> mouth. ';
}
"\n";
gActor.hungerBar += self.nutrition;
"\t Hunger +<<self.nutrition>> (<<gActor.name>>)";
if(gActor.hungerBar > gActor.maxHunger)
{
gActor.hungerBar += gActor.maxHunger;
}
// end if gActor == npc
}
if(gDobj.uses <= 0)
{
gDobj.moveInto(nil);
gDobj.location = nil;
}
}else{
"<<gActor.name>> isn't hungry enough to eat {the dobj/he}.";
}
// end action
}
// end dobjFor eat
}
// remove food if eaten
afterAction()
{
if(self.uses <= 0)
{
self.moveInto(nil);
}
food_handler();
}
// food_handler for rotting food
// BUG : Finish food handler
food_handler()
{
self.shelfLife -= 1;
switch(self.shelfLife)
{
case 25:
"<<one of>>Something is beginning to smell a little funny.
<<or>> Something smells a bit off.
<<or>> Something doesn't smell right.";
break;
case 0:
"<<one of>>Something smells rotten.
<<or>> Something smells putrid.
<<or>> A putrid smell wafts up from somewhere.";
self.isRotten = true;
self.name = 'rotten ' + self.name;
self.vocabWords = 'rotten <<self.name>>';
isFresh = nil;
isSalty = nil;
isSour = nil;
isSweet = nil;
isSpicy = nil;
isSavery = nil;
isBitter = nil;
break;
}
}
;