[I6]Implementing darkness tied to a worn item.

Hi. After trying to search through the forum for quite too long and not finding anything, I decided to just ask.
Spoonfed style, if possible, but not required, because my patience for this is near zero now.

How to implement something like a hood, or a sheet, or a basket, or anything that can temporarily blind the player?

I’ve tried giving the room light and taking it away, but, of course, that comes with the problem of making the room dark and keeping it dark if one drops the item in a different room.
What would be the least convoluted way of pulling this off?
Daemons? Some sort of catch in the chain of “each turn”?
The design manual states that “inside_descriptions” can override room descriptions too, but I don’t know how to pull that one off either.


It’s easiest to just write a before:Look rule that stops the action. That doesn’t prevent the player from blindly picking items up, however.

If you really want to use the library darkness mechanism, replace the OffersLight() function and add a line at the top that returns false if the blindfold is worn. The library will then treat the world as dark, ignoring all light sources.

I see, thank you. I will most likely go use that if the solution I cobbled up in the meantime is inferior to that.

Object OldClothSheet "Old Linen Sheet" Cellar_Barrels with name 'sheet' 'cloth' 'old' 'rags' 'fabric',
description "An old, plain sheet of linen cloth. It smells like dust but does not show any signs of mold.",

after [;
    Wear:location = thedark;
    Disrobe:location  =real_location;
react_before [;
    Go: if(self has worn ){ print "You stumble around blindly until you reach your destination";}
react_after [;
    Go: if(self has worn && location ~= thedark){location = thedark; rfalse;}
has clothing;

I am mainly concerned about setting the location, myself.
So far I have not come across any problems, since taking the blindfold off in a room that has no light by default will become the darkness again in the light calculation routine.
So it doesn’t magically reveal a room if you take off the blindfold.

But maybe there are some things I simply don’t know about due to my noob status?
In any case, thank you for the advice. I wouldn’t even have thought to replace a “guts” routine like that.

Oh, right I had to rewrite objects that use “location” to use “real_location” for decisions.
But I think those break with darkness being the current location, as well. Like two way doors that set themselves to destinations based on the location.

I also had to add some DarkToDark() stuff.

Class Blindfold  with name 'blindfold', 
darkname "( Blindfolded )",
after [;
    Wear:location = thedark; thedark.short_name = self.darkname; rtrue;
    Disrobe:thedark.short_name = real_dark_name;location  =real_location; <<Look>>;
react_before [;
    Examine: if(self has worn) {print (string)self.darkname; rtrue;}
    Go: if(self has worn ){ print "You stumble around blindly.^"; DarkToDark();rfalse;}
react_after [;
    Go: if(self has worn && location ~= thedark){;location = thedark; rfalse;}
has clothing;