Button Pushing Special Procedure [by Justin Robinson]
Snippet Posted Wednesday, August 12th @ 11:24:57 PM, by George Greer in the Specials dept.
. Click the link below to read it or download it.

From: Primacy <jmrobins@wired.uvm.edu>
Subject: Redbutton Spec

Here's some code I wrote for a 'Red Button' that when pushed,
will teleport the character to a random room somewhere in the mud.
In spec_assign.c add this to assign_objects():

        SPECIAL(redbutton);
        ASSIGNOBJ(32, redbutton);     /* transport button */

In spec_procs.c add this in at the bottom:

SPECIAL (redbutton)
{
  struct obj_data *obj = (struct obj_data *) me;
  struct obj_data *port;
  char obj_name[MAX_STRING_LENGTH];
  int z;

    if (!CMD_IS("push")) return FALSE;

    argument = one_argument(argument,obj_name);
    if (!(port = get_obj_in_list_vis(ch,obj_name,world[ch->in_room].contents)))
 {
      return(FALSE);
    }

    if (port != obj)
      return(FALSE);

        act("$n pushes $p and fades away.", FALSE, ch, port, 0, TO_ROOM);
        act("You push $p, and you are transported elsewhere", FALSE, ch, port,
0, TO_CHAR);
        char_from_room(ch);
        char_to_room(ch, number(0, top_of_world));
        look_at_room(ch, 0);
        act("$n slowly materializes from nowhere...", FALSE, ch, 0, 0, TO_ROOM)
;
        return(TRUE);
}

Finally, you will want to ensure that you have the 'push'
command, so add this line in the command list in interpreter.c:

  { "push"     , POS_DEAD    , do_not_here , 0, 0 },

---------
Now, you should create the object itself and put it into 0.obj.

#32
button red~
a red button~
A large red button is protruding from the wall here.~
~
13 0 0
0 0 0 0
1000 0 -1 0


Presto!  Load object 32 somewhere in the mud... and have someone
'push button', and away they go!



<< Butcher code [by Mendar] | Reply | View as text | Flattened | Change Ownership Command [by Crimson Wizard] >>

 


Related Links
  Wired
download
Related Articles
More by greerga
 
 

CircleMUD Snippets
 
Note: Not all of these snippets will work perfectly with your version of code, so be prepared to fix one or two bugs that may arise, and please let me know what you needed to do to fix it. Sending a corrected version is always welcome.
Finally, if you wish to use any of the snippets from this page, you are more than welcome, just mention the authors in your credits. If you wish to release any of these snippets to the public on another site, contact me FIRST.