[Twisted-Python] Reality Servers - diffs included

Chris.Hadgis at mincom.com Chris.Hadgis at mincom.com
Wed Sep 5 17:51:25 MDT 2001


Here is a diff for tkfaucet for inclusion in 0.10.2

Changes made are (1) shortcuts, (2) word-wrapped, logically-sized  frames, 
(3) errors in a message box

--- C:\TMLold\Twisted-0.10.0\twisted\reality\ui\tkfaucet.py     Sun Aug 19 
17:52:46 2001
+++ C:\TML\Twisted-0.10.0\twisted\reality\ui\tkfaucet.py        Tue Aug 28 
22:18:54 2001
@@ -20,25 +20,39 @@
 
 from Tkinter import *
 from ScrolledText import *
+from tkMessageBox import *
 
 from twisted.spread import pb
 from twisted.internet import tkinternet, main, tcp
 
 class MainWindow(Toplevel, pb.Referenced):
+
+    shortcuts = {"n":"go north",
+                 "s":"go south",
+                 "e":"go east",
+                 "w":"go west",
+                 "l":"look",
+                 "ne":"go northeast",
+                 "nw":"go northwest",
+                 "sw":"go southwest",
+                 "se":"go southeast",
+                 "u":"go up",
+                 "d":"go down"}
+
     def __init__(self, *args,**kw):
         self.descriptions = {}
         self.items = {}
         self.exits = []
         apply(Toplevel.__init__,(self,)+args,kw)
         self.title("Reality Faucet")
-        self.happenings = ScrolledText(self, height=5, width=5)
+        self.happenings = ScrolledText(self, height=6, width=72, 
wrap='word')
 
         midf = Frame(self)
         ddf = Frame(midf)
         idf = Frame(midf)
 
-        a = self.descriptionField = ScrolledText(ddf, height=5, width=5)
-        b = self.itemsField = ScrolledText(idf, height=5, width=30)
+        a = self.descriptionField = ScrolledText(ddf, height=12, 
width=72, wrap='word')
+        b = self.itemsField = ScrolledText(idf, height=12, width=36, 
wrap='word')
         a.pack(fill=BOTH, expand=YES)
         b.pack(fill=BOTH, expand=YES)
         ddf.pack(side=LEFT, fill=BOTH, expand=YES)
@@ -72,6 +86,7 @@
 
     def tryAgain(self, er):
         print 'oops',er
+        showerror('Oops', er)
 
     def disco(self):
         print 'disconnected'
@@ -128,6 +143,9 @@
 
     def doSend(self, *evstuf):
         sentence = self.entry.get()
+        possible_shortcut = self.shortcuts.get(sentence)
+        if possible_shortcut:
+            sentence = possible_shortcut
         self.doNow(sentence)
         self.entry.delete('0','end')
 


Here is a diff for trdemo for inclusion in 0.10.2

Changes made are (1) correct broadcast for John Romero "pull", (2) correct 
broadcast for John Romero "drop"

--- C:\TMLold\Twisted-0.10.0\trdemo\trdemo\trdemo.py    Mon Aug 20 
21:46:14 2001
+++ C:\TML\Twisted-0.10.0\trdemo\trdemo\trdemo.py       Mon Sep 03 
23:20:02 2001
@@ -175,15 +175,19 @@
         """
         self.broadcastToPair(sentence.subject,
                              to_subject="",
                              to_target=("You pull ",self,"'s string."),
                              to_other =(sentence.subject," pulls 
",self,"'s string."))
         f = whrandom.random()
         if f < 0.3:
-            self.broadcast(self,"'s string reels back in, and it chirps 
\"",whrandom.choice(self.dollSpeech),"\" in a faint, high-pitched voice.")
+            s = (self,"'s string reels back in, and it chirps 
\"",whrandom.choice(self.dollSpeech),"\" in a faint, high-pitched voice.")
         elif f < 0.7:
-            self.broadcast(self,"'s string reels itself back in, and it 
says, \"",whrandom.choice(self.dollSpeech),"\" in a faint, high-pitched 
voice.")
+            s = (self,"'s string reels itself back in, and it says, 
\"",whrandom.choice(self.dollSpeech),"\" in a faint, high-pitched voice.")
         else:
-            self.broadcast("As ",self,"'s string reels in, it squeaks 
\"",whrandom.choice(self.dollSpeech),"\"")
+            s = ("As ",self,"'s string reels in, it squeaks 
\"",whrandom.choice(self.dollSpeech),"\"")
+        self.broadcastToPair(sentence.subject,
+                             to_subject="",
+                             to_target=s,
+                             to_other="")
 
 
     def verb_squeeze(self, sentence):
@@ -202,7 +206,11 @@
 
         Now you can be just like eidos!
         """
-        self.broadcast(self," emits a faint squeak as it lands on the 
floor.")
+        if self.location._hasIntelligence():
+            # self.broadcast(self," emits a faint squeak as it lands on 
the floor.")
+            self.broadcastToPair(sentence.subject, to_subject='',
+                                 to_target = (self," emits a faint squeak 
as it lands on the floor."),
+                                 to_other = '')
         raise error.InappropriateVerb()
 
 class Fountain(thing.Thing):



I will make fixing up the broadcast() and hears() routines my priority 
unless someone else wants to do it. I have not submitted any patches for 
this yet because I am still working on it.

I suggest renaming InappropriateVerb to PassVerb. TADS uses pass when a verb has been "over-written" as in 
this case.

What is the story behind the brass cockroach :)

Cheers,
ChrisH



-- 
This transmission is for the intended addressee only and is confidential
information.  If you have received this transmission in error, please
delete it and notify the sender.  The contents of this e-mail are the
opinion of the writer only and are not endorsed by the Mincom Group
of companies unless expressly stated otherwise.





More information about the Twisted-Python mailing list