[Crossfire-wiki] [Crossfire DokuWiki] page changed: cfdialog

no-reply_wiki at metalforge.org no-reply_wiki at metalforge.org
Wed Aug 22 01:34:10 CDT 2007


A page in your DokuWiki was added or changed. Here are the details:

Date        : 2007/08/22 01:34
User        : 
Edit Summary: Add example details to help CFDialog newbie.

@@ -28,14 +28,40 @@
  
  Once you have defined your rules, you have to assemble them into a dialog. Each dialog involves somebody who triggers it, somebody who answers, and has a unique name so it cannot be confused with other dialogs.
  
  Typically, the "one who triggers" will be the player, and the "one who answers" is an NPC the player was taking to. You are free to chose whatever you want for the dialog name, as long as it contains no space or special characters, and is not used by another dialog. You can then add the rules you created to the dialog. Rules are parsed in a given order, so you must add the most generic answer last.
+ 
  
  ==== A simple example ====
  
  I want to create a dialog for an old man. If I say "hello" or "hi" for the first time, grandpa will greet me. If I say it for the second time, he'll grumble (because he's like that, you know :)). I also need a generic answer if I say whatever else.
  
- In this example, the player is stored in 'player', and the old man in 'grandpa'. What the player said is in 'message'.
+ To illustrate the setup and use of this plugin, a previously inanimate NPC in Goths Tavern will be modified.  The order of the following steps is not important, but they will take you through every step required to get an NPC that uses the plugin.
+ 
+   * Edit the map file in scorn/taverns/goths as follows.
+ 
+   Index: goths
+   ===================================================================
+   --- goths       (revision 6971)
+   +++ goths       (working copy)
+   @@ -974,10 +974,15 @@
+    y 23
+    end
+    arch man
+   +name grandpa
+    x 3
+    y 23
+    friendly 1 
+   +arch event_say
+   +title Python
+   +slaying /python/maps/scorn-goths-grandpa_say.py
+    end
+   +end
+    arch woodfloor
+    x 3
+    y 24
+ 
+  * Create a new file in the maps directory python/maps/scorn-goths-grandpa_say.py and place the following code in the file.
  
    import Crossfire
    import string
    from CFDialog import Dialog, DialogRule
@@ -72,4 +98,21 @@
    speech.addRule(DialogRule("*", prer, rmsg, postr),2)
    #
    # We only have to let the old man speak now:
    speech.speak(message)
+ 
+  * In this example, the player is stored in 'player', and the old man in 'grandpa'. What the player said is in 'message'.
+ 
+  * Start the crossfire server, login, then enter Goths tavern and walk up to the man now named "grandpa" in the left-hand room.  He is in the top left-hand corner of the room.
+ 
+  * Say hello two times.
+ 
+   Player says: hello
+   grandpa says: Hello, lad!
+   Player says: hello
+   grandpa says: I've heard, you know, I'm not deaf *grmbl*
+ 
+  * The conversation state is stored in your player file.  For example:
+ 
+   $ grep -ri test_grandpa var
+   var/crossfire/players/Player/Player.pl:dialog_test_grandpa_01 hello:1
+ 


IP-Address  : 75.23.37.53
Old Revision: http://wiki.metalforge.net/doku.php/cfdialog?rev=1178621196
New Revision: http://wiki.metalforge.net/doku.php/cfdialog

-- 
This mail was generated by DokuWiki at
http://wiki.metalforge.net/




More information about the crossfire-wiki mailing list