class object not working in if condition

Hi,

I created a Honeycomb class and am trying to use it in an IF condition but the condition fails. When the honeycomb was a Container object, the condition worked. I made a class because I need more than one segments of honeycomb.

beeNest: Container, Fixture 'bee nest;old abandoned' @terraceRoom
"An old bee nest. It's gray and dry. <<if Honeycomb.isIn(beeNest)>>The bees are long gone but segments of honeycomb are still present.<<end>> "

cannotTakeMsg="You don't need the entire nest, just a section of honeycomb will do. "

;

+Honeycomb;
+Honeycomb;

class Honeycomb: Container 'honeycomb;wax soft segment; honeycomb' 
"A segment of waxy honeycomb. The wax could be formed into a variety of shapes. "
bulk = 1
bulkCapacity = 1
isUsed = nil

;
//The condition
crack: OpenableContainer  'crack;small opening hole fracture' @exteriorWall
"A small crack in the exterior wall of the ice palace. <<if meltwater.isSpraying>>A stream of frigid water sprays from the crack.<<else>>The crack is sealed closed.<<end>> "

bulkCapacity = 1
isOpen = true
allowInsert = true
isListed = nil

iobjFor(PutIn)
{
  action(){
    local direct = gDobj;
    if(gDobj == tallow || gDobj == Honeycomb){
    "You mash the <<direct.theName>> into the hole, sealing the crack. The spraying water is diverted down the inside of the wall. You are now free to continue down the ledge. ";
        meltwater.isSpraying = nil;
        gDobj.moveInto(crack);
        crack.isOpen = nil;
        crackAchievement.awardPointsOnce();
  }else{
    "The pressure forces the <<direct.theName>> out of the crack. ";
    abort;
  }
  }
}

;

As always, thank you for your help.

Deborah

With the +Honeycomb; lines, you’re declaring two anonymous objects.

I don’t think that you can then use such an anonymous object in conditions directly, as you’re trying to do in these passages: if Honeycomb.isIn(beeNest) and if(gDobj == tallow || gDobj == Honeycomb).

You’ll either need to give the objects names in order to be able to refer to them, such as …

+honey1: Honeycomb;
+honey2: Honeycomb;

... if (honey1.isIn(beeNest) || honey2.isIn(beeNest)) ...

… and/or check the kind of an object, for example like this: if(gDobj.ofKind(Honeycomb))

3 Likes

He’s right. Anonymous objects are great until you need them for more than decoration or menus/conversation. After that, it really pays to give your objects names. That’s partly why general purpose programming languages ask you to give every object a name.

2 Likes