Subject: Re: porting an object between MOOs

From: [email-masked] (Narciso Jaramillo)
Date: Thu, 5 Nov 1992 15:38:20 -0800

I wrote a @dump_object macro that will print out a script enabling you
to create a (nearly) identical copy of an object on another MOO.  (I
gather that there's something like this in the 1.7 core, but we were
running an old version.)  Of course, the script assumes the existence
on the target MOO of all objects and verbs that the dumped object
refers to; the script can be edited by hand to fix the parent number,
etc.  When run on the new MOO, the clone object will be owned by the
person running the script and will be in that person's inventory;
also, the script can't set any `c' properties (unless you're a wizard,
I guess).  Other than that, the new object should be pretty much
identical.

No guarantees expressed or implied; `it works for me, occasionally.'

.program me:@dump_object
"Prints out a script that could be used to recreate the object in another";
"MOO.  Assumes the parent number is the same; the owner will be whoever";
"runs the script, and the location will be in that player's inventory";
"rather than wherever it is in the source MOO.  Programmers and wizards";
"cannot be dumped.";
if (!valid(dobj))
  player:tell("Not a valid object.");
elseif (dobj.owner != player)
  player:tell("Can't dump an object you don't own.");
elseif (dobj.wizard || dobj.programmer)
  player:tell("Can't dump programmers or wizards.");
else
  player:tell("\"***Start of script to recreate object ", dobj.name, ".");
  player:tell(";if (!(\"_recreating\" in properties(player))) add_property(player, \"_recreating\", #-1, {player, \"\"}); endif");
  player:tell(";player._recreating = create(", parent(dobj), ")");
  player:tell(";move(player._recreating, player)");
  player:tell(";player._recreating.name = \"", dobj.name, "\"");
  player:tell(";player._recreating.r = ", dobj.r);
  player:tell(";player._recreating.w = ", dobj.w);
  for i in ($object_utils:all_properties(dobj))
    if (!(i in {"owner", "location", "programmer", "wizard"}))
      pperms = property_info(dobj, i)[2];
      if (i in properties(dobj))
        player:tell(";add_property(player._recreating, \"", i, "\", ", $string_utils:from_value(dobj.(i), 1), ", {player, \"", pperms, "\"})");
      else
        player:tell(";set_property_info(player._recreating, \"", i, "\", {player, \"", pperms, "\"})");
        player:tell(";player._recreating.", i, " = ", $string_utils:from_value(dobj.(i), 1));
      endif
    endif
    if (ticks_left() < 20 || seconds_left() < 2)
      suspend(1);
    endif
  endfor
  for i in (verbs(dobj))
    player:tell(";add_verb(player._recreating, ", $string_utils:from_value(verb_info(dobj, i), 1), ", ", $string_utils:from_value(verb_args(dobj, i), 1), ")");
    if (ticks_left() < 20 || seconds_left() < 2)
      suspend(1);
    endif
    player:tell(";set_verb_code(player._recreating, \"", i, "\", ", $string_utils:from_value(verb_code(dobj, i), 1), ")");
    if (ticks_left() < 20 || seconds_left() < 2)
      suspend(1);
    endif
  endfor
  player:tell("\"***End of script to recreate object ", dobj.name, ".");
endif