[1439] in Coldmud discussion meeting
First pass (ugly) script for MOO -> Cold
daemon@ATHENA.MIT.EDU (Thu Nov 19 20:12:26 1998
)
Date: Thu, 19 Nov 1998 20:03:46 -0500
From: Jonathan Bradshaw <jonathan@nrgup.com>
To: coldstuff@cold.org
I am trying to move from a MOO to Cold. The biggest hurdle is moving all the
objects such as users, rooms, exits and $things to Cold. Unfortunately I know
about as much about COLD and ColdCore as I did about LambdaMOO when I first
started (about zilch).
I decided I didn't want to do this one object at a time considering the large
number I had so I hacked up some scripts to help. They are UGLY. Anyone who
knows Cold will probably cringe when they see what I did but it works for >
90% of the objects and I can live with fixing up the rest.
I give you the scripts I used to do with as you wish. I'd love for someone
with either better MOO or COLD knowledge to refine them. In Tinyfugue I start
a log, run the program and then use /quote to send them to the Cold system.
-- CUT HERE --
;" This script creates an object to convert MOO objects to COLD "
;" Take the output of each program and feed it to Cold as the "
;" administrator with @mojo turned on. ";
;
;"WARNING: This is my first attempt at any type of conversion and I"
;"am aware that it needs SIGNIFICANT improvements. Contributions will"
;"be gladly accepted."
;
;"To allow passwords to work you must include your system CRYPT libraries"
;"when compiling cold."
;
;"The scripts should be run in the following order"
;
;"export_users()"
;"export_rooms()"
;"export_exits()"
;"export_homes()"
;"export_things()"
;"export_notes()"
;
@create $thing named convert
@verb convert:"export_users" this none this
@program convert:export_users
for p in (players())
if (((p != #2) && (p.first_connect_time != $maxint)) && (p.description != $player.description))
$command_utils:suspend_if_needed(0);
name = $string_utils:strip_all_but($string_utils:lowercase(p.name), "abcdefghijklmnopqrstuvwxyz1234567890");
player:tell(";var new; if(!(| valid($user_", name, ") |)) { new = $sys.create_user(\"", p.name, "\", \"", p.realname, "\", \"", p.email_address, "\");}");
player:tell(";|as $user_", name, "<$root>; created_on = ", p.first_connect_time, ";");
player:tell(";|as $user_", name, "<$user>; connected_at = ", p.last_connect_time, ";");
player:tell(";|as $user_", name, "<$user>; password = \"", p.password, "\";");
if ((p.gender == "male") || (p.gender == "female"))
player:tell(";|as $user_", name, "<$thing>; gender = $gender_", p.gender, ";");
endif
player:tell(";|as $user_", name, "; .set_user_info(\"rl-name\", $user_info, \"", p.realname, "\");");
player:tell(";|as $user_", name, "<$described>; prose = <$ctext_frob, [[\"", $string_utils:from_list(p:description(), " "), "\"], #[]]>;");
if (p.wizard)
player:tell("@promote ", p:title(), " to wizard");
elseif ($object_utils:isa(p, $prog))
player:tell("@promote ", p:title(), " to programmer");
elseif ($object_utils:isa(p, $builder))
player:tell("@promote ", p:title(), " to builder");
endif
endif
endfor
.
@verb convert:"export_rooms" this none this
@program convert:export_rooms
for room in ($object_utils:leaves_suspended($generic_room))
$command_utils:suspend_if_needed(0);
if ((room.entrances == {}) || (room:exits() == {}))
else
username = tostr("$user_", $string_utils:strip_all_but($string_utils:lowercase(room.owner.name), "abcdefghijklmnopqrstuvwxyz1234567890"));
name = tostr(room)[2..$];
value = $string_utils:from_list(room:description(), " ");
result = "";
while (q = index(value, "\"") || index(value, "\\"))
if (value[q] == "\"")
q = min(q, index(value + "\\", "\\"));
endif
result = ((result + value[1..q - 1]) + "\\") + value[q];
value = value[q + 1..length(value)];
endwhile
player:tell(";var p, new; if(!(| valid($room_", name, ") |)) { new = $place.spawn(); new.set_objname('room_", name, ");}");
player:tell(";|as $room_", name, "<$has_name>; name = ['prop, \"", room:title(), "\", \"", room:title(), "\"];");
player:tell(";|as $room_", name, "<$described>; prose = <$ctext_frob,[[\"", result ? result | value, "\"], #[]]>;");
player:tell("@chmanage $room_", name, " to ", username);
endif
endfor
.
@verb convert:"export_exits" this none this
@program convert:export_exits
for exit in ($object_utils:leaves_suspended($exit))
$command_utils:suspend_if_needed(0);
player:tell("@move me to $room_", tostr(exit.location)[2..$]);
player:tell("@dig ", exit.name, " to $room_", tostr(exit.dest)[2..$]);
player:tell("none");
player:tell("@move me to $the_pit");
endfor
.
@verb convert:"export_things" this none this
@program convert:export_things
for thing in ($object_utils:leaves_suspended($thing))
$command_utils:suspend_if_needed(0);
if (($object_utils:isa(thing, $exit) || $object_utils:isa(thing, $container)) || $object_utils:isa(thing, $note))
else
username = tostr("$user_", $string_utils:strip_all_but($string_utils:lowercase(thing.owner.name), "abcdefghijklmnopqrstuvwxyz1234567890"));
name = tostr(thing)[2..$];
value = $string_utils:from_list(thing:description(), " ");
result = "";
while (q = index(value, "\"") || index(value, "\\"))
if (value[q] == "\"")
q = min(q, index(value + "\\", "\\"));
endif
result = ((result + value[1..q - 1]) + "\\") + value[q];
value = value[q + 1..length(value)];
endwhile
player:tell(";var p, new; if(!(| valid($thing_", name, ") |)) { new = $thing.spawn(); new.set_objname('thing_", name, ");}");
player:tell(";|as $thing_", name, "<$has_name>; name = ['prop, \"", thing:title(), "\", \"", thing:title(), "\"];");
player:tell(";|as $thing_", name, "<$described>; prose = <$ctext_frob,[[\"", result ? result | value, "\"], #[]]>;");
player:tell("@chmanage $thing_", name, " to ", username);
player:tell("@move $thing_", name, " to ", username);
if ($object_utils:isa(thing.location, $player))
user = $string_utils:strip_all_but($string_utils:lowercase(thing.location.name), "abcdefghijklmnopqrstuvwxyz1234567890");
player:tell("@move $thing_", name, " to $user_", user);
else
player:tell("@move $thing_", name, " to $room_", tostr(thing.location)[2..$]);
endif
endif
endfor
.
@verb convert:"export_homes" this none this
@program convert:export_homes
for p in (players())
if ((((p != #2) && (p.first_connect_time != $maxint)) && (p.home != #267)) && (p.description != $player.description))
$command_utils:suspend_if_needed(0);
user = $string_utils:strip_all_but($string_utils:lowercase(p.name), "abcdefghijklmnopqrstuvwxyz1234567890");
name = tostr(p.home)[2..$];
player:tell("@set $user_", user, ":home=$room_", name);
player:tell("@move $user_", user, " to $room_", name);
endif
endfor
.
@verb convert:"export_notes" this none this
@program convert:export_notes
for thing in ($object_utils:leaves_suspended($note))
$command_utils:suspend_if_needed(0);
username = tostr("$user_", $string_utils:strip_all_but($string_utils:lowercase(thing.owner.name), "abcdefghijklmnopqrstuvwxyz1234567890"));
name = tostr(thing)[2..$];
value = $string_utils:from_list(thing:description(), " ");
result = "";
while (q = index(value, "\"") || index(value, "\\"))
if (value[q] == "\"")
q = min(q, index(value + "\\", "\\"));
endif
result = ((result + value[1..q - 1]) + "\\") + value[q];
value = value[q + 1..length(value)];
endwhile
player:tell(";var p, new; if(!(| valid($note_", name, ") |)) { new = $note.spawn(); new.set_objname('note_", name, ");}");
player:tell(";|as $note_", name, "<$has_name>; name = ['prop, \"", thing:title(), "\", \"", thing:title(), "\"];");
player:tell(";|as $note_", name, "<$described>; prose = <$ctext_frob,[[\"", result ? result | value, "\"], #[]]>;");
player:tell(";|as $note_", name, "<$has_text>; text = [\"", $string_utils:from_list(thing.text), "\"];");
player:tell("@chmanage $note_", name, " to ", username);
player:tell("@move $note_", name, " to ", username);
if ($object_utils:isa(thing.location, $player))
user = $string_utils:strip_all_but($string_utils:lowercase(thing.location.name), "abcdefghijklmnopqrstuvwxyz1234567890");
player:tell("@move $note_", name, " to $user_", user);
else
player:tell("@move $note_", name, " to $room_", tostr(thing.location)[2..$]);
endif
endfor
.
; "End of object creation"