Lib Discussion => Dead Souls Support => Topic started by: Raudhrskal on September 21, 2008, 05:46:46 am

Title: Door that destroys keys.
Post by: Raudhrskal on September 21, 2008, 05:46:46 am
For Aerlindir @ i3.

Side note:
Raudhrskal <ds> Well, with locks there is a stupid thing. In case of things that inherit LIB_LOCK, (containers, etc.), you can have an callback in key file. But doors/enters don't do it ;( It's an inconsistency, and probably should be fixed.
Code: [Select]
#include <lib.h>

inherit LIB_DOOR;

static void create() {

    SetSide("north", ([ "id" : ({"door leading north", "door", "north door"}),
        "short" : "a door leading north",
        "long" : "This is the south side of a door leading north.",
        "lockable" : 1 ]) );

    SetSide("south", ([ "id" : ({"door leading south", "door", "south door"}),
        "short" : "a door leading south",
        "long" : "This is the north side of a door leading south.",
        "lockable" : 1 ]) );


    //If you don't know, strings like "key to north side" are added in 'modify my_key id'
    SetKeys("north", ({ "key to north side" }));
    SetKeys("south", ({ "key to south side" }));

//You add THIS:
mixed eventUnlock(object who, object key)
    if(GetLocked()) //if the door is unlocked, we just fall back to parent.
      if(::eventUnlock(who,key)) //Handled?
    if(!GetLocked()) //did the key unlocked the door?
key->eventDestruct(); //kill it.
who->eventPrint("Your key crumbles to dust..."); //message ;)
    return 1; // ::eventUnlock() returned 1, so must we.
return 0;  // ::eventUnlock() returned 0, so must we.
    return ::eventUnlock(who,key);  // Fall back to parent.

void init(){

//EDIT - changed title.