LPMuds.net

Lib Discussion => Dead Souls Support => Topic started by: Raudhrskal on August 29, 2008, 02:04:49 pm

Title: Configurable prepositions for furniture
Post by: Raudhrskal on August 29, 2008, 02:04:49 pm
Kelton at i3 wants to have a piece of furniture to "sit in".

This is a stub of code allowing to make it work.

Code: [Select]
--- ds-dist/lib/lib/lvs/position.c 2008-06-01 21:25:34.000000000 +0200
+++ ds/lib/lib/lvs/position.c 2008-08-29 21:00:44.736593528 +0200
@@ -151,7 +151,7 @@
         }
         return 1;
     }
-    send_messages("sit", "$agent_name $agent_verb down on " +
+    send_messages("sit", "$agent_name $agent_verb down "+target->GetPreposition()+" " +
       target->GetShort() + ".", this_object(), 0, environment());
     Position = POSITION_SITTING;
     Chair = target;
--- ds-dist/lib/lib/events/sit.c 2008-07-07 20:00:36.000000000 +0200
+++ ds/lib/lib/events/sit.c 2008-08-29 20:40:45.303935008 +0200
@@ -10,6 +10,7 @@
 
 private int          MaxSitters = 1;
 private object array Sitters    = ({});
+private string preposition = "on";
 
 int GetMaxSitters(){
     return MaxSitters;
@@ -23,6 +24,17 @@
     return copy(Sitters);
 }
 
+string GetPreposition()
+  {
+    return preposition;
+  }
+
+string SetPreposition(string nw)
+  {
+    if(strlen(nw)) preposition = nw;
+    return preposition;
+  }
+
 mixed eventReceiveSit(object who){
     mixed furn = who->GetProperty("furniture");
     if(furn && objectp(furn)){
@@ -30,7 +42,7 @@
         return 1;
     }
     Sitters = ({ Sitters..., who });
-    who->SetProperty("furniture", " on "+this_object()->GetShort());
+    who->SetProperty("furniture", " "+preposition+" "+this_object()->GetShort());
     who->SetProperty("furniture_object", this_object());
     return 1;
 }
Now just put SetPreposition("in"); (or whatever you want) into your create().

Of course, the same pattern is used on other verbs. Lie, kneel... Will add it later, it's just a ad-hoc piece of code.
Think of it as a demo version having support for only one verb ;).

Regards,
'Skal