When I was coding this, I got that feeling. I didn't really expect it to work, but since it was a good effort, at least, I'll post it anyway. ;-)
#include <lib.h>
#include <vendor_types.h>
inherit LIB_ITEM;
string color;
int once;
mixed is_pushed();
static void create() {
::create();
SetMass(5);
SetShort("A metal panel.");
SetLong("A metal panel with a big red button in the middle labeled /"PUSH ME"/.");
SetKeyName("panel");
SetId("panel","metal panel","button",);
SetItems( ([ ({ "button" : (: is_pushed
]) );
}
void init() {
::init();
once = 0;
color = red;
}
add_action("push_button","push") {
mixed push_button(string str);
if( str != button) { write("Push what, the button?");
else write("You push the button, which turns blue!"); color = blue; once = 1; say(this_player->GetName() + " pushes the button, which turns blue!");
return 1;
}
if( once == 1) { write("The button has already been pushed!");
return 0;
}
}
And this is the error when I try to clone.
> /realms/zaroth/area/obj/button.c line 17: syntax error
/realms/zaroth/area/obj/button.c line 29: Illegal LHS
/realms/zaroth/area/obj/button.c line 30: Undefined variable 'red'
/realms/zaroth/area/obj/button.c line 30: Illegal LHS
/realms/zaroth/area/obj/button.c line 40: Undefined variable 'blue'
/realms/zaroth/area/obj/button.c line 40: Illegal LHS
---
*Error in loading object '/realms/zaroth/area/obj/button'
Object: /cmds/creators/clone at line 21
'<function>' at /secure/save/creators/z/zaroth (<function>) at /:0
'cmdAll' at /secure/save/creators/z/zaroth (/lib/command.c) at line 93
'cmd' at /cmds/creators/clone at line 21
'CATCH' at /cmds/creators/clone at line 21
Trace written to /log/catch
Error in cloning object: *Error in loading object
'/realms/zaroth/area/obj/button'
I see some undefined and uncalled stuff in my code, but I can't quite figure it out myself, since this is my first real attempt and add_action() on an object.