toast/programming_examples.md
2025-09-07 01:18:08 +00:00

1.0 KiB

George, who can be awakened.

@create $thing named "George"
@property george.awakened_time 0
@property george.time_awake 20
@verb george:description this none this rxd
@verb george:awaken this none none rxd

@program george:awaken
if ((time() - this.awakened_time) > this.time_awake)
    player:tell("W H A M M U ! You awaken George!");
    player.location:announce("W H A M M U ! "+player.name+" awakens George!");
    this.awakened_time = time();
else
    player:tell("George is already awake.");
endif
.

@program george:description
if ((time() - this.awakened_time) > this.time_awake)
    return "He appears to be sleeping. Hopefully nobody AWAKENS him.";
else
    return "George is awake and unfathomably powerful.";
endif
.

The Orb of Seeing, which demonstrates how to get information about the players that interact with objects.

@create $thing named "Orb of Seeing"
@verb orb:description tnt

@program orb:description
return {
    "The "+this.name+" sees many things!",
    "Viewer name: "+player.name,
    "Item owner: "+this.owner.name
};
.