Thread: LPC Help
View Single Post
Old 11-12-2002, 10:05 PM   #3
kaylus1
 
Posts: n/a
Not sure about Amylaar, so I will go with MudOS first, in MudOS you have a config file when you start the driver ("driver ./config.mud") or whatever. Inside that file is the options for how long till reset and how long till swap out in seconds.

Each object in your Lpmud carries variables you never see that are defined in the driver, like when it's next reset time is, whether it is resetting etc. All the reset will do is reset the object back to it's original state. That's why it's good to keep a moderate number (1200-1800 seconds is usually good for a decent sized mud).

  Another good thing to note is if you put your swapout lower than your resets it never will reset. I always tend to use this as a rule: SWAP_TIME = RESET_TIME+(RESET_TIME/2), that way if no one enters the room, or "touches" an object (causes it to be accessed) within half the time after the reset than it swaps it out of memory.

 Anyway back to the topic, an interesting feature of the resets is that if your object has a reset() function in it, that function will be what is called.

To do this as was stated above you will need to create a new
room object (in addition) that has it's own reset command and on it's reset reloads from the file and destructs all children of it. (do a search of the MudOS efuns docs to find out how to do this). Do not recreate all the "virtual"-rooms in the reset. Have it load the file into some sort of mapping of arrays.. here is an example...
(don't look at the ****ty descs, just the concept
vr_room.dat
VR1:entrance to swamp:the swamp is to the north.:VR2:\rooms\world\street.c:X:X:
VR2:swamp:this swamp smells nasty:VR3:VR1:X:X:
VR3:swamp:you are deep in the swamp:X:VR2:X:X:

Notice the format is
NAME:short:long:north:south:east:west:

code to read it:
[code]
mapping vr_rooms;

void reset() {
  string *input_file, *this_room;
  object *rooms;
  int i;

  /* Whatever this file name is */
  rooms = children("/obj/vr_room");

  for(i = 0; i < sizeof(rooms); i++) {
      /*maybe put a check here to make sure a player isn't in the room*/
     rooms[i]->destruct();
  }

  vr_rooms = ([ ]);
  /* Read vr_room.dat and save the array of properties to a mapping reference */
  /* by the rooms name */
  input_file = explode(read_file("vr_room.dat", 1), "\n");
  for(i = 0; i < sizeof(input_file); i++) {
       this_room = explode(input_file[i], ";");
       vr_rooms[this_room[0]] = ({ this_room });
  }
}
[/quote]
That is some reset code, it may or may not work.. not tested, it should except for
maybe if I typoed =) But it helps get the picture, now what you need to do is add
a check to the move() function wherever you have it.
It needs to see if the exit is an actual file, if it is load it like regular, if it is not, run
the exit through the mapping of vr_rooms (ie if you have set_exits(({ "west" : "VR2" })); )
it obviously won't find a file named that so make it check vr_rooms["VR2"] and if it does
exist do a find_object to see if it's loaded and if not, clone a vr_room and set it's properties
based on the array in vr_rooms["VR2"];
Hope that helps?

Kaylus@Solice
  Reply With Quote