home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #7 / amigamamagazinepolishissue1998.iso / rozrywka / rpg / amigamud / src / building / build1.m < prev    next >
Text File  |  1997-06-10  |  77KB  |  3,242 lines

  1. /*
  2.  * Amiga MUD
  3.  *
  4.  * Copyright (c) 1997 by Chris Gray
  5.  */
  6.  
  7. /*
  8.  * build - code to come after the full startup set to set up the commands
  9.  *    which allow simple room-building.
  10.  *    NOTE: most of the code must be 'utility', since we want the rooms,
  11.  *    etc. to be owned by the character issuing the commands.
  12.  */
  13.  
  14. private tp_build1 CreateTable()$
  15. use tp_build1
  16.  
  17. define tp_build r_playPen CreateThing(r_indoors)$
  18.  
  19. define tp_build p_rPlayPen CreateBoolProp()$
  20. define tp_build1 p_pActiveDir CreateIntProp()$
  21. define tp_build1 p_pActiveCode CreateStringProp()$
  22. define tp_build1 p_pActiveState CreateIntProp()$
  23. define tp_build1 p_pSaveState CreateIntProp()$
  24.     define tp_build1 st_noState     0$
  25.     define tp_build1 st_preCondition    1$
  26.     define tp_build1 st_condition    2$
  27.     define tp_build1 st_then        3$
  28.     define tp_build1 st_else        4$
  29.     define tp_build1 st_descTrue    5$
  30.     define tp_build1 st_descFalse    6$
  31.     define tp_build1 st_descResult    7$
  32.     define tp_build1 st_condition2    8$
  33.     define tp_build1 st_then2        9$
  34.     define tp_build1 st_else2        10$
  35.     define tp_build1 STRING_FIRST    20$
  36.     define tp_build1 STRING_OTHER    40$
  37. define tp_build1 p_pHadCondition CreateBoolProp()$
  38. define tp_build1 p_pCodeKind CreateIntProp()$
  39.     define tp_build1 ck_roomChecker    0$
  40.     define tp_build1 ck_objectChecker    1$
  41.     define tp_build1 ck_roomDesc    2$
  42.     define tp_build1 ck_objectDesc    3$
  43.     define tp_build1 ck_roomVoid    4$
  44.     define tp_build1 ck_objectVoid    5$
  45. define tp_build1 p_pNewName CreateStringProp()$
  46. define tp_build1 p_pActiveThing CreateThingProp()$
  47. define tp_build1 p_pActiveTable CreateTableProp()$
  48. define tp_build1 p_pActiveVerb CreateStringProp()$
  49.  
  50. define tp_build1 wh_character     0$
  51. define tp_build1 wh_room     1$
  52. define tp_build1 wh_object     2$
  53.  
  54. CharacterThing(SysAdmin)@p_pBuilder := true$
  55.  
  56. define tp_build1 g_build CreateGrammar()$
  57.  
  58. define tp_build1 proc utility v_build()bool:
  59.     string s;
  60.  
  61.     if Me()@p_pBuilder or Here()@p_rPlayPen then
  62.     s := GetTail();
  63.     if s = "" then
  64.         Print("Missing build command - "
  65.           "see builder's library for details.\n");
  66.         false
  67.     else
  68.         Parse(g_build, s) ~= 0
  69.     fi
  70.     else
  71.     Print("Sorry, you have not been enabled for building.\n");
  72.     false
  73.     fi
  74. corp;
  75.  
  76. VerbTail(G, "@", v_build)$
  77. Synonym(G, "@", "b")$
  78. Synonym(G, "@", "build")$
  79. Synonym(G, "@", "construct")$
  80.  
  81. define tp_build proc utility checkTable(string tableName)table:
  82.     table theTable;
  83.  
  84.     theTable := LookupTable(nil, tableName);
  85.     if theTable = nil then
  86.     if IsDefined(nil, tableName) then
  87.         Print("\"" + tableName + "\" is not a table.\n");
  88.     else
  89.         Print("\"" + tableName + "\" is not defined.\n");
  90.     fi;
  91.     nil
  92.     else
  93.     theTable
  94.     fi
  95. corp;
  96.  
  97. define tp_build1 proc utility findTable(string tableName; bool readOnly)table:
  98.     table theTable;
  99.  
  100.     if tableName == "public" then
  101.     if Me()@p_pBuilder or readOnly then
  102.         PublicTable()
  103.     else
  104.         Print("Only true builders can change the public symbol table.\n");
  105.         nil
  106.     fi
  107.     elif tableName == "private" then
  108.     PrivateTable()
  109.     else
  110.     checkTable(tableName)
  111.     fi
  112. corp;
  113.  
  114. /*****************************************************************************\
  115. *                                          *
  116. *        code to implement a 'compiler' for actions              *
  117. *                                          *
  118. \*****************************************************************************/
  119.  
  120. define tp_build1 proc utility error(string str)void:
  121.  
  122.     Print("*** " + str + ".\n");
  123.     if not Me()@p_pHidden then
  124.     OPrint(Capitalize(Me()@p_pName) +
  125.         " abruptly stops gesturing and grimaces.\n");
  126.     fi;
  127. corp;
  128.  
  129. define tp_build1 proc utility stringError(string w, str)void:
  130.     error("'" + w + "' " + str);
  131. corp;
  132.  
  133. define tp_build1 proc utility notCounter(string w)void:
  134.     stringError(w, "is not a defined counter");
  135. corp;
  136.  
  137. define tp_build1 proc utility notFlag(string w)void:
  138.     stringError(w, "is not a defined flag");
  139. corp;
  140.  
  141. define tp_build1 proc utility notString(string w)void:
  142.     stringError(w, "is not a defined string");
  143. corp;
  144.  
  145. define tp_build1 proc utility notObject(string w)void:
  146.     stringError(w, "is not an object-symbol");
  147. corp;
  148.  
  149. define tp_build1 proc utility notRoom(string w)void:
  150.     stringError(w, "is not a room-symbol");
  151. corp;
  152.  
  153. define tp_build1 proc utility checkWord(string w, nameTail1, nameTail2;
  154.                     int kind)bool:
  155.  
  156.     w == "character" + nameTail1 or w == "character" + nameTail2 or
  157.     w == "room" + nameTail1 or w == "room" + nameTail2 or
  158.     (kind = ck_objectChecker or kind = ck_objectDesc or
  159.     kind = ck_objectVoid) and
  160.     (w == "object" + nameTail1 or w == "object" + nameTail2)
  161. corp;
  162.  
  163. define tp_build1 proc utility pickWhich(string w, nameTail1, nameTail2)int:
  164.  
  165.     if w == "character" + nameTail1 or w == "character" + nameTail2 then
  166.     wh_character
  167.     elif w == "room" + nameTail1 or w == "room" + nameTail2 then
  168.     wh_room
  169.     else
  170.     /* do NOT check for "object" + nameTail */
  171.     wh_object
  172.     fi
  173. corp;
  174.  
  175. define tp_build1 proc utility doWhich(int which)string:
  176.  
  177.     case which
  178.     incase wh_character:
  179.     "Me()"
  180.     incase wh_room:
  181.     "Here()"
  182.     incase wh_object:
  183.     "It()"
  184.     default:
  185.     "xxx"
  186.     esac
  187. corp;
  188.  
  189. define tp_build1 proc utility doWhich2(int which)string:
  190.  
  191.     case which
  192.     incase wh_character:
  193.     "p_pCarrying"
  194.     incase wh_room:
  195.     "p_rContents"
  196.     incase wh_object:
  197.     "p_oContents"
  198.     default:
  199.     "xxx"
  200.     esac
  201. corp;
  202.  
  203. define tp_build1 proc utility roomToObject(int kind)void:
  204.  
  205.     Me()@p_pCodeKind :=
  206.     case kind
  207.     incase ck_roomChecker:
  208.         ck_objectChecker
  209.     incase ck_roomDesc:
  210.         ck_objectDesc
  211.     incase ck_roomVoid:
  212.         ck_objectVoid
  213.     default:
  214.         kind
  215.     esac;
  216. corp;
  217.  
  218. define tp_build1 proc utility checkStringSpecials(string s; int kind;
  219.                           string code)string:
  220.     int which, len, pos;
  221.     string w;
  222.     property string theString;
  223.     property int theCounter;
  224.  
  225.     if SubString(s, 0, 1) = "@" then
  226.     SetTail(SubString(s, 1, Length(s) - 1));
  227.     w := GetWord();
  228.     if checkWord(w, "string", "", kind) then
  229.         which := pickWhich(w, "string", "");
  230.         w := GetWord();
  231.         if w = "" then
  232.         error("Missing string-symbol");
  233.         else
  234.         theString := LookupString(nil, w);
  235.         if theString = nil then
  236.             notString(w);
  237.         else
  238.             code := code + "\"+" + doWhich(which) + "@" + w + "+\"";
  239.         fi;
  240.         fi;
  241.     elif checkWord(w, "counter", "", kind) then
  242.         which := pickWhich(w, "counter", "");
  243.         w := GetWord();
  244.         if w = "" then
  245.         error("Missing counter-symbol");
  246.         else
  247.         theCounter := LookupCounter(nil, w);
  248.         if theCounter = nil then
  249.             notCounter(w);
  250.         else
  251.             code := code + "\"+IntToString(" + doWhich(which) + "@" +
  252.             w + ")+\"";
  253.         fi;
  254.         fi;
  255.     elif checkWord(w, "name", "", kind) then
  256.         case pickWhich(w, "name", "")
  257.         incase wh_character:
  258.         code := code + "\"+Me()@p_pName+\"";
  259.         incase wh_room:
  260.         code := code + "\"+Here()@p_rName+\"";
  261.         incase wh_object:
  262.         code := code + "\"+FormatName(It()@p_oName)+\"";
  263.         esac;
  264.     else
  265.         stringError(w, "is not a known text escape");
  266.     fi;
  267.     else
  268.     len := Length(s);
  269.     w := "";
  270.     while
  271.         pos := Index(s, "\"");
  272.         pos >= 0
  273.     do
  274.         w := w + SubString(s, 0, pos) + "\\\"";
  275.         len := len - pos - 1;
  276.         s := SubString(s, pos + 1, len);
  277.     od;
  278.     code := code + w + s;
  279.     fi;
  280.     code
  281. corp;
  282.  
  283. define tp_build1 proc utility continuePrompt(int state, kind)void:
  284.  
  285.     case state
  286.     incase st_preCondition:
  287.     if kind = ck_roomVoid or kind = ck_objectVoid then
  288.         Print("Continue entering actions:\n");
  289.         ignore SetPrompt("* actions> ");
  290.     else
  291.         Print("Continue entering pre-condition actions:\n");
  292.         ignore SetPrompt("* pre-condition actions> ");
  293.     fi;
  294.     incase st_then:
  295.     incase st_then2:
  296.     Print("Continue entering the true actions:\n");
  297.     ignore SetPrompt("* true actions> ");
  298.     incase st_else:
  299.     incase st_else2:
  300.     Print("Continue entering the false actions:\n");
  301.     ignore SetPrompt("* false actions> ");
  302.     esac;
  303. corp;
  304.  
  305. define tp_build1 proc utility conditionPrompt()void:
  306.     Print("Now enter the conditions for the test:\n");
  307.     ignore SetPrompt("* condition> ");
  308. corp;
  309.  
  310. define tp_build1 proc utility truePrompt()void:
  311.     Print("Now enter the actions to do if condition is true:\n");
  312.     ignore SetPrompt("* true actions> ");
  313. corp;
  314.  
  315. define tp_build1 proc utility falsePrompt()void:
  316.     Print("Now enter the actions to do if condition is false:\n");
  317.     ignore SetPrompt("* false actions> ");
  318. corp;
  319.  
  320. define tp_build1 proc utility protectedString(string w)bool:
  321.     if w = "p_pName" or w = "p_rName" or w = "p_oName" then
  322.     error("Sorry - you can't modify that string");
  323.     true
  324.     else
  325.     false
  326.     fi
  327. corp;
  328.  
  329. define tp_build1 proc utility compileCode(string code)void:
  330.     action a;
  331.     thing me;
  332.  
  333.     me := Me();
  334.     a := StringToAction(code);
  335.     if a = nil then
  336.     error("Errors in action - not defined");
  337.     else
  338.     if DefineAction(me@p_pActiveTable, me@p_pNewName, a) then
  339.         Print("Action '" + me@p_pNewName + "' defined.\n");
  340.     fi;
  341.     if not me@p_pHidden then
  342.         OPrint(Capitalize(me@p_pName) + " finishes gesturing.\n");
  343.     fi;
  344.     fi;
  345. corp;
  346.  
  347. define tp_build1 proc utility bv_actionLineHandler(string s)void:
  348.     thing me, theThing, theRoom;
  349.     int state, kind, value, which;
  350.     string code, w, w2, w3, errMess;
  351.     action a;
  352.     property bool theFlag;
  353.     property int theCounter;
  354.     property string theString;
  355.     bool ending, tf, isNegative;
  356.  
  357.     ending := false;
  358.     me := Me();
  359.     state := me@p_pActiveState;
  360.     code := me@p_pActiveCode;
  361.     kind := me@p_pCodeKind;
  362.     if s = "." then
  363.     case state
  364.     incase st_preCondition:
  365.         /* end of pre-condition actions */
  366.         if kind = ck_roomVoid or kind = ck_objectVoid then
  367.         compileCode(code);
  368.         ending := true;
  369.         else
  370.         state := st_condition;
  371.         conditionPrompt();
  372.         fi;
  373.     incase st_condition:
  374.         /* end of condition */
  375.         if not me@p_pHadCondition then
  376.         if kind = ck_roomDesc or kind = ck_objectDesc then
  377.             if code ~= "" then
  378.             code := code + ";";
  379.             fi;
  380.             code := code + "\"";
  381.             state := st_descResult + STRING_FIRST;
  382.             Print("Now enter the result description:\n");
  383.             ignore SetPrompt("* description result> ");
  384.         else
  385.             if kind = ck_objectChecker then
  386.             code := code + ";succeed";
  387.             else
  388.             code := code + ";continue";
  389.             fi;
  390.             compileCode(code);
  391.             ending := true;
  392.         fi;
  393.         else
  394.         code := code + " then ";
  395.         state := st_then;
  396.         truePrompt();
  397.         fi;
  398.     incase st_then:
  399.         /* end of 'then' actions */
  400.         if kind = ck_roomDesc or kind = ck_objectDesc then
  401.         code := code + "\"";
  402.         state := st_descTrue + STRING_FIRST;
  403.         Print("Now enter the true description result:\n");
  404.         ignore SetPrompt("* true description result> ");
  405.         else
  406.         if kind = ck_objectChecker then
  407.             code := code + "succeed else ";
  408.         else
  409.             code := code + "continue else ";
  410.         fi;
  411.         state := st_else;
  412.         falsePrompt();
  413.         fi;
  414.     incase st_else:
  415.         /* end of 'else' actions */
  416.         if kind = ck_roomDesc or kind = ck_objectDesc then
  417.         code := code + "\"";
  418.         state := st_descFalse + STRING_FIRST;
  419.         Print("Now enter the false description result:\n");
  420.         ignore SetPrompt("* false description result> ");
  421.         else
  422.         code := code + "fail fi";
  423.         compileCode(code);
  424.         ending := true;
  425.         fi;
  426.     incase st_condition2:
  427.         if not me@p_pHadCondition then
  428.         error("Condition is required on 'if'");
  429.         ending := true;
  430.         else
  431.         code := code + " then ";
  432.         state := st_then2;
  433.         truePrompt();
  434.         fi;
  435.     incase st_then2:
  436.         code := code + "else ";
  437.         state := st_else2;
  438.         falsePrompt();
  439.     incase st_else2:
  440.         code := code + "fi;";
  441.         state := me@p_pSaveState;
  442.         me -- p_pSaveState;
  443.         continuePrompt(state, kind);
  444.     default:
  445.         /* end of a string */
  446.         if state >= STRING_OTHER then
  447.         state := state - STRING_OTHER;
  448.         else
  449.         state := state - STRING_FIRST;
  450.         fi;
  451.         case state
  452.         incase st_preCondition:
  453.         incase st_then:
  454.         incase st_else:
  455.         incase st_then2:
  456.         incase st_else2:
  457.         code := code + "\\n\");";
  458.         continuePrompt(state, kind);
  459.         incase st_descTrue:
  460.         /* end of 'then' description result */
  461.         code := code + "\" else ";
  462.         state := st_else;
  463.         falsePrompt();
  464.         incase st_descFalse:
  465.         /* end of 'else' description result */
  466.         code := code + "\" fi";
  467.         compileCode(code);
  468.         ending := true;
  469.         incase st_descResult:
  470.         /* end of the description result string */
  471.         code := code + "\"";
  472.         compileCode(code);
  473.         ending := true;
  474.         esac;
  475.     esac;
  476.     else
  477.     errMess := "Missing flag/counter-symbol";
  478.     SetTail(s);
  479.     w := GetWord();
  480.     if state = st_condition or state = st_condition2 then
  481.         /* handling conditions */
  482.         if me@p_pHadCondition then
  483.         code := code + " and ";
  484.         else
  485.         code := code + "if ";
  486.         me@p_pHadCondition := true;
  487.         fi;
  488.         if w == "not" then
  489.         code := code + "not ";
  490.         w := GetWord();
  491.         fi;
  492.         if w == "fail" then
  493.         code := code + "false";
  494.         elif checkWord(w, "flag", "", kind) then
  495.         which := pickWhich(w, "flag", "");
  496.         w := GetWord();
  497.         if w = "" then
  498.             error(errMess);
  499.             ending := true;
  500.         else
  501.             theFlag := LookupFlag(nil, w);
  502.             if theFlag ~= nil then
  503.             code := code + doWhich(which) + "@" + w;
  504.             else
  505.             notFlag(w);
  506.             ending := true;
  507.             fi;
  508.         fi;
  509.         elif checkWord(w, "counter", "", kind) then
  510.         which := pickWhich(w, "counter", "");
  511.         w := GetWord();
  512.         if w = "" then
  513.             error(errMess);
  514.             ending := true;
  515.         else
  516.             theCounter := LookupCounter(nil, w);
  517.             if theCounter ~= nil then
  518.             w2 := GetWord();
  519.             isNegative := false;
  520.             if SubString(w2, 0, 1) = "-" then
  521.                 isNegative := true;
  522.                 w2 := SubString(w2, 1, Length(w2) - 1);
  523.             elif SubString(w2, 0, 1) = "+" then
  524.                 w2 := SubString(w2, 1, Length(w2) - 1);
  525.             fi;
  526.             value := StringToInt(w2);
  527.             if value < 0 then
  528.                 error("Missing or invalid counter value");
  529.                 ending := true;
  530.             else
  531.                 if isNegative then
  532.                 value := -value;
  533.                 fi;
  534.                 code := code + doWhich(which) + "@" + w + "=" +
  535.                 IntToString(value);
  536.             fi;
  537.             else
  538.             notCounter(w);
  539.             ending := true;
  540.             fi;
  541.         fi;
  542.         elif checkWord(w, "hasspecific", "", kind) then
  543.         which := pickWhich(w, "hasspecific", "");
  544.         w := GetWord();
  545.         if w = "" then
  546.             error("Missing object-symbol");
  547.             ending := true;
  548.         else
  549.             theThing := LookupThing(nil, w);
  550.             if theThing ~= nil and theThing@p_oName ~= "" then
  551.             code := code + "FindElement(" + doWhich(which) + "@" +
  552.                 doWhich2(which) + "," + w + ")~=-1";
  553.             else
  554.             notObject(w);
  555.             ending := true;
  556.             fi;
  557.         fi;
  558.         elif checkWord(w, "haschild", "", kind) then
  559.         which := pickWhich(w, "haschild", "");
  560.         w := GetWord();
  561.         if w = "" then
  562.             error("Missing object child form");
  563.             ending := true;
  564.         else
  565.             theThing := LookupThing(nil, w);
  566.             if theThing ~= nil and theThing@p_oName ~= "" then
  567.             code := code + "FindChildOnList(" + doWhich(which) +
  568.                 "@" + doWhich2(which) + "," + w + ")";
  569.             else
  570.             notObject(w);
  571.             ending := true;
  572.             fi;
  573.         fi;
  574.         elif checkWord(w, "hasname", "", kind) then
  575.         which := pickWhich(w, "hasname", "");
  576.         w := GetWord();
  577.         if w = "" then
  578.             error("Missing object name form");
  579.             ending := true;
  580.         else
  581.             code := code + "FindName(" + doWhich(which) + "@" +
  582.                 doWhich2(which) + ",p_oName,\"" + Strip(w) +
  583.                 "\")~=fail";
  584.         fi;
  585.         elif checkWord(w, "hasflag", "", kind) then
  586.         which := pickWhich(w, "hasflag", "");
  587.         w := GetWord();
  588.         if w = "" then
  589.             error(errMess);
  590.             ending := true;
  591.         else
  592.             theFlag := LookupFlag(nil, w);
  593.             if theFlag = nil then
  594.             notFlag(w);
  595.             ending := true;
  596.             else
  597.             code := code + "FindFlagOnList(" + doWhich(which) +
  598.                 "@" + doWhich2(which) + "," + w + ")";
  599.             fi;
  600.         fi;
  601.         elif w == "random" then
  602.         w := GetWord();
  603.         value := StringToInt(w);
  604.         if value < 1 then
  605.             error("Missing or invalid random range");
  606.             ending := true;
  607.         else
  608.             code := code + "Random(999)<" + w;
  609.         fi;
  610.         else
  611.         stringError(w, "is not a known condition");
  612.         ending := true;
  613.         fi;
  614.     elif state >= STRING_OTHER then
  615.         /* getting a string - subsequent hunk */
  616.         if s ~= "" then
  617.         w := SubString(s, 0, 1);
  618.         if w ~= "," and w ~= "." and w ~= ";" and w ~= "!" and
  619.             w ~= "?" and w ~= ":"
  620.         then
  621.             code := code + " ";
  622.         fi;
  623.         code := checkStringSpecials(s, kind, code);
  624.         fi;
  625.     elif state >= STRING_FIRST then
  626.         /* getting a string - first hunk */
  627.         code := checkStringSpecials(s, kind, code);
  628.         state := state - STRING_FIRST + STRING_OTHER;
  629.     else
  630.         /* handling statements */
  631.         if checkWord(w, "setflag", "clearflag", kind) then
  632.         which := pickWhich(w, "setflag", "clearflag");
  633.         tf := w == "charactersetflag" or w == "roomsetflag" or
  634.             w == "objectsetflag";
  635.         w := GetWord();
  636.         if w = "" then
  637.             error(errMess);
  638.             ending := true;
  639.         else
  640.             theFlag := LookupFlag(nil, w);
  641.             if theFlag = nil then
  642.             notFlag(w);
  643.             ending := true;
  644.             else
  645.             if tf then
  646.                 code := code + doWhich(which) + "@" + w +
  647.                 ":=true;";
  648.             else
  649.                 code := code + doWhich(which) + "--" + w + ";";
  650.             fi;
  651.             fi;
  652.         fi;
  653.         elif checkWord(w, "inccounter", "deccounter", kind) then
  654.         which := pickWhich(w, "inccounter", "deccounter");
  655.         tf := w == "characterinccounter" or w == "roominccounter" or
  656.             w == "objectinccounter";
  657.         w := GetWord();
  658.         if w = "" then
  659.             error(errMess);
  660.             ending := true;
  661.         else
  662.             theCounter := LookupCounter(nil, w);
  663.             if theCounter = nil then
  664.             notCounter(w);
  665.             ending := true;
  666.             else
  667.             w2 := GetWord();
  668.             if w2 ~= "" then
  669.                 value := StringToInt(w2);
  670.                 if value < 0 then
  671.                 error("Invalid inc/dec value");
  672.                 ending := true;
  673.                 fi;
  674.             else
  675.                 value := 1;
  676.             fi;
  677.             w2 := doWhich(which);
  678.             code := code + w2 + "@" + w + ":=" + w2 + "@" + w +
  679.                 if tf then "+" else "-" fi +
  680.                 IntToString(value) + ";";
  681.             fi;
  682.         fi;
  683.         elif checkWord(w, "setcounter", "", kind) then
  684.         which := pickWhich(w, "setcounter", "");
  685.         w := GetWord();
  686.         if w = "" then
  687.             error(errMess);
  688.             ending := true;
  689.         else
  690.             theCounter := LookupCounter(nil, w);
  691.             if theCounter ~= nil then
  692.             w2 := GetWord();
  693.             isNegative := false;
  694.             if SubString(w2, 0, 1) = "-" then
  695.                 isNegative := true;
  696.                 w2 := SubString(w2, 1, Length(w2) - 1);
  697.             elif SubString(w2, 0, 1) = "+" then
  698.                 w2 := SubString(w2, 1, Length(w2) - 1);
  699.             fi;
  700.             value := StringToInt(w2);
  701.             if value < 0 then
  702.                 error("Missing or invalid counter value");
  703.                 ending := true;
  704.             else
  705.                 if value = 0 then
  706.                 code := code + doWhich(which) + "--" + w + ";";
  707.                 else
  708.                 if isNegative then
  709.                     value := -value;
  710.                 fi;
  711.                 code := code + doWhich(which) + "@" +
  712.                     w + ":=" + IntToString(value) + ";";
  713.                 fi;
  714.             fi;
  715.             else
  716.             notCounter(w);
  717.             ending := true;
  718.             fi;
  719.         fi;
  720.         elif checkWord(w, "setstring", "", kind) then
  721.         which := pickWhich(w, "setstring", "");
  722.         w := GetWord();
  723.         if w = "" then
  724.             error("Missing string-symbol");
  725.             ending := true;
  726.         else
  727.             theString := LookupString(nil, w);
  728.             if theString = nil then
  729.             notString(w);
  730.             ending := true;
  731.             elif protectedString(w) then
  732.             ending := true;
  733.             else
  734.             w3 := GetWord();
  735.             if w3 = "" then
  736.                 error("Missing string identifier");
  737.                 ending := true;
  738.             else
  739.                 if w3 == "date" or w3 == "time" then
  740.                 w2 := "Date()";
  741.                 elif w3 == "charactername" then
  742.                 w2 := "Me()@p_pName";
  743.                 elif w3 == "roomname" then
  744.                 w2 := "Here()@p_rName";
  745.                 elif w3 == "objectname" and
  746.                 (kind = ck_objectChecker or
  747.                  kind = ck_objectDesc or
  748.                  kind = ck_objectVoid)
  749.                 then
  750.                 w2 := "FormatName(It()@p_oName)";
  751.                 else
  752.                 stringError(w3,
  753.                     "is not a known string identifier");
  754.                 ending := true;
  755.                 w2 := "\"\"";
  756.                 fi;
  757.                 code := code + doWhich(which) + "@" + w + ":=" +
  758.                 w2 + ";";
  759.             fi;
  760.             fi;
  761.         fi;
  762.         elif checkWord(w, "clearstring", "", kind) then
  763.         which := pickWhich(w, "clearstring", "");
  764.         w := GetWord();
  765.         if w = "" then
  766.             error("Missing string-symbol");
  767.             ending := true;
  768.         elif protectedString(w) then
  769.             ending := true;
  770.         else
  771.             theString := LookupString(nil, w);
  772.             if theString ~= nil then
  773.             code := code + doWhich(which) + "--" + w + ";";
  774.             else
  775.             notString(w);
  776.             ending := true;
  777.             fi;
  778.         fi;
  779.         elif w == "clonehere" or w == "cloneat" then
  780.         if not Me()@p_pBuilder then
  781.             error("Sorry, only true builders can clone things");
  782.             ending := true;
  783.         elif w = "cloneat" then
  784.             w2 := GetWord();
  785.             if w2 = "" then
  786.             error("Missing room-symbol");
  787.             ending := true;
  788.             else
  789.             theRoom := LookupThing(nil, w2);
  790.             if theRoom = nil or theRoom@p_rName = "" then
  791.                 notRoom(w2);
  792.                 ending := true;
  793.             fi;
  794.             fi;
  795.         fi;
  796.         w3 := GetWord();
  797.         if ending or w3 = "" then
  798.             if not ending then
  799.             error("Missing object-symbol");
  800.             ending := true;
  801.             fi;
  802.         else
  803.             theThing := LookupThing(nil, w3);
  804.             if theThing ~= nil and theThing@p_oName ~= "" then
  805.             code := code + "SetIt(CreateThing(" + w3 +
  806.                 "));AddTail(" +
  807.                 if w == "clonehere" then "Here()" else w2 fi +
  808.                 "@p_rContents,It());" +
  809.                 "SetThingStatus(It(),ts_public);" +
  810.                 "GiveThing(It(),Character(\"SysAdmin\"));" +
  811.                 "It()@p_oCarryer:=Me();" +
  812.                 "It()@p_oCreator:=Me();";
  813.             roomToObject(kind);
  814.             else
  815.             notObject(w3);
  816.             ending := true;
  817.             fi;
  818.         fi;
  819.         elif w == "destruct" and
  820.         (kind = ck_objectChecker or kind = ck_objectDesc or
  821.          kind = ck_objectVoid)
  822.         then
  823.         code := code + "ClearThing(It());" +
  824.             "DelElement(Me()@p_pCarrying,It());";
  825.         elif w == "drop" and
  826.         (kind = ck_objectChecker or kind = ck_objectDesc or
  827.          kind = ck_objectVoid)
  828.         then
  829.         code := code + "ignore DoDrop(Here(),Me(),It());";
  830.         elif w == "dropto" and
  831.         (kind = ck_objectChecker or kind = ck_objectDesc or
  832.          kind = ck_objectVoid)
  833.         then
  834.         w := GetWord();
  835.         if w = "" then
  836.             error("Missing room-symbol");
  837.             ending := true;
  838.         else
  839.             theRoom := LookupThing(nil, w);
  840.             if theRoom ~= nil and theRoom@p_rName ~= "" then
  841.             code := code + "ignore DoDrop(" + w + ",Me(),It());";
  842.             else
  843.             notRoom(w);
  844.             ending := true;
  845.             fi;
  846.         fi;
  847.         elif w == "setit" then
  848.         w := GetWord();
  849.         if w = "" then
  850.             error("Missing object kind");
  851.             ending := true;
  852.         else
  853.             w2 := GetWord();
  854.             if w2 = "" then
  855.             error("Missing object-symbol/flag-symbol/string");
  856.             ending := true;
  857.             else
  858.             if w == "specific" then
  859.                 theThing := LookupThing(nil, w2);
  860.                 if theThing ~= nil and theThing@p_oName ~= "" then
  861.                 code := code + "SetIt(" + w2 + ");";
  862.                 else
  863.                 notObject(w2);
  864.                 ending := true;
  865.                 fi;
  866.             elif checkWord(w, "child", "", kind) then
  867.                 theThing := LookupThing(nil, w2);
  868.                 if theThing ~= nil and theThing@p_oName ~= "" then
  869.                 which := pickWhich(w, "child", "");
  870.                 code := code + "ignore FindChildOnList(" +
  871.                     doWhich(which) + "@" + doWhich2(which) +
  872.                     "," + w2 + ");SetIt(FindResult());";
  873.                 else
  874.                 notObject(w2);
  875.                 ending := true;
  876.                 fi;
  877.             elif checkWord(w, "flag", "", kind) then
  878.                 theFlag := LookupFlag(nil, w2);
  879.                 if theFlag ~= nil then
  880.                 which := pickWhich(w, "flag", "");
  881.                 code := code + "ignore FindFlagOnList(" +
  882.                     doWhich(which) + "@" + doWhich2(which) +
  883.                     "," + w2 + ");SetIt(FindResult());";
  884.                 else
  885.                 notFlag(w);
  886.                 ending := true;
  887.                 fi;
  888.             elif checkWord(w, "name", "", kind) then
  889.                 which := pickWhich(w, "name", "");
  890.                 code := code + "ignore FindName(" +
  891.                 doWhich(which) + "@" + doWhich2(which) +
  892.                 ",p_oName,\"" + Strip(w2) +
  893.                 "\");SetIt(FindResult());";
  894.             else
  895.                 stringError(w, "is not a known object kind");
  896.                 ending := true;
  897.             fi;
  898.             roomToObject(kind);
  899.             fi;
  900.         fi;
  901.         elif w == "saycharacter" then
  902.         code := code + "Print(\"";
  903.         state := state + STRING_FIRST;
  904.         Print("Enter the text to be shown to the character:\n");
  905.         ignore SetPrompt("* character text> ");
  906.         elif w == "sayothers" then
  907.         code := code + "OPrint(\"";
  908.         state := state + STRING_FIRST;
  909.         Print("Enter the text to be shown to others:\n");
  910.         ignore SetPrompt("* others text> ");
  911.         elif w == "if" then
  912.         if me@p_pSaveState ~= st_noState then
  913.             error("Sorry, you cannot nest 'if's");
  914.             ending := true;
  915.         else
  916.             me@p_pSaveState := state;
  917.             me@p_pHadCondition := false;
  918.             state := st_condition2;
  919.             Print("Enter the condition for the if:\n");
  920.             ignore SetPrompt("* condition> ");
  921.         fi;
  922.         else
  923.         stringError(w, "is not a known action");
  924.         ending := true;
  925.         fi;
  926.     fi;
  927.     fi;
  928.     if ending then
  929.     me -- p_pActiveCode;
  930.     me -- p_pActiveState;
  931.     me -- p_pSaveState;
  932.     me -- p_pHadCondition;
  933.     me -- p_pCodeKind;
  934.     me -- p_pActiveDir;
  935.     me -- p_pNewName;
  936.     me -- p_pActiveTable;
  937.     GetCheckedEnd();
  938.     else
  939.     me@p_pActiveCode := code;
  940.     me@p_pActiveState := state;
  941.     fi;
  942. corp;
  943.  
  944. define tp_build1 proc utility getAction(table theTable; string name;
  945.                     int kind)bool:
  946.     thing me;
  947.  
  948.     me := Me();
  949.     me@p_pActiveTable := theTable;
  950.     me@p_pNewName := name;
  951.     me@p_pCodeKind := kind;
  952.     me@p_pActiveCode := "";
  953.     me@p_pActiveState := st_preCondition;
  954.     me -- p_pSaveState;
  955.     me@p_pHadCondition := false;
  956.     me -- p_pActiveDir;
  957.     if not me@p_pHidden then
  958.     OPrint(Capitalize(me@p_pName) + " starts gesturing arcanely.\n");
  959.     fi;
  960.     if kind = ck_roomVoid or kind = ck_objectVoid then
  961.     Print("Enter the actions:\n");
  962.     GetCheckedDescription("actions> ", bv_actionLineHandler)
  963.     else
  964.     Print("Enter the pre-condition actions:\n");
  965.     GetCheckedDescription("pre-condition actions> ", bv_actionLineHandler)
  966.     fi
  967. corp;
  968.  
  969. /*****************************************************************************\
  970. *                                          *
  971. *        now the actual building subcommands                  *
  972. *                                          *
  973. \*****************************************************************************/
  974.  
  975. /*****************************************************************************\
  976. *                                          *
  977. *        first, some generic building subcommands              *
  978. *                                          *
  979. \*****************************************************************************/
  980.  
  981. define tp_build1 proc utility checkBuilder()bool:
  982.  
  983.     /* This check is used in @table, @use and @unuse. The most important
  984.        is in @use, since otherwise a character in the PlayPen could
  985.        "@use t_base", and then write actions which increased his money,
  986.        etc.! */
  987.     if Me()@p_pBuilder then
  988.     true
  989.     else
  990.     Print("Sorry, only true builders can use that command.\n");
  991.     false
  992.     fi
  993. corp;
  994.  
  995. define tp_build1 proc utility bv_showtable(string tableName)bool:
  996.     table theTable;
  997.  
  998.     if tableName = "" then
  999.     Print("Use is: @showtable <table>\n");
  1000.     false
  1001.     else
  1002.     theTable := findTable(tableName, true);
  1003.     if theTable = nil then
  1004.         false
  1005.     else
  1006.         ShowTable(theTable);
  1007.         true
  1008.     fi
  1009.     fi
  1010. corp;
  1011.  
  1012. Verb1(g_build, "showtable", 0, bv_showtable)$
  1013.  
  1014. define tp_build1 proc utility bv_describesymbol()bool:
  1015.     string tableName, what;
  1016.     table theTable;
  1017.  
  1018.     tableName := GetWord();
  1019.     what := GetWord();
  1020.     if tableName = "" or what = "" or GetWord() ~= "" then
  1021.     Print("Use is: @describesymbol <table> <symbol>\n");
  1022.     false
  1023.     else
  1024.     theTable := findTable(tableName, true);
  1025.     if theTable = nil then
  1026.         false
  1027.     else
  1028.         DescribeSymbol(theTable, Strip(what));
  1029.         true
  1030.     fi
  1031.     fi
  1032. corp;
  1033.  
  1034. VerbTail(g_build, "describesymbol", bv_describesymbol)$
  1035. Synonym(g_build, "describesymbol", "describe")$
  1036. Synonym(g_build, "describesymbol", "d")$
  1037.  
  1038. define tp_build1 proc utility bv_deletesymbol()bool:
  1039.     string tableName, what;
  1040.     table theTable;
  1041.  
  1042.     tableName := GetWord();
  1043.     what := GetWord();
  1044.     if tableName = "" or what = "" or GetWord() ~= "" then
  1045.     Print("Use is: @deletesymbol <table> <symbol>\n");
  1046.     false
  1047.     else
  1048.     theTable := findTable(tableName, false);
  1049.     if theTable = nil then
  1050.         false
  1051.     else
  1052.         ignore DeleteSymbol(theTable, Strip(what));
  1053.         true
  1054.     fi
  1055.     fi
  1056. corp;
  1057.  
  1058. VerbTail(g_build, "deletesymbol", bv_deletesymbol)$
  1059. Synonym(g_build, "deletesymbol", "delete")$
  1060.  
  1061. define tp_build1 proc utility bv_movesymbol()bool:
  1062.     string fromTableName, toTableName, what;
  1063.     table fromTable, toTable;
  1064.  
  1065.     fromTableName := GetWord();
  1066.     toTableName := GetWord();
  1067.     what := GetWord();
  1068.     if fromTableName = "" or toTableName = "" or what = "" or GetWord() ~= ""
  1069.     then
  1070.     Print("Use is: @movesymbol <from-table> <to-table> <symbol>\n");
  1071.     false
  1072.     else
  1073.     fromTable := findTable(fromTableName, false);
  1074.     if fromTable = nil then
  1075.         false
  1076.     else
  1077.         toTable := findTable(toTableName, false);
  1078.         if toTable = nil then
  1079.         false
  1080.         else
  1081.         ignore MoveSymbol(fromTable, toTable, Strip(what));
  1082.         true
  1083.         fi
  1084.     fi
  1085.     fi
  1086. corp;
  1087.  
  1088. VerbTail(g_build, "movesymbol", bv_movesymbol)$
  1089. Synonym(g_build, "movesymbol", "move")$
  1090.  
  1091. define tp_build1 proc utility bv_renamesymbol()bool:
  1092.     string tableName, oldName, newName;
  1093.     table theTable;
  1094.  
  1095.     tableName := GetWord();
  1096.     oldName := GetWord();
  1097.     newName := GetWord();
  1098.     if tableName = "" or oldName = "" or newName = "" or GetWord() ~= "" then
  1099.     Print("Use is: @renamesymbol <table> <old-symbol> <new-symbol>\n");
  1100.     false
  1101.     else
  1102.     theTable := findTable(tableName, false);
  1103.     if theTable = nil then
  1104.         false
  1105.     else
  1106.         RenameSymbol(theTable, Strip(oldName), Strip(newName))
  1107.     fi
  1108.     fi
  1109. corp;
  1110.  
  1111. VerbTail(g_build, "renamesymbol", bv_renamesymbol)$
  1112. Synonym(g_build, "renamesymbol", "rename")$
  1113.  
  1114. define tp_build1 proc utility bv_flag()bool:
  1115.     string tableName, name;
  1116.     table theTable;
  1117.  
  1118.     tableName := GetWord();
  1119.     name := GetWord();
  1120.     if tableName = "" or name = "" or GetWord() ~= "" then
  1121.     Print("Use is: @flag <table> <symbol>\n");
  1122.     false
  1123.     else
  1124.     theTable := findTable(tableName, false);
  1125.     if theTable = nil then
  1126.         false
  1127.     else
  1128.         DefineFlag(theTable, name, CreateBoolProp())
  1129.     fi
  1130.     fi
  1131. corp;
  1132.  
  1133. VerbTail(g_build, "flag", bv_flag)$
  1134.  
  1135. define tp_build1 proc utility bv_counter()bool:
  1136.     string tableName, name;
  1137.     table theTable;
  1138.  
  1139.     tableName := GetWord();
  1140.     name := GetWord();
  1141.     if tableName = "" or name = "" or GetWord() ~= "" then
  1142.     Print("Use is: @counter <table> <symbol>\n");
  1143.     false
  1144.     else
  1145.     theTable := findTable(tableName, false);
  1146.     if theTable = nil then
  1147.         false
  1148.     else
  1149.         DefineCounter(theTable, name, CreateIntProp())
  1150.     fi
  1151.     fi
  1152. corp;
  1153.  
  1154. VerbTail(g_build, "counter", bv_counter)$
  1155.  
  1156. define tp_build1 proc utility bv_string()bool:
  1157.     string tableName, name;
  1158.     table theTable;
  1159.  
  1160.     tableName := GetWord();
  1161.     name := GetWord();
  1162.     if tableName = "" or name = "" or GetWord() ~= "" then
  1163.     Print("Use is: @string <table> <symbol>\n");
  1164.     false
  1165.     else
  1166.     theTable := findTable(tableName, false);
  1167.     if theTable = nil then
  1168.         false
  1169.     else
  1170.         DefineString(theTable, name, CreateStringProp())
  1171.     fi
  1172.     fi
  1173. corp;
  1174.  
  1175. VerbTail(g_build, "string", bv_string)$
  1176.  
  1177. define tp_build1 proc utility bv_table()bool:
  1178.     string tableName, name;
  1179.     table theTable;
  1180.  
  1181.     tableName := GetWord();
  1182.     name := GetWord();
  1183.     if not checkBuilder() then
  1184.     false
  1185.     elif tableName = "" or name = "" or GetWord() ~= "" then
  1186.     Print("Use is: @table <existing-table-name> <new-table-name>\n");
  1187.     false
  1188.     else
  1189.     theTable := findTable(tableName, false);
  1190.     if theTable = nil then
  1191.         false
  1192.     else
  1193.         DefineTable(theTable, name, CreateTable())
  1194.     fi
  1195.     fi
  1196. corp;
  1197.  
  1198. VerbTail(g_build, "table", bv_table)$
  1199.  
  1200. define tp_build1 proc utility bv_use(string tableName)bool:
  1201.     table theTable;
  1202.  
  1203.     if not checkBuilder() then
  1204.     false
  1205.     elif tableName = "" then
  1206.     Print("Use is: @use <table>\n");
  1207.     false
  1208.     else
  1209.     theTable := checkTable(tableName);
  1210.     if theTable = nil then
  1211.         false
  1212.     else
  1213.         UseTable(theTable)
  1214.     fi
  1215.     fi
  1216. corp;
  1217.  
  1218. Verb1(g_build, "use", 0, bv_use)$
  1219.  
  1220. define tp_build1 proc utility bv_unuse(string tableName)bool:
  1221.     table theTable;
  1222.  
  1223.     if not checkBuilder() then
  1224.     false
  1225.     elif tableName = "" then
  1226.     Print("Use is: @unuse <table>\n");
  1227.     false
  1228.     else
  1229.     theTable := checkTable(tableName);
  1230.     if theTable = nil then
  1231.         false
  1232.     else
  1233.         UnUseTable(theTable)
  1234.     fi
  1235.     fi
  1236. corp;
  1237.  
  1238. Verb1(g_build, "unuse", 0, bv_unuse)$
  1239.  
  1240. define tp_build1 proc utility bv_symbolhere()bool:
  1241.     string tableName, what;
  1242.     table theTable;
  1243.  
  1244.     tableName := GetWord();
  1245.     what := GetWord();
  1246.     if tableName = "" or what = "" or GetWord() ~= "" then
  1247.     Print("Use is: @symbolhere <table> <symbol>\n");
  1248.     false
  1249.     else
  1250.     theTable := findTable(tableName, false);
  1251.     if theTable = nil then
  1252.         false
  1253.     else
  1254.         DefineThing(theTable, what, Here())
  1255.     fi
  1256.     fi
  1257. corp;
  1258.  
  1259. VerbTail(g_build, "symbolhere", bv_symbolhere)$
  1260.  
  1261. define tp_build proc utility bv_poof(string where)bool:
  1262.     string err;
  1263.     thing room;
  1264.     bool privileged;
  1265.     action a;
  1266.  
  1267.     privileged := Me()@p_pPrivileged;
  1268.     err := "Can only POOF between your own rooms.\n";
  1269.     if where = "" then
  1270.     Print("You must specify where you want to poof to.\n");
  1271.     false
  1272.     elif not Mine(Here()) and not privileged then
  1273.     Print(err);
  1274.     false
  1275.     else
  1276.     room := LookupThing(nil, where);
  1277.     if room = nil or room@p_rName = "" then
  1278.         if IsDefined(nil, where) then
  1279.         Print("Name '" + where + "' is not a room.\n");
  1280.         else
  1281.         Print("Name '" + where + "' is not defined.\n");
  1282.         fi;
  1283.         false
  1284.     elif not Mine(room) and not privileged then
  1285.         Print(err);
  1286.         false
  1287.     elif room = Here() then
  1288.         Print("That's where you are!\n");
  1289.         false
  1290.     else
  1291.         LeaveRoomStuff(room, 0, MOVE_POOF);
  1292.         EnterRoomStuff(room, 0, MOVE_POOF);
  1293.         true
  1294.     fi
  1295.     fi
  1296. corp;
  1297.  
  1298. Verb1(g_build, "poof", 0, bv_poof)$
  1299.  
  1300. /* a couple of utilities */
  1301.  
  1302. define tp_build proc utility objNameCheck(string symbol)thing:
  1303.     thing th;
  1304.  
  1305.     th := LookupThing(nil, symbol);
  1306.     if th = nil or th@p_oName = "" then
  1307.     if IsDefined(nil, symbol) then
  1308.         Print("'" + symbol + "' is not an object.\n");
  1309.     else
  1310.         Print("You have no object named '" + symbol + "'.\n");
  1311.     fi;
  1312.     nil
  1313.     else
  1314.     th
  1315.     fi
  1316. corp;
  1317.  
  1318. define tp_build1 proc utility actionNameCheck(string symbol)action:
  1319.     action a;
  1320.  
  1321.     a := LookupAction(nil, symbol);
  1322.     if a = nil then
  1323.     if IsDefined(nil, symbol) then
  1324.         Print("'" + symbol + "' is not an action.\n");
  1325.     else
  1326.         Print("You have no action named '" + symbol + "'.\n");
  1327.     fi;
  1328.     nil
  1329.     else
  1330.     a
  1331.     fi
  1332. corp;
  1333.  
  1334. define tp_build proc utility changeDone(string what)void:
  1335.  
  1336.     if Me()@p_pHidden then
  1337.     OPrint("Someone has " + what + ".\n");
  1338.     else
  1339.     OPrint(Capitalize(Me()@p_pName) + " has " + what + ".\n");
  1340.     fi;
  1341. corp;
  1342.  
  1343. /*****************************************************************************\
  1344. *                                          *
  1345. *        now some subsubcommands for building rooms              *
  1346. *                                          *
  1347. \*****************************************************************************/
  1348.  
  1349. define tp_build1 g_room CreateGrammar()$
  1350.  
  1351. define tp_build1 proc utility bv_room()bool:
  1352.     thing here;
  1353.     string s;
  1354.  
  1355.     here := Here();
  1356.     s := GetTail();
  1357.     if s = "" then
  1358.     Print("Missing room command - "
  1359.           "see builder's library for details.\n");
  1360.     false
  1361.     elif not Mine(here) and (GetThingStatus(here) = ts_readonly or
  1362.     GetThingStatus(here) = ts_wizard and not IsWizard()) and
  1363.     MeCharacter() ~= SysAdmin
  1364.     then
  1365.     Print("The owner of this room has not permitted it.\n");
  1366.     false
  1367.     else
  1368.     Parse(g_room, s) ~= 0
  1369.     fi
  1370. corp;
  1371.  
  1372. VerbTail(g_build, "r", bv_room)$
  1373. Synonym(g_build, "r", "room")$
  1374.  
  1375. define tp_build proc getRoomThing(int kind)thing:
  1376.  
  1377.     case kind
  1378.     incase 0:
  1379.     r_indoors
  1380.     incase 1:
  1381.     r_outdoors
  1382.     incase 2:
  1383.     r_forest
  1384.     incase 3:
  1385.     r_field
  1386.     incase 4:
  1387.     r_path
  1388.     incase 5:
  1389.     r_road
  1390.     incase 6:
  1391.     r_sidewalk
  1392.     incase 7:
  1393.     r_park
  1394.     incase 8:
  1395.     r_tunnel
  1396.     default:
  1397.     nil
  1398.     esac
  1399. corp;
  1400.  
  1401. define tp_build proc utility doCreateRoom(int dir, kind; string s)void:
  1402.     thing room;
  1403.  
  1404.     room := CreateThing(getRoomThing(kind));
  1405.     room@p_rName := s;
  1406.     room@p_rContents := CreateThingList();
  1407.     SetThingStatus(room, ts_readonly);
  1408.     Connect(Here(), room, dir);
  1409.     if Here()@p_rPlayPen then
  1410.     room@p_rPlayPen := true;
  1411.     fi;
  1412.     Print("New room created and linked.\n");
  1413.     changeDone("created a new room");
  1414. corp;
  1415.  
  1416. define tp_build1 proc utility brv_new()bool:
  1417.     string s, error;
  1418.     int dir, kind;
  1419.  
  1420.     error := "Use is: @room new <dir> <kind> <room-name>\n";
  1421.     s := GetWord();
  1422.     if s = "" then
  1423.     Print(error);
  1424.     false
  1425.     else
  1426.     dir := DirMatch(s);
  1427.     if dir = -1 then
  1428.         Print(error);
  1429.         false
  1430.     else
  1431.         s := GetWord();
  1432.         kind := MatchName("indoors.outdoors.forest.field.path.road."
  1433.                   "sidewalk.park.tunnel", s);
  1434.         if kind = -1 then
  1435.         Print("Unknown room kind. Known kinds are: indoors, outdoors, "
  1436.             "forest, field, path, road, sidewalk, park, tunnel\n");
  1437.         false
  1438.         else
  1439.         s := Strip(GetTail());
  1440.         if s = "" then
  1441.             Print(error);
  1442.             false
  1443.         elif Here()@(DirProp(dir)) ~= nil then
  1444.             Print("That direction is already in use.\n");
  1445.             false
  1446.         else
  1447.             doCreateRoom(dir, kind, s);
  1448.             true
  1449.         fi
  1450.         fi
  1451.     fi
  1452.     fi
  1453. corp;
  1454.  
  1455. VerbTail(g_room, "new", brv_new)$
  1456.  
  1457. define tp_build1 proc utility brv_newname()bool:
  1458.     string name;
  1459.  
  1460.     name := GetTail();
  1461.     if name = "" then
  1462.     Print("Use is: @room newname <room-name>\n");
  1463.     false
  1464.     else
  1465.     Here()@p_rName := name;
  1466.     Print("Room renamed.\n");
  1467.     changeDone("renamed this room");
  1468.     true
  1469.     fi
  1470. corp;
  1471.  
  1472. VerbTail(g_room, "newname", brv_newname)$
  1473.  
  1474. define tp_build1 proc utility brv_hide(string dirName)bool:
  1475.     int dir;
  1476.     list int exits;
  1477.  
  1478.     dir := DirMatch(dirName);
  1479.     if dir = -1 then
  1480.     Print("Use is: @room hide <dir>\n");
  1481.     false
  1482.     else
  1483.     exits := Here()@p_rExits;
  1484.     if Here()@(DirProp(dir)) = nil then
  1485.         Print("That direction is not in use.\n");
  1486.         false
  1487.     else
  1488.         if FindElement(exits, dir) = -1 then
  1489.         AddTail(exits, dir);
  1490.         Print("Link unhidden.\n");
  1491.         else
  1492.         DelElement(exits, dir);
  1493.         Print("Link hidden.\n");
  1494.         fi;
  1495.         true
  1496.     fi
  1497.     fi
  1498. corp;
  1499.  
  1500. Verb1(g_room, "hide", 0, brv_hide)$
  1501.  
  1502. define tp_build1 proc utility brv_same()bool:
  1503.     thing here;
  1504.     string error, s;
  1505.     int dirOld, dirNew;
  1506.  
  1507.     here := Here();
  1508.     error := "Use is: @room same <old-dir> <new-dir>\n";
  1509.     s := GetWord();
  1510.     if s = "" then
  1511.     Print(error);
  1512.     false
  1513.     else
  1514.     dirOld := DirMatch(s);
  1515.     if dirOld = -1 then
  1516.         Print(error);
  1517.         false
  1518.     elif here@(DirProp(dirOld)) = nil then
  1519.         Print("That old direction does not go anywhere.\n");
  1520.         false
  1521.     else
  1522.         s := GetWord();
  1523.         if s = "" or GetWord() ~= "" then
  1524.         Print(error);
  1525.         false
  1526.         else
  1527.         dirNew := DirMatch(s);
  1528.         if dirNew = -1 then
  1529.             Print(error);
  1530.             false
  1531.         elif here@(DirProp(dirNew)) ~= nil then
  1532.             Print("That new direction is already in use.\n");
  1533.             false
  1534.         else
  1535.             UniConnect(here, here@(DirProp(dirOld)), dirNew);
  1536.             Print("Link made.\n");
  1537.             changeDone("made a new link");
  1538.             true
  1539.         fi
  1540.         fi
  1541.     fi
  1542.     fi
  1543. corp;
  1544.  
  1545. VerbTail(g_room, "same", brv_same)$
  1546.  
  1547. define tp_build1 proc utility brv_scenery()bool:
  1548.     string s;
  1549.     bool hadOne;
  1550.  
  1551.     hadOne := false;
  1552.     while
  1553.     s := GetWord();
  1554.     s ~= ""
  1555.     do
  1556.     hadOne := true;
  1557.     Scenery(Here(), s);
  1558.     od;
  1559.     if hadOne then
  1560.     Print("New scenery words added.\n");
  1561.     true
  1562.     else
  1563.     Print("Use is: @room scenery <word> ... <word>\n");
  1564.     false
  1565.     fi
  1566. corp;
  1567.  
  1568. VerbTail(g_room, "scenery", brv_scenery)$
  1569.  
  1570. define tp_build1 proc utility brv_endNewdesc(string s)void:
  1571.     thing here;
  1572.  
  1573.     here := Here();
  1574.     /* Be careful that someone has not walked out of the Playpen while
  1575.        editing the room description! */
  1576.     if Me()@p_pBuilder or here@p_rPlayPen then
  1577.     s := Trim(s);
  1578.     if s = "" then
  1579.         here -- p_rDesc;
  1580.         Print("Room description deleted.\n");
  1581.     else
  1582.         here@p_rDesc := s;
  1583.         Print("Room decorated.\n");
  1584.     fi;
  1585.     changeDone("decorated this room");
  1586.     else
  1587.     Print("Description change cancelled.\n");
  1588.     fi;
  1589. corp;
  1590.  
  1591. define tp_build proc utility brv_newdesc()bool:
  1592.  
  1593.     GetDocument("room desc> ", "Enter room description", Here()@p_rDesc,
  1594.     brv_endNewdesc, false)
  1595. corp;
  1596.  
  1597. Verb0(g_room, "newdesc", 0, brv_newdesc)$
  1598.  
  1599. define tp_build1 proc utility brv_endAdddesc1(string s)void:
  1600.  
  1601.     if Me()@p_pBuilder or Here()@p_rPlayPen then
  1602.     s := Trim(s);
  1603.     if s = "" then
  1604.         Print("Room description not changed.\n");
  1605.     else
  1606.         Here()@p_rDesc := s;
  1607.         Print("Room redecorated.\n");
  1608.         changeDone("redecorated this room");
  1609.     fi;
  1610.     else
  1611.     Print("Description change cancelled.\n");
  1612.     fi;
  1613. corp;
  1614.  
  1615. define tp_build1 proc utility brv_endAdddesc2(string s)void:
  1616.  
  1617.     if Me()@p_pBuilder or Here()@p_rPlayPen then
  1618.     s := Trim(s);
  1619.     if s = "" then
  1620.         Print("Room description not changed.\n");
  1621.     else
  1622.         ExtendDesc(Here(), s);
  1623.         Print("Room redecorated.\n");
  1624.         changeDone("redecorated this room");
  1625.     fi;
  1626.     else
  1627.     Print("Description change cancelled.\n");
  1628.     fi;
  1629. corp;
  1630.  
  1631. define tp_build1 proc utility brv_adddesc()bool:
  1632.  
  1633.     if CanEdit() then
  1634.     GetDocument("add room desc> ", "Edit room description", Here()@p_rDesc,
  1635.         brv_endAdddesc1, false)
  1636.     else
  1637.     GetDocument("add room desc> ", "Edit room description", "",
  1638.         brv_endAdddesc2, false)
  1639.     fi
  1640. corp;
  1641.  
  1642. Verb0(g_room, "adddesc", 0, brv_adddesc)$
  1643.  
  1644. define tp_build1 proc utility brv_setdescaction(string name)bool:
  1645.     action a;
  1646.  
  1647.     if name = "" then
  1648.     Print("Use is: @room setdescaction <action-symbol>\n");
  1649.     false
  1650.     else
  1651.     if name == "nil" then
  1652.         Here() -- p_rDescAction;
  1653.         Print("Descaction removed.\n");
  1654.         changeDone("altered something here");
  1655.         true
  1656.     else
  1657.         a := actionNameCheck(name);
  1658.         if a = nil then
  1659.         false
  1660.         else
  1661.         Here()@p_rDescAction := a;
  1662.         Print("Descaction set.\n");
  1663.         changeDone("altered something here");
  1664.         true
  1665.         fi
  1666.     fi
  1667.     fi
  1668. corp;
  1669.  
  1670. Verb1(g_room, "setdescaction", 0, brv_setdescaction)$
  1671.  
  1672. define tp_build1 proc utility brv_addspecialaction()bool:
  1673.     string name, command;
  1674.     action a;
  1675.  
  1676.     name := GetWord();
  1677.     command := GetWord();
  1678.     if name = "" or command = "" or GetWord() ~= "" then
  1679.     Print("Use is: @room addspecialaction <action-symbol> <verb-form>\n");
  1680.     false
  1681.     else
  1682.     a := actionNameCheck(name);
  1683.     if a = nil then
  1684.         false
  1685.     else
  1686.         AddSpecialCommand(Here(), command, a);
  1687.         Print("Special command set.\n");
  1688.         changeDone("altered something here");
  1689.         true
  1690.     fi
  1691.     fi
  1692. corp;
  1693.  
  1694. VerbTail(g_room, "addspecialaction", brv_addspecialaction)$
  1695.  
  1696. define tp_build1 proc utility brv_subspecialaction()bool:
  1697.     string name, command;
  1698.     action a;
  1699.  
  1700.     name := GetWord();
  1701.     command := GetWord();
  1702.     if name = "" or command = "" or GetWord() ~= "" then
  1703.     Print("Use is: @room subspecialaction <action-symbol> <verb-form>\n");
  1704.     false
  1705.     else
  1706.     a := actionNameCheck(name);
  1707.     if a = nil then
  1708.         false
  1709.     else
  1710.         if RemoveSpecialCommand(Here(), command, a) then
  1711.         Print("Special command set.\n");
  1712.         changeDone("altered something here");
  1713.         true
  1714.         else
  1715.         Print("That special command is not set here.\n");
  1716.         false
  1717.         fi
  1718.     fi
  1719.     fi
  1720. corp;
  1721.  
  1722. VerbTail(g_room, "subspecialaction", brv_subspecialaction)$
  1723.  
  1724. define tp_build proc utility doMakeLink(string s; int dir)bool:
  1725.     thing there;
  1726.  
  1727.     there := LookupThing(nil, s);
  1728.     if there = nil then
  1729.     if IsDefined(nil, s) then
  1730.         Print("Name '" + s + "' is not a room.\n");
  1731.     else
  1732.         Print("Name '" + s + "' is not defined.\n");
  1733.     fi;
  1734.     false
  1735.     elif there@p_rName = "" and there@p_rNameAction = nil then
  1736.     Print("Name '" + s + "' is not a room.\n");
  1737.     false
  1738.     elif Here()@p_rPlayPen and not there@p_rPlayPen then
  1739.     Print("Cannot link to non-playpen rooms from playpen rooms\n");
  1740.     false
  1741.     elif not Mine(there) and (GetThingStatus(there) = ts_readonly or
  1742.     GetThingStatus(there) = ts_wizard and not IsWizard()) and
  1743.     MeCharacter() ~= SysAdmin
  1744.     then
  1745.     Print("The owner of that room has not permitted it.\n");
  1746.     false
  1747.     else
  1748.     UniConnect(Here(), there, dir);
  1749.     Print("Link made.\n");
  1750.     changeDone("made a new link");
  1751.     true
  1752.     fi
  1753. corp;
  1754.  
  1755. define tp_build1 proc utility brv_linkto()bool:
  1756.     thing here;
  1757.     string error, s;
  1758.     int dir;
  1759.  
  1760.     error := "Use is: @room linkto <dir> <room-symbol>\n";
  1761.     here := Here();
  1762.     s := GetWord();
  1763.     if s = "" then
  1764.     Print(error);
  1765.     false
  1766.     else
  1767.     dir := DirMatch(s);
  1768.     if dir = -1 then
  1769.         Print(error);
  1770.         false
  1771.     elif here@(DirProp(dir)) ~= nil then
  1772.         Print("That direction is already in use.\n");
  1773.         false
  1774.     else
  1775.         s := GetWord();
  1776.         if s = "" or GetWord() ~= "" then
  1777.         Print(error);
  1778.         false
  1779.         else
  1780.         doMakeLink(s, dir)
  1781.         fi
  1782.     fi
  1783.     fi
  1784. corp;
  1785.  
  1786. VerbTail(g_room, "linkto", brv_linkto)$
  1787.  
  1788. define tp_build proc utility brv_unlink(string dirName)bool:
  1789.     int dir;
  1790.     list int exits;
  1791.  
  1792.     dir := DirMatch(dirName);
  1793.     if dir = -1 then
  1794.     Print("Use is: @room unlink <dir>\n");
  1795.     false
  1796.     elif Here()@(DirProp(dir)) = nil then
  1797.     Print("There is no link in that direction from here.\n");
  1798.     false
  1799.     elif dir = D_NORTH and Here() = r_playPen then
  1800.     Print("Only a wizard or apprentice can remove the Playpen's exit.\n");
  1801.     false
  1802.     else
  1803.     Here() -- DirProp(dir);
  1804.     exits := Here()@p_rExits;
  1805.     if exits ~= nil then
  1806.         DelElement(exits, dir);
  1807.     fi;
  1808.     Print("Connection removed.\n");
  1809.     changeDone("removed a link");
  1810.     true
  1811.     fi
  1812. corp;
  1813.  
  1814. Verb1(g_room, "unlink", 0, brv_unlink)$
  1815.  
  1816. define tp_build proc utility brv_dark(string s)bool:
  1817.     thing here;
  1818.  
  1819.     here := Here();
  1820.     if not Mine(here) then
  1821.     Print("Can only change the lighting in your own rooms.\n");
  1822.     false
  1823.     else
  1824.     if s = "" then
  1825.         s := "y";
  1826.     fi;
  1827.     if isYes(s) then
  1828.         here@p_rDark := true;
  1829.         Print("This room is now dark.\n");
  1830.         if Me()@p_pHidden then
  1831.         OPrint("The light has gone away.\n");
  1832.         else
  1833.         OPrint(Capitalize(Me()@p_pName) + " has removed the light.\n");
  1834.         fi;
  1835.         true
  1836.     elif isNo(s) then
  1837.         here -- p_rDark;
  1838.         Print("This room is now lighted.\n");
  1839.         if Me()@p_pHidden then
  1840.         OPrint("Light has appeared\n");
  1841.         else
  1842.         OPrint(Capitalize(Me()@p_pName) + " has created light.\n");
  1843.         fi;
  1844.         true
  1845.     else
  1846.         Print("Use is: @room dark [y|n]\n");
  1847.         false
  1848.     fi
  1849.     fi
  1850. corp;
  1851.  
  1852. Verb1(g_room, "dark", 0, brv_dark)$
  1853.  
  1854. define tp_build proc utility brv_lock(string s)bool:
  1855.     thing here;
  1856.  
  1857.     here := Here();
  1858.     if not Mine(here) then
  1859.     Print("Can only lock/unlock your own rooms.\n");
  1860.     false
  1861.     else
  1862.     if s = "" then
  1863.         s := "y";
  1864.     fi;
  1865.     if isYes(s) then
  1866.         here@p_rLocked := true;
  1867.         Print("This room is now locked from public access.\n");
  1868.         true
  1869.     elif isNo(s) then
  1870.         here -- p_rLocked;
  1871.         Print("This room is now available for public access.\n");
  1872.         true
  1873.     else
  1874.         Print("Use is: @room lock [y|n]\n");
  1875.         false
  1876.     fi
  1877.     fi
  1878. corp;
  1879.  
  1880. Verb1(g_room, "lock", 0, brv_lock)$
  1881.  
  1882. define tp_build1 proc utility brv_status(string s)bool:
  1883.     string error;
  1884.     thing here;
  1885.  
  1886.     here := Here();
  1887.     if not Mine(here) then
  1888.     Print("Can only change the status on your own rooms.\n");
  1889.     false
  1890.     else
  1891.     error := "Use is: @room status {readonly|wizard|public}\n";
  1892.     if s = "" then
  1893.         Print(error);
  1894.         false
  1895.     else
  1896.         if s == "readonly" then
  1897.         SetThingStatus(here, ts_readonly);
  1898.         Print("This room is now changeable by its owner only.\n");
  1899.         true
  1900.         elif s == "wizard" then
  1901.         SetThingStatus(here, ts_wizard);
  1902.         Print("This room is now changeable by wizards only.\n");
  1903.         true
  1904.         elif s == "public" then
  1905.         SetThingStatus(here, ts_public);
  1906.         Print(
  1907.     "This room is now changeable by wizards, apprentices and builders.\n");
  1908.         true
  1909.         else
  1910.         Print(error);
  1911.         false
  1912.         fi
  1913.     fi
  1914.     fi
  1915. corp;
  1916.  
  1917. Verb1(g_room, "status", 0, brv_status)$
  1918.  
  1919. define tp_build1 proc utility brv_endDirDesc(string s)void:
  1920.     thing me, here;
  1921.  
  1922.     me := Me();
  1923.     here := Here();
  1924.     if me@p_pBuilder or here@p_rPlayPen then
  1925.     s := Trim(s);
  1926.     if s = "" then
  1927.         here -- DirDesc(me@p_pActiveDir);
  1928.         Print("Direction description deleted.\n");
  1929.     else
  1930.         here@(DirDesc(me@p_pActiveDir)) := s;
  1931.         Print("Direction decorated.\n");
  1932.     fi;
  1933.     changeDone("done some detailing");
  1934.     else
  1935.     Print("Direction description change cancelled.\n");
  1936.     fi;
  1937.     me -- p_pActiveDir;
  1938. corp;
  1939.  
  1940. define tp_build1 proc utility brv_dirdesc(string where)bool:
  1941.     int dir;
  1942.  
  1943.     dir := DirMatch(where);
  1944.     if dir = -1 then
  1945.     Print("Use is: @room dirdesc <dir>\n");
  1946.     false
  1947.     else
  1948.     Me()@p_pActiveDir := dir;
  1949.     GetDocument("room dirdesc> ", "Enter direction description", "",
  1950.         brv_endDirDesc, false)
  1951.     fi
  1952. corp;
  1953.  
  1954. Verb1(g_room, "dirdesc", 0, brv_dirdesc)$
  1955.  
  1956. define tp_build1 proc utility brv_endDirMessage(string s)void:
  1957.     thing me, here;
  1958.  
  1959.     me := Me();
  1960.     here := Here();
  1961.     if me@p_pBuilder or here@p_rPlayPen then
  1962.     s := Trim(s);
  1963.     if s = "" then
  1964.         if me@p_pActiveDir = 100 then
  1965.         here -- p_rNoGoString;
  1966.         Print("NoGo string deleted.\n");
  1967.         else
  1968.         here -- DirMessage(me@p_pActiveDir);
  1969.         Print("Direction message deleted.\n");
  1970.         fi;
  1971.     else
  1972.         if me@p_pActiveDir = 100 then
  1973.         here@p_rNoGoString := s;
  1974.         Print("NoGo message entered.\n");
  1975.         else
  1976.         here@(DirMessage(me@p_pActiveDir)) := s;
  1977.         Print("Direction message entered.\n");
  1978.         fi;
  1979.     fi;
  1980.     changeDone("done some detailing");
  1981.     else
  1982.     Print("Message change cancelled.\n");
  1983.     fi;
  1984.     me -- p_pActiveDir;
  1985. corp;
  1986.  
  1987. define tp_build1 proc utility brv_dirmessage(string where)bool:
  1988.     int dir;
  1989.  
  1990.     if where == "nogo" then
  1991.     dir := 100;
  1992.     else
  1993.     dir := DirMatch(where);
  1994.     fi;
  1995.     if dir = -1 then
  1996.     Print("Use is: @room dirmessage <dir>\n");
  1997.     false
  1998.     else
  1999.     Me()@p_pActiveDir := dir;
  2000.     GetDocument("room dirmessage> ", "Enter direction message", "",
  2001.         brv_endDirMessage, false)
  2002.     fi
  2003. corp;
  2004.  
  2005. Verb1(g_room, "dirmessage", 0, brv_dirmessage)$
  2006.  
  2007. define tp_build1 proc utility brv_endDirOMessage(string s)void:
  2008.     thing me, here;
  2009.  
  2010.     me := Me();
  2011.     here := Here();
  2012.     if me@p_pBuilder or here@p_rPlayPen then
  2013.     s := Trim(s);
  2014.     if s = "" then
  2015.         here -- DirOMessage(me@p_pActiveDir);
  2016.         Print("Direction message deleted.\n");
  2017.     else
  2018.         here@(DirOMessage(me@p_pActiveDir)) := s;
  2019.         Print("Direction message entered.\n");
  2020.     fi;
  2021.     changeDone("done some detailing");
  2022.     else
  2023.     Print("Message change cancelled.\n");
  2024.     fi;
  2025.     me -- p_pActiveDir;
  2026. corp;
  2027.  
  2028. define tp_build1 proc utility brv_diromessage(string where)bool:
  2029.     int dir;
  2030.  
  2031.     dir := DirMatch(where);
  2032.     if dir = -1 then
  2033.     Print("Use is: @room diromessage <dir>\n");
  2034.     false
  2035.     else
  2036.     Me()@p_pActiveDir := dir;
  2037.     GetDocument("room diromessage> ", "Enter entering direction message",
  2038.         "", brv_endDirOMessage, false)
  2039.     fi
  2040. corp;
  2041.  
  2042. Verb1(g_room, "diromessage", 0, brv_diromessage)$
  2043.  
  2044. define tp_build1 proc utility brv_endDirEMessage(string s)void:
  2045.     thing me, here;
  2046.  
  2047.     me := Me();
  2048.     here := Here();
  2049.     if me@p_pBuilder or here@p_rPlayPen then
  2050.     s := Trim(s);
  2051.     if s = "" then
  2052.         here -- DirEMessage(me@p_pActiveDir);
  2053.         Print("Direction message deleted.\n");
  2054.     else
  2055.         here@(DirEMessage(me@p_pActiveDir)) := s;
  2056.         Print("Direction message entered.\n");
  2057.     fi;
  2058.     changeDone("done some detailing");
  2059.     else
  2060.     Print("Message change cancelled.\n");
  2061.     fi;
  2062.     me -- p_pActiveDir;
  2063. corp;
  2064.  
  2065. define tp_build1 proc utility brv_diremessage(string where)bool:
  2066.     int dir;
  2067.  
  2068.     dir := DirMatch(where);
  2069.     if dir = -1 then
  2070.     Print("Use is: @room diremessage <dir>\n");
  2071.     false
  2072.     else
  2073.     Me()@p_pActiveDir := dir;
  2074.     GetDocument("room diremessage> ", "Enter exiting direction message","",
  2075.         brv_endDirEMessage, false)
  2076.     fi
  2077. corp;
  2078.  
  2079. Verb1(g_room, "diremessage", 0, brv_diremessage)$
  2080.  
  2081. define tp_build1 proc utility brv_adddircheck()bool:
  2082.     string dirName, name;
  2083.     int dir;
  2084.     action a;
  2085.  
  2086.     dirName := GetWord();
  2087.     name := GetWord();
  2088.     if dirName == "anyenter" then
  2089.     dir := 100;
  2090.     elif dirName == "anyexit" then
  2091.     dir := 101;
  2092.     else
  2093.     dir := DirMatch(dirName);
  2094.     fi;
  2095.     if dir = -1 or name = "" or GetWord() ~= "" then
  2096.     Print("Use is: @room adddircheck <dir> <action-symbol>\n");
  2097.     false
  2098.     else
  2099.     a := actionNameCheck(name);
  2100.     if a = nil then
  2101.         false
  2102.     else
  2103.         if dir = 100 then
  2104.         AddAnyEnterChecker(Here(), a, false);
  2105.         elif dir = 101 then
  2106.         AddAnyLeaveChecker(Here(), a, false);
  2107.         else
  2108.         AddDirChecker(Here(), dir, a, false);
  2109.         fi;
  2110.         Print("Dircheck entered.\n");
  2111.         changeDone("altered something here");
  2112.         true
  2113.     fi
  2114.     fi
  2115. corp;
  2116.  
  2117. VerbTail(g_room, "adddircheck", brv_adddircheck)$
  2118.  
  2119. define tp_build1 proc utility brv_subdircheck()bool:
  2120.     string dirName, name;
  2121.     int dir;
  2122.     action a;
  2123.  
  2124.     dirName := GetWord();
  2125.     name := GetWord();
  2126.     if dirName == "anyenter" then
  2127.     dir := 100;
  2128.     elif dirName == "anyexit" then
  2129.     dir := 101;
  2130.     else
  2131.     dir := DirMatch(dirName);
  2132.     fi;
  2133.     if dir = -1 or name = "" or GetWord() ~= "" then
  2134.     Print("Use is: @room subdircheck <dir> <action-symbol>\n");
  2135.     false
  2136.     else
  2137.     a := actionNameCheck(name);
  2138.     if a = nil then
  2139.         false
  2140.     else
  2141.         if dir = 100 then
  2142.         DelAnyEnterChecker(Here(), a);
  2143.         elif dir = 101 then
  2144.         DelAnyLeaveChecker(Here(), a);
  2145.         else
  2146.         DelDirChecker(Here(), dir, a);
  2147.         fi;
  2148.         Print("Dircheck removed.\n");
  2149.         changeDone("altered something here");
  2150.         true
  2151.     fi
  2152.     fi
  2153. corp;
  2154.  
  2155. VerbTail(g_room, "subdircheck", brv_subdircheck)$
  2156.  
  2157. /* need to steal a couple of private definitions */
  2158. use tp_base
  2159.  
  2160. define tp_build1 proc utility brv_showdirchecks(string dirName)bool:
  2161.     list action la;
  2162.     action a;
  2163.     int count, dir, i;
  2164.     string procName;
  2165.  
  2166.     if dirName == "anyenter" then
  2167.     dir := 100;
  2168.     elif dirName == "anyexit" then
  2169.     dir := 101;
  2170.     else
  2171.     dir := DirMatch(dirName);
  2172.     fi;
  2173.     if dir = -1 then
  2174.     Print("Use is: @room showdirchecks <dir>\n");
  2175.     false
  2176.     else
  2177.     if dir = 100 then
  2178.         la := Here()@p_rAnyEnterChecks;
  2179.     elif dir = 101 then
  2180.         la := Here()@p_rAnyLeaveChecks;
  2181.     else
  2182.         la := Here()@(DirChecks(dir));
  2183.     fi;
  2184.     if la = nil then
  2185.         Print("There are no checkers for that direction here.\n");
  2186.     else
  2187.         count := Count(la);
  2188.         i := 0;
  2189.         while i ~= count do
  2190.         Print("Checker ");
  2191.         IPrint(i);
  2192.         Print(":");
  2193.         procName := FindActionSymbol(nil, la[i]);
  2194.         if procName ~= "" then
  2195.             Print(" " + procName + "\n");
  2196.         else
  2197.             Print("\n");
  2198.             PrintAction(la[i]);
  2199.         fi;
  2200.         i := i + 1;
  2201.         od;
  2202.     fi;
  2203.     true
  2204.     fi
  2205. corp;
  2206.  
  2207. unuse tp_base
  2208.  
  2209. Verb1(g_room, "showdirchecks", 0, brv_showdirchecks)$
  2210.  
  2211. define tp_build1 proc utility brv_checker()bool:
  2212.     string tableName, name;
  2213.     table theTable;
  2214.  
  2215.     tableName := GetWord();
  2216.     name := GetWord();
  2217.     if tableName = "" or name = "" or GetWord() ~= "" then
  2218.     Print("Use is: @room checker <table> <action-symbol>\n");
  2219.     false
  2220.     else
  2221.     theTable := findTable(tableName, false);
  2222.     if theTable = nil then
  2223.         false
  2224.     elif IsDefined(theTable, name) then
  2225.         Print("'" + name + "' is already defined.\n");
  2226.         false
  2227.     else
  2228.         getAction(theTable, name, ck_roomChecker)
  2229.     fi
  2230.     fi
  2231. corp;
  2232.  
  2233. VerbTail(g_room, "checker", brv_checker)$
  2234.  
  2235. define tp_build1 proc utility brv_descaction()bool:
  2236.     string tableName, name;
  2237.     table theTable;
  2238.  
  2239.     tableName := GetWord();
  2240.     name := GetWord();
  2241.     if tableName = "" or name = "" or GetWord() ~= "" then
  2242.     Print("Use is: @room descaction <table> <action-symbol>\n");
  2243.     false
  2244.     else
  2245.     theTable := findTable(tableName, false);
  2246.     if theTable = nil then
  2247.         false
  2248.     elif IsDefined(theTable, name) then
  2249.         Print("'" + name + "' is already defined.\n");
  2250.         false
  2251.     else
  2252.         getAction(theTable, name, ck_roomDesc)
  2253.     fi
  2254.     fi
  2255. corp;
  2256.  
  2257. VerbTail(g_room, "descaction", brv_descaction)$
  2258.  
  2259. define tp_build1 proc utility brv_specialaction()bool:
  2260.     string tableName, name;
  2261.     table theTable;
  2262.  
  2263.     tableName := GetWord();
  2264.     name := GetWord();
  2265.     if tableName = "" or name = "" or GetWord() ~= "" then
  2266.     Print("Use is: @room specialaction <table> <action-symbol>\n");
  2267.     false
  2268.     else
  2269.     theTable := findTable(tableName, false);
  2270.     if theTable = nil then
  2271.         false
  2272.     elif IsDefined(theTable, name) then
  2273.         Print("'" + name + "' is already defined.\n");
  2274.         false
  2275.     else
  2276.         getAction(theTable, name, ck_roomVoid)
  2277.     fi
  2278.     fi
  2279. corp;
  2280.  
  2281. VerbTail(g_room, "specialaction", brv_specialaction)$
  2282.  
  2283. define tp_build proc utility brv_makebank()bool:
  2284.     thing here;
  2285.  
  2286.     here := Here();
  2287.     if not Mine(here) then
  2288.     Print("Can only make your own rooms into banks.\n");
  2289.     false
  2290.     elif IsBank(here) then
  2291.     if UnmakeBank(here) = succeed then
  2292.         Print("This room is no longer a bank.\n");
  2293.         true
  2294.     else
  2295.         Print("Bank cannot be unmade - it has accounts.\n");
  2296.         false
  2297.     fi
  2298.     else
  2299.     MakeBank(here);
  2300.     Print("This room is now a bank.\n");
  2301.     true
  2302.     fi
  2303. corp;
  2304.  
  2305. Verb0(g_room, "makebank", 0, brv_makebank)$
  2306.  
  2307. define tp_build proc utility brv_makestore()bool:
  2308.     thing here;
  2309.  
  2310.     here := Here();
  2311.     if not Mine(here) then
  2312.     Print("Can only make your own rooms into stores.\n");
  2313.     false
  2314.     else
  2315.     if IsStore(here) then
  2316.         UnmakeStore(here);
  2317.         Print("This room is no longer a store.\n");
  2318.         false
  2319.     else
  2320.         MakeStore(here);
  2321.         Print("This room is now a store.\n");
  2322.         true
  2323.     fi
  2324.     fi
  2325. corp;
  2326.  
  2327. Verb0(g_room, "makestore", 0, brv_makestore)$
  2328.  
  2329. define tp_build1 proc utility brv_addforsale()bool:
  2330.     string symbol;
  2331.     int price;
  2332.     thing here, th;
  2333.  
  2334.     here := Here();
  2335.     if not Mine(here) then
  2336.     Print("Can only modify your own stores.\n");
  2337.     false
  2338.     elif not IsStore(here) then
  2339.     Print("This room is not a store.\n");
  2340.     false
  2341.     else
  2342.     symbol := GetWord();
  2343.     price := StringToInt(GetWord());
  2344.     if symbol = "" or price <= 0 or GetWord() ~= "" then
  2345.         Print("Use is: @room addforsale <object-symbol> <price>\n");
  2346.         false
  2347.     else
  2348.         th := objNameCheck(symbol);
  2349.         if th ~= nil then
  2350.         AddObjectForSale(here, th, price, nil);
  2351.         Print(FormatName(th@p_oName) + " is now for sale here.\n");
  2352.         true
  2353.         else
  2354.         false
  2355.         fi
  2356.     fi
  2357.     fi
  2358. corp;
  2359.  
  2360. VerbTail(g_room, "addforsale", brv_addforsale)$
  2361.  
  2362. define tp_build1 proc utility brv_subforsale()bool:
  2363.     string symbol;
  2364.     thing here, th;
  2365.  
  2366.     here := Here();
  2367.     if not Mine(here) then
  2368.     Print("Can only modify your own stores.\n");
  2369.     false
  2370.     elif not IsStore(here) then
  2371.     Print("This room is not a store.\n");
  2372.     false
  2373.     else
  2374.     symbol := GetWord();
  2375.     if symbol = "" or GetWord() ~= "" then
  2376.         Print("Use is: @room subforsale <object-symbol>\n");
  2377.         false
  2378.     else
  2379.         th := objNameCheck(symbol);
  2380.         if th ~= nil then
  2381.         if SubObjectForSale(here, th) then
  2382.             Print(FormatName(th@p_oName) +
  2383.             " is no longer for sale here.\n");
  2384.             true
  2385.         else
  2386.             Print(FormatName(th@p_oName) + " is not for sale here.\n");
  2387.             false
  2388.         fi
  2389.         else
  2390.         false
  2391.         fi
  2392.     fi
  2393.     fi
  2394. corp;
  2395.  
  2396. VerbTail(g_room, "subforsale", brv_subforsale)$
  2397.  
  2398. /*****************************************************************************\
  2399. *                                          *
  2400. *        now some subsubcommands for building objects              *
  2401. *                                          *
  2402. \*****************************************************************************/
  2403.  
  2404. define tp_build1 g_object CreateGrammar()$
  2405.  
  2406. define tp_build1 proc utility bv_object()bool:
  2407.     string s;
  2408.  
  2409.     s := GetTail();
  2410.     if s = "" then
  2411.     Print("Missing object command - "
  2412.           "see builder's library for details.\n");
  2413.     true
  2414.     else
  2415.     Parse(g_object, s) ~= 0
  2416.     fi
  2417. corp;
  2418.  
  2419. VerbTail(g_build, "o", bv_object)$
  2420. Synonym(g_build, "o", "object")$
  2421.  
  2422. define tp_build proc utility createNewObject(string name; table theTable;
  2423.     string symbol)thing:
  2424.     thing me, th;
  2425.  
  2426.     me := Me();
  2427.     if Count(me@p_pCarrying) >= MAX_CARRY then
  2428.     Print("You can't carry anything else.\n");
  2429.     nil
  2430.     else
  2431.     th := CreateThing(nil);
  2432.     th@p_oName := name;
  2433.     th@p_oHome := Here();
  2434.     th@p_oCarryer := me;
  2435.     th@p_oCreator := me;
  2436.     if Here()@p_rPlayPen then
  2437.         th@p_rPlayPen := true;
  2438.     fi;
  2439.     SetThingStatus(th, ts_public);
  2440.     GiveThing(th, SysAdmin);
  2441.     AddTail(me@p_pCarrying, th);
  2442.     if DefineThing(theTable, symbol, th) then
  2443.         Print("Object created - you are carrying it.\n");
  2444.         changeDone("created something");
  2445.     fi;
  2446.     th
  2447.     fi
  2448. corp;
  2449.  
  2450. define tp_build1 proc utility bov_new()bool:
  2451.     string tableName, symbol, name;
  2452.     table theTable;
  2453.     thing me, th;
  2454.  
  2455.     tableName := GetWord();
  2456.     symbol := GetWord();
  2457.     name := GetWord();
  2458.     if tableName = "" or symbol = "" or name = "" or GetWord() ~= "" then
  2459.     Print(
  2460.        "Use is: @object new <table> <object-symbol> \"noun[;adj,...,adj]\"\n");
  2461.     false
  2462.     else
  2463.     theTable := findTable(tableName, false);
  2464.     if theTable = nil then
  2465.         false
  2466.     elif IsDefined(theTable, symbol) then
  2467.         Print("'" + symbol + "' is already defined.\n");
  2468.         false
  2469.     else
  2470.         createNewObject(name, theTable, symbol) ~= nil
  2471.     fi
  2472.     fi
  2473. corp;
  2474.  
  2475. VerbTail(g_object, "new", bov_new)$
  2476.  
  2477. define tp_build1 proc utility bov_newname()bool:
  2478.     string symbol, newName;
  2479.     thing th;
  2480.  
  2481.     symbol := GetWord();
  2482.     newName := GetWord();
  2483.     if symbol = "" or newName = "" or GetWord() ~= "" then
  2484.     Print(
  2485.        "Use is: @object newname <object-symbol> \"noun[;adj,...,adj]\"\n");
  2486.     false
  2487.     else
  2488.     th := objNameCheck(symbol);
  2489.     if th ~= nil then
  2490.         th@p_oName := newName;
  2491.         Print("Your object '" + symbol + "' will now be seen as '" +
  2492.           FormatName(newName) + "'.\n");
  2493.         true
  2494.     else
  2495.         false
  2496.     fi
  2497.     fi
  2498. corp;
  2499.  
  2500. VerbTail(g_object, "newname", bov_newname)$
  2501. Synonym(g_object, "newname", "name")$
  2502.  
  2503. define tp_build1 proc utility bov_endNewdesc(string s)void:
  2504.     thing me;
  2505.  
  2506.     me := Me();
  2507.     s := Trim(s);
  2508.     if s = "" then
  2509.     me@p_pActiveThing -- p_oDesc;
  2510.     Print("Object description deleted.\n");
  2511.     else
  2512.     me@p_pActiveThing@p_oDesc := s;
  2513.     Print("Object description entered.\n");
  2514.     fi;
  2515.     me -- p_pActiveThing;
  2516. corp;
  2517.  
  2518. define tp_build proc utility doObjectDesc(thing th)bool:
  2519.  
  2520.     Me()@p_pActiveThing := th;
  2521.     GetDocument("object desc> ", "Enter description",
  2522.     th@p_oDesc, bov_endNewdesc, false)
  2523. corp;
  2524.  
  2525. define tp_build1 proc utility bov_newdesc(string symbol)bool:
  2526.     thing th;
  2527.  
  2528.     if symbol = "" then
  2529.     Print("Use is: @object newdesc <object-symbol>\n");
  2530.     false
  2531.     else
  2532.     th := objNameCheck(symbol);
  2533.     if th ~= nil then
  2534.         doObjectDesc(th)
  2535.     else
  2536.         false
  2537.     fi
  2538.     fi
  2539. corp;
  2540.  
  2541. Verb1(g_object, "newdesc", 0, bov_newdesc)$
  2542. Synonym(g_object, "newdesc", "desc")$
  2543.  
  2544. define tp_build1 proc utility bov_endReadstring(string s)void:
  2545.     thing me;
  2546.  
  2547.     me := Me();
  2548.     s := Trim(s);
  2549.     if s = "" then
  2550.     me@p_pActiveThing -- p_oReadString;
  2551.     Print("Object readstring deleted.\n");
  2552.     else
  2553.     me@p_pActiveThing@p_oReadString := s;
  2554.     Print("Object read string entered.\n");
  2555.     fi;
  2556.     me -- p_pActiveThing;
  2557. corp;
  2558.  
  2559. define tp_build proc utility doObjectRead(thing th)bool:
  2560.  
  2561.     Me()@p_pActiveThing := th;
  2562.     GetDocument("object read string> ", "Enter read string",
  2563.     th@p_oReadString, bov_endReadstring, false)
  2564. corp;
  2565.  
  2566. define tp_build1 proc utility bov_readstring(string symbol)bool:
  2567.     thing th;
  2568.  
  2569.     if symbol = "" then
  2570.     Print("Use is: @object readstring <object-symbol>\n");
  2571.     false
  2572.     else
  2573.     th := objNameCheck(symbol);
  2574.     if th ~= nil then
  2575.         doObjectRead(th)
  2576.     else
  2577.         false
  2578.     fi
  2579.     fi
  2580. corp;
  2581.  
  2582. Verb1(g_object, "readstring", 0, bov_readstring)$
  2583.  
  2584. define tp_build1 proc utility bov_setdescaction()bool:
  2585.     string thingName, name;
  2586.     thing th;
  2587.     action a;
  2588.  
  2589.     thingName := GetWord();
  2590.     name := GetWord();
  2591.     if thingName = "" or name = "" or GetWord() ~= "" then
  2592.     Print(
  2593.         "Use is: @object setdescaction <object-symbol> <action-symbol>\n");
  2594.     false
  2595.     else
  2596.     th := objNameCheck(thingName);
  2597.     if th ~= nil then
  2598.         if name == "nil" then
  2599.         th -- p_oDescAction;
  2600.         Print("Descaction removed.\n");
  2601.         true
  2602.         else
  2603.         a := actionNameCheck(name);
  2604.         if a = nil then
  2605.             false
  2606.         else
  2607.             th@p_oDescAction := a;
  2608.             Print("Descaction set.\n");
  2609.             true
  2610.         fi
  2611.         fi
  2612.     else
  2613.         false
  2614.     fi
  2615.     fi
  2616. corp;
  2617.  
  2618. VerbTail(g_object, "setdescaction", bov_setdescaction)$
  2619.  
  2620. define tp_build1 proc utility bov_setreadaction()bool:
  2621.     string thingName, name;
  2622.     thing th;
  2623.     action a;
  2624.  
  2625.     thingName := GetWord();
  2626.     name := GetWord();
  2627.     if thingName = "" or name = "" or GetWord() ~= "" then
  2628.     Print(
  2629.         "Use is: @object setreadaction <object-symbol> <action-symbol>\n");
  2630.     false
  2631.     else
  2632.     th := objNameCheck(thingName);
  2633.     if th ~= nil then
  2634.         if name == "nil" then
  2635.         th -- p_oReadAction;
  2636.         Print("Readaction removed.\n");
  2637.         true
  2638.         else
  2639.         a := actionNameCheck(name);
  2640.         if a = nil then
  2641.             false
  2642.         else
  2643.             th@p_oReadAction := a;
  2644.             Print("Readaction set.\n");
  2645.             true
  2646.         fi
  2647.         fi
  2648.     else
  2649.         false
  2650.     fi
  2651.     fi
  2652. corp;
  2653.  
  2654. VerbTail(g_object, "setreadaction", bov_setreadaction)$
  2655.  
  2656. define tp_build1 proc utility bov_setactword()bool:
  2657.     string symbol, word;
  2658.     thing th;
  2659.  
  2660.     symbol := GetWord();
  2661.     word := GetWord();
  2662.     if symbol = "" or word = "" or GetWord() ~= "" then
  2663.     Print(
  2664.       "Use is: @object setactword <object-symbol> \"word,synonym,...\"\n");
  2665.     false
  2666.     else
  2667.     th := objNameCheck(symbol);
  2668.     if th ~= nil then
  2669.         th@p_oActWord := word;
  2670.         Print("Your object '" + symbol + AAn("' will now have", word) +
  2671.           " action.\n");
  2672.         true
  2673.     else
  2674.         false
  2675.     fi
  2676.     fi
  2677. corp;
  2678.  
  2679. VerbTail(g_object, "setactword", bov_setactword)$
  2680.  
  2681. define tp_build1 proc utility bov_endSetActString(string s)void:
  2682.     thing me;
  2683.  
  2684.     me := Me();
  2685.     s := Trim(s);
  2686.     if s = "" then
  2687.     me@ p_pActiveThing -- p_oActString;
  2688.     Print("Object actstring deleted.\n");
  2689.     else
  2690.     me@p_pActiveThing@p_oActString := s;
  2691.     Print("Object actstring entered.\n");
  2692.     fi;
  2693.     me -- p_pActiveThing;
  2694. corp;
  2695.  
  2696. define tp_build proc enterActString(thing th)bool:
  2697.  
  2698.     Me()@p_pActiveThing := th;
  2699.     GetDocument("action string> ", "Enter action string",
  2700.     th@p_oActString, bov_endSetActString, false)
  2701. corp;
  2702.  
  2703. define tp_build1 proc utility bov_setactstring(string symbol)bool:
  2704.     thing th;
  2705.  
  2706.     if symbol = "" then
  2707.     Print("Use is: @object setactstring <object-symbol>\n");
  2708.     false
  2709.     else
  2710.     th := objNameCheck(symbol);
  2711.     if th ~= nil then
  2712.         enterActString(th)
  2713.     else
  2714.         false
  2715.     fi
  2716.     fi
  2717. corp;
  2718.  
  2719. Verb1(g_object, "setactstring", 0, bov_setactstring)$
  2720.  
  2721. define tp_build1 proc utility bov_setactaction()bool:
  2722.     string thingName, name;
  2723.     thing th;
  2724.     action a;
  2725.  
  2726.     thingName := GetWord();
  2727.     name := GetWord();
  2728.     if thingName = "" or name = "" or GetWord() ~= "" then
  2729.     Print(
  2730.         "Use is: @object setactaction <object-symbol> <action-symbol>\n");
  2731.     false
  2732.     else
  2733.     th := objNameCheck(thingName);
  2734.     if th ~= nil then
  2735.         if name == "nil" then
  2736.         th -- p_oActAction;
  2737.         Print("Actaction removed.\n");
  2738.         true
  2739.         else
  2740.         a := actionNameCheck(name);
  2741.         if a = nil then
  2742.             false
  2743.         else
  2744.             th@p_oActAction := a;
  2745.             Print("Actaction set.\n");
  2746.             true
  2747.         fi
  2748.         fi
  2749.     else
  2750.         false
  2751.     fi
  2752.     fi
  2753. corp;
  2754.  
  2755. VerbTail(g_object, "setactaction", bov_setactaction)$
  2756.  
  2757. define tp_build1 proc utility bov_gettable()bool:
  2758.     string errorMessage, symbol, yesNo;
  2759.     thing th;
  2760.  
  2761.     errorMessage := "Use is: @object gettable <object-symbol> [yes|no]\n";
  2762.     symbol := GetWord();
  2763.     if symbol = "" then
  2764.     Print(errorMessage);
  2765.     false
  2766.     else
  2767.     th := objNameCheck(symbol);
  2768.     if th ~= nil then
  2769.         yesNo := GetWord();
  2770.         if yesNo = "" then
  2771.         yesNo := "y";
  2772.         fi;
  2773.         if GetWord() ~= "" then
  2774.         Print(errorMessage);
  2775.         false
  2776.         else
  2777.         if isYes(yesNo) then
  2778.             th -- p_oNotGettable;
  2779.             Print(symbol + " marked as gettable.\n");
  2780.             true
  2781.         elif isNo(yesNo) then
  2782.             th@p_oNotGettable := true;
  2783.             Print(symbol + " marked as not gettable.\n");
  2784.             true
  2785.         else
  2786.             Print(errorMessage);
  2787.             false
  2788.         fi
  2789.         fi
  2790.     else
  2791.         false
  2792.     fi
  2793.     fi
  2794. corp;
  2795.  
  2796. VerbTail(g_object, "gettable", bov_gettable)$
  2797.  
  2798. define tp_build1 proc utility bov_islight()bool:
  2799.     string errorMessage, symbol, yesNo;
  2800.     thing th;
  2801.  
  2802.     errorMessage := "Use is: @object islight <object-symbol> [yes|no]\n";
  2803.     symbol := GetWord();
  2804.     if symbol = "" then
  2805.     Print(errorMessage);
  2806.     false
  2807.     else
  2808.     th := objNameCheck(symbol);
  2809.     if th ~= nil then
  2810.         yesNo := GetWord();
  2811.         if yesNo = "" then
  2812.         yesNo := "y";
  2813.         fi;
  2814.         if GetWord() ~= "" then
  2815.         Print(errorMessage);
  2816.         false
  2817.         else
  2818.         if isYes(yesNo) then
  2819.             th@p_oLight := true;
  2820.             Print(symbol + " marked as emitting light.\n");
  2821.             true
  2822.         elif isNo(yesNo) then
  2823.             th -- p_oLight;
  2824.             Print(symbol + " marked as not emitting light.\n");
  2825.             true
  2826.         else
  2827.             Print(errorMessage);
  2828.             false
  2829.         fi
  2830.         fi
  2831.     else
  2832.         false
  2833.     fi
  2834.     fi
  2835. corp;
  2836.  
  2837. VerbTail(g_object, "islight", bov_islight)$
  2838. Synonym(g_object, "islight", "light")$
  2839.  
  2840. define tp_build1 proc utility bov_invisible()bool:
  2841.     string errorMessage, symbol, yesNo;
  2842.     thing th;
  2843.  
  2844.     errorMessage := "Use is: @object invisible <object-symbol> [yes|no]\n";
  2845.     symbol := GetWord();
  2846.     if symbol = "" then
  2847.     Print(errorMessage);
  2848.     false
  2849.     else
  2850.     th := objNameCheck(symbol);
  2851.     if th ~= nil then
  2852.         yesNo := GetWord();
  2853.         if yesNo = "" then
  2854.         yesNo := "y";
  2855.         fi;
  2856.         if GetWord() ~= "" then
  2857.         Print(errorMessage);
  2858.         false
  2859.         else
  2860.         if isYes(yesNo) then
  2861.             th@p_oInvisible := true;
  2862.             Print(symbol + " marked as invisible.\n");
  2863.             true
  2864.         elif isNo(yesNo) then
  2865.             th -- p_oInvisible;
  2866.             Print(symbol + " marked as not invisible.\n");
  2867.             true
  2868.         else
  2869.             Print(errorMessage);
  2870.             false
  2871.         fi
  2872.         fi
  2873.     else
  2874.         false
  2875.     fi
  2876.     fi
  2877. corp;
  2878.  
  2879. VerbTail(g_object, "invisible", bov_invisible)$
  2880.  
  2881. define tp_build1 proc utility bov_container()bool:
  2882.     string symbol, count;
  2883.     thing th;
  2884.     int n;
  2885.  
  2886.     symbol := GetWord();
  2887.     count := GetWord();
  2888.     n := StringToInt(count);
  2889.     if symbol = "" or n < 0 or GetWord() ~= "" then
  2890.     Print("Use is @object container <object-symbol> <count>\n");
  2891.     false
  2892.     else
  2893.     th := objNameCheck(symbol);
  2894.     if th ~= nil then
  2895.         if n = 0 then
  2896.         th -- p_oContents;
  2897.         th -- p_oCapacity;
  2898.         Print(symbol + " marked as no longer a container.\n");
  2899.         else
  2900.         th@p_oContents := CreateThingList();
  2901.         th@p_oCapacity := n;
  2902.         Print(symbol + " marked with capacity " + IntToString(n) +
  2903.             ".\n");
  2904.         fi;
  2905.         true
  2906.     else
  2907.         false
  2908.     fi
  2909.     fi
  2910. corp;
  2911.  
  2912. VerbTail(g_object, "container", bov_container)$
  2913.  
  2914. define tp_build1 proc utility bov_position()bool:
  2915.     thing me, th;
  2916.     string name, count, verb;
  2917.     int n, which;
  2918.  
  2919.     name := GetWord();
  2920.     count := GetWord();
  2921.     verb := Verb();
  2922.     n := StringToInt(count);
  2923.     if name = "" or n < 0 or GetWord() ~= "" then
  2924.     Print("Use is @object " + verb + " <object-symbol> <count>\n");
  2925.     false
  2926.     else
  2927.     th := objNameCheck(name);
  2928.     if th ~= nil then
  2929.         which := MatchName("sitin.siton.liein.lieon.standin.standon",verb);
  2930.         if n = 0 then
  2931.         Print("No-one can now '" + verb + "' '" + name + "'\n");
  2932.         case which
  2933.         incase 0:
  2934.             th -- p_oCanSitIn;
  2935.         incase 1:
  2936.             th -- p_oCanSitOn;
  2937.         incase 2:
  2938.             th -- p_oCanLieIn;
  2939.         incase 3:
  2940.             th -- p_oCanLieOn;
  2941.         incase 4:
  2942.             th -- p_oCanStandIn;
  2943.         incase 5:
  2944.             th -- p_oCanStandOn;
  2945.         esac;
  2946.         else
  2947.         Print(IntToString(n) + " can now '" + verb + "' '" + name +
  2948.             "'\n");
  2949.         n := n + 1;
  2950.         case which
  2951.         incase 0:
  2952.             th@p_oCanSitIn := n;
  2953.         incase 1:
  2954.             th@p_oCanSitOn := n;
  2955.         incase 2:
  2956.             th@p_oCanLieIn := n;
  2957.         incase 3:
  2958.             th@p_oCanLieOn := n;
  2959.         incase 4:
  2960.             th@p_oCanStandIn := n;
  2961.         incase 5:
  2962.             th@p_oCanStandOn := n;
  2963.         esac;
  2964.         fi;
  2965.         true
  2966.     else
  2967.         false
  2968.     fi
  2969.     fi
  2970. corp;
  2971.  
  2972. VerbTail(g_object, "sitin", bov_position)$
  2973. VerbTail(g_object, "siton", bov_position)$
  2974. VerbTail(g_object, "liein", bov_position)$
  2975. VerbTail(g_object, "lieon", bov_position)$
  2976. VerbTail(g_object, "standin", bov_position)$
  2977. VerbTail(g_object, "standon", bov_position)$
  2978.  
  2979. /* This is NOT utility, so that we are SysAdmin and can do the ClearThing. */
  2980. /* It is local in tp_build1 so other wizards cannot find it. */
  2981.  
  2982. define tp_build1 proc localZapObject(thing th)void:
  2983.     ClearThing(th);
  2984. corp;
  2985.  
  2986. define tp_build1 proc utility bov_destroy()bool:
  2987.     string tableName, symbol;
  2988.     table tb;
  2989.     thing me, th;
  2990.  
  2991.     tableName := GetWord();
  2992.     symbol := GetWord();
  2993.     if tableName = "" or symbol = "" or GetWord() ~= "" then
  2994.     Print("Use is: @object destroy <table> <object-symbol>\n");
  2995.     false
  2996.     else
  2997.     tb := findTable(tableName, true);
  2998.     if tb = nil then
  2999.         false
  3000.     else
  3001.         th := objNameCheck(symbol);
  3002.         if th ~= nil then
  3003.         me := Me();
  3004.         if FindElement(me@p_pCarrying, th) < 0 then
  3005.             Print("You are not carrying '" + symbol + "'.\n");
  3006.             false
  3007.         elif th@p_oContents ~= nil and Count(th@p_oContents) ~= 0 then
  3008.             Print("The " + symbol + " is not empty.\n");
  3009.             false
  3010.         else
  3011.             localZapObject(th);
  3012.             if DeleteSymbol(tb, symbol) then
  3013.             DelElement(me@p_pCarrying, th);
  3014.             Print("It should now be gone!\n");
  3015.             changeDone("destroyed something");
  3016.             true
  3017.             else
  3018.             false
  3019.             fi
  3020.         fi
  3021.         else
  3022.         false
  3023.         fi
  3024.     fi
  3025.     fi
  3026. corp;
  3027.  
  3028. VerbTail(g_object, "destroy", bov_destroy)$
  3029.  
  3030. define tp_build1 proc utility bov_checker()bool:
  3031.     string tableName, name;
  3032.     table theTable;
  3033.  
  3034.     tableName := GetWord();
  3035.     name := GetWord();
  3036.     if tableName = "" or name = "" or GetWord() ~= "" then
  3037.     Print("Use is: @object checker <table> <action-symbol>\n");
  3038.     false
  3039.     else
  3040.     theTable := findTable(tableName, false);
  3041.     if theTable = nil then
  3042.         false
  3043.     elif IsDefined(theTable, name) then
  3044.         Print("'" + name + "' is already defined.\n");
  3045.         false
  3046.     else
  3047.         getAction(theTable, name, ck_objectChecker)
  3048.     fi
  3049.     fi
  3050. corp;
  3051.  
  3052. VerbTail(g_object, "checker", bov_checker)$
  3053.  
  3054. define tp_build1 proc utility bov_descaction()bool:
  3055.     string tableName, name;
  3056.     table theTable;
  3057.  
  3058.     tableName := GetWord();
  3059.     name := GetWord();
  3060.     if tableName = "" or name = "" or GetWord() ~= "" then
  3061.     Print("Use is: @object descaction <table> <action-symbol>\n");
  3062.     false
  3063.     else
  3064.     theTable := findTable(tableName, false);
  3065.     if theTable = nil then
  3066.         false
  3067.     elif IsDefined(theTable, name) then
  3068.         Print("'" + name + "' is already defined.\n");
  3069.         false
  3070.     else
  3071.         getAction(theTable, name, ck_objectDesc)
  3072.     fi
  3073.     fi
  3074. corp;
  3075.  
  3076. VerbTail(g_object, "descaction", bov_descaction)$
  3077. Synonym(g_object, "descaction", "readaction")$
  3078.  
  3079. define tp_build1 proc utility bov_actaction()bool:
  3080.     string tableName, name;
  3081.     table theTable;
  3082.  
  3083.     tableName := GetWord();
  3084.     name := GetWord();
  3085.     if tableName = "" or name = "" or GetWord() ~= "" then
  3086.     Print("Use is: @object actaction <table> <action-symbol>\n");
  3087.     false
  3088.     else
  3089.     theTable := findTable(tableName, false);
  3090.     if theTable = nil then
  3091.         false
  3092.     elif IsDefined(theTable, name) then
  3093.         Print("'" + name + "' is already defined.\n");
  3094.         false
  3095.     else
  3096.         getAction(theTable, name, ck_objectVoid)
  3097.     fi
  3098.     fi
  3099. corp;
  3100.  
  3101. VerbTail(g_object, "actaction", bov_actaction)$
  3102.  
  3103. define tp_build1 proc utility bov_endVerbString(string s)void:
  3104.     thing me;
  3105.     string verb;
  3106.     property string theProp;
  3107.  
  3108.     me := Me();
  3109.     verb := me@p_pActiveVerb;
  3110.     theProp := GetVerbStringProp(verb);
  3111.     if theProp = nil then
  3112.     Print("Oh-oh! bov_endVerbString can't find prop!\n");
  3113.     else
  3114.     s := Trim(s);
  3115.     if s = "" then
  3116.         me@p_pActiveThing -- GetVerbStringProp(verb);
  3117.         Print("Object " + verb + " string deleted.\n");
  3118.     else
  3119.         me@p_pActiveThing@(GetVerbStringProp(verb)) := s;
  3120.         Print("Object " + verb + " string entered.\n");
  3121.     fi;
  3122.     fi;
  3123.     me -- p_pActiveThing;
  3124.     me -- p_pActiveVerb;
  3125. corp;
  3126.  
  3127. define tp_build proc utility doSetVerbString(string verb; thing th)bool:
  3128.  
  3129.     Me()@p_pActiveVerb := verb;
  3130.     Me()@p_pActiveThing := th;
  3131.     GetDocument(verb + " string> ", "Enter " + verb + " string",
  3132.     th@(GetVerbStringProp(verb)), bov_endVerbString, false)
  3133. corp;
  3134.  
  3135. define tp_build1 proc utility bov_verbstring(string symbol)bool:
  3136.     string verb;
  3137.     thing th;
  3138.  
  3139.     verb := Verb();
  3140.     if symbol = "" then
  3141.     Print("Use is: @object " + verb + " <object-symbol>\n");
  3142.     false
  3143.     else
  3144.     th := objNameCheck(symbol);
  3145.     if th ~= nil then
  3146.         verb := SubString(verb, 0, Length(verb) - 6);
  3147.         doSetVerbString(verb, th)
  3148.     else
  3149.         false
  3150.     fi
  3151.     fi
  3152. corp;
  3153.  
  3154. Verb1(g_object, "playstring", 0, bov_verbstring)$
  3155. Verb1(g_object, "erasestring", 0, bov_verbstring)$
  3156. Verb1(g_object, "eatstring", 0, bov_verbstring)$
  3157. Verb1(g_object, "usestring", 0, bov_verbstring)$
  3158. Verb1(g_object, "activatestring", 0, bov_verbstring)$
  3159. Verb1(g_object, "deactivatestring", 0, bov_verbstring)$
  3160. Synonym(g_object, "deactivatestring", "inactivatestring")$
  3161. Verb1(g_object, "lightstring", 0, bov_verbstring)$
  3162. Verb1(g_object, "extinguishstring", 0, bov_verbstring)$
  3163. Verb1(g_object, "wearstring", 0, bov_verbstring)$
  3164. Verb1(g_object, "touchstring", 0, bov_verbstring)$
  3165. Verb1(g_object, "smellstring", 0, bov_verbstring)$
  3166. Verb1(g_object, "listenstring", 0, bov_verbstring)$
  3167. Verb1(g_object, "openstring", 0, bov_verbstring)$
  3168. Verb1(g_object, "closestring", 0, bov_verbstring)$
  3169. Verb1(g_object, "pushstring", 0, bov_verbstring)$
  3170. Verb1(g_object, "pullstring", 0, bov_verbstring)$
  3171. Verb1(g_object, "turnstring", 0, bov_verbstring)$
  3172. Verb1(g_object, "liftstring", 0, bov_verbstring)$
  3173. Verb1(g_object, "lowerstring", 0, bov_verbstring)$
  3174. Verb1(g_object, "getstring", 0, bov_verbstring)$
  3175. Verb1(g_object, "unlockstring", 0, bov_verbstring)$
  3176.  
  3177. define tp_build1 proc utility bov_verbchecker()bool:
  3178.     string verb, objectName, actionName;
  3179.     property action theProp;
  3180.     action a;
  3181.     thing th;
  3182.  
  3183.     verb := Verb();
  3184.     objectName := GetWord();
  3185.     actionName := GetWord();
  3186.     if objectName = "" or actionName = "" or GetWord() ~= "" then
  3187.     Print(
  3188.         "Use is: @object " + verb + " <object-symbol> <action-symbol>\n");
  3189.     false
  3190.     else
  3191.     th := objNameCheck(objectName);
  3192.     if th ~= nil then
  3193.         verb := SubString(verb, 0, Length(verb) - 7);
  3194.         theProp := GetVerbCheckerProp(verb);
  3195.         if theProp = nil then
  3196.         Print("Oh-oh! bov_verbchecker can't find prop!\n");
  3197.         false
  3198.         else
  3199.         if actionName == "nil" then
  3200.             th -- theProp;
  3201.             Print(Capitalize(verb) + "action removed.\n");
  3202.             true
  3203.         else
  3204.             a := actionNameCheck(actionName);
  3205.             if a = nil then
  3206.             false
  3207.             else
  3208.             th@theProp := a;
  3209.             Print(Capitalize(verb) + "action set.\n");
  3210.             true
  3211.             fi
  3212.         fi
  3213.         fi
  3214.     else
  3215.         false
  3216.     fi
  3217.     fi
  3218. corp;
  3219.  
  3220. VerbTail(g_object, "playchecker", bov_verbchecker)$
  3221. VerbTail(g_object, "erasechecker", bov_verbchecker)$
  3222. VerbTail(g_object, "eatchecker", bov_verbchecker)$
  3223. VerbTail(g_object, "usechecker", bov_verbchecker)$
  3224. VerbTail(g_object, "activatechecker", bov_verbchecker)$
  3225. VerbTail(g_object, "inactivatechecker", bov_verbchecker)$
  3226. Synonym(g_object, "inactivatechecker", "deactivatechecker")$
  3227. VerbTail(g_object, "lightchecker", bov_verbchecker)$
  3228. VerbTail(g_object, "extinguishchecker", bov_verbchecker)$
  3229. VerbTail(g_object, "wearchecker", bov_verbchecker)$
  3230. VerbTail(g_object, "touchchecker", bov_verbchecker)$
  3231. VerbTail(g_object, "smellchecker", bov_verbchecker)$
  3232. VerbTail(g_object, "listenchecker", bov_verbchecker)$
  3233. VerbTail(g_object, "openchecker", bov_verbchecker)$
  3234. VerbTail(g_object, "closechecker", bov_verbchecker)$
  3235. VerbTail(g_object, "pushchecker", bov_verbchecker)$
  3236. VerbTail(g_object, "pullchecker", bov_verbchecker)$
  3237. VerbTail(g_object, "turnchecker", bov_verbchecker)$
  3238. VerbTail(g_object, "liftchecker", bov_verbchecker)$
  3239. VerbTail(g_object, "lowerchecker", bov_verbchecker)$
  3240.  
  3241. unuse tp_build1
  3242.