[Crossfire-wiki] [Crossfire DokuWiki] page changed: cfpython:tod

no-reply_wiki at metalforge.org no-reply_wiki at metalforge.org
Thu Nov 22 16:29:28 CST 2007


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

Date        : 2007/11/22 16:29
User        : tchize
Edit Summary: Up to date documentation with trunk

@@ -1,14 +1,35 @@
  ====== Time based python scripts ======
- The folder /python/tod in crossfire maps contains several script ready to be linked to event_xxxx object in map editor. All those scripts use the notion of period of the day and period of the year, they do different things, but all use the same way to name period. It's simply the period name, as can be found in following table. The names are case sensitive. For scripts that accept several periods, name of periods are spearated by coma, please don't add additionnal spaces between coma and name of period
- ===== Parameter values =====
+ ===== Common conventions =====
+ The folder /python/tod in crossfire maps contains several scripts ready to be linked to event_xxxx object in map editor. All those scripts use common naming and parameters conventions. 
+ ==== JSON parameters ====
+ All parameters are passed as arguments in //Message// of event, using JSON (JavaScript Object Notation). Basically, it takes the forms of "key" : "value" list enclosed in braces. Example:<code javascript>
+ {
+   "key1" : "value1",
+   "key2" : "value2",
+ 
+   "key3" : "value3"
+ }</code>
+ For boolean type, the possible values are ''True'' and ''False'', other type are, for now, only String between double quotes. Some script parameters accept list of value. A list uses square bracket and separate it's value by comas. Example:
+ <code javascript>
+ {
+     "key"   : "skeleton kills"
+     "when"  : ["Dawn","Morning","Noon","Evening","Dusk"]
+     "from"  : ["skeleton","generator"],
+     "to"    : ["bones1","bones2","bones3"],
+     "match" : "one"
+ }
+ </code>
+ I hope to see gridarta editor be able to edit such structure for you, but until then you will have to do it by hand. It's not very complex to understand anyway.
+ ==== Period type parameter values ====
+ All time based scripts use the notion of period name, as can be found in following table. The names are case sensitive. 
  
  ^ name of period ^ description ^
- |The Season of New Year| Starting 1st month, ending 3rd month|
- |The Season of Growth| Starting 4th month, ending 6st month|
- |The Season of Harvest| Starting 7th month, ending 9th month|
- |The Season of Decay| Starting 10th month, ending 12th month|
- |The Season of the Blizzard| Starting 13th month, ending 17th month|
+ |The Season of New Year| Starting 1st month of the year, ending 3rd month|
+ |The Season of Growth| Starting 4th month of the year, ending 6st month|
+ |The Season of Harvest| Starting 7th month of the year, ending 9th month|
+ |The Season of Decay| Starting 10th month of the year, ending 12th month|
+ |The Season of the Blizzard| Starting 13th month of the year, ending 17th month|
  |Month of Winter| |
  |Month of the Ice Dragon| |
  |Month of the Frost Giant| |
  |Month of Valriel| |
@@ -38,96 +59,52 @@
  |Noon| Between 13:00 am and 1:00 pm |
  |Evening| Between 1:00 pm and 6:00 pm |
  |Dusk| Between 6:00 pm and 9:00 pm |
  
- For demonstration of the scripts, mapmakers are invited to take a look at the demo map at /test/tod
- ===== Filtering based on period list =====
- ==== match any ====
- 
- Script name: **/python/tod/filter_one_period.py**
- 
- This script will stop the event from propagating if the current time of the server matches **any** of the times defined as script parameters. Typical use:
- 
-   arch event_apply
-   title Python
-   slaying /python/tod/filter_one_period.py
-   name The Season of New Year,The Season of the Blizzard,Morning
-   end
- 
- If any of the period of day/year mentionned in parameter match the current server time, the event will be propagated. Otherwise it will be stopped. In this example, the object this event is attached too will be usable on ly during New Year, blizzard or Morning.
- 
- ==== Match all  ====
- Script name: **/python/tod/filter_all_periods.py**
- 
- This script will stop the event from propagating if the current time of the server matches **all** of the times defined as script parameters. Typical use:
-   arch event_apply
-   title Python
-   slaying /python/tod/filter_all_periods.py
-   name the Day of the Moon,The Season of the Blizzard,Morning
-   end
- 
- If all of the period of day/year mentionned in parameter match the current server time, the event will be propagated. Otherwise it will be stopped. In this example, the object this event is attached too will be usable only during Mornings of days of the moon during the season of Blizzard.
- 
- 
- ===== Scheduling map triggers =====
- Those scripts run a "connected" list inside the current map, at a specific time. Arguments required by those scripts are, the value of the "connected" chain to run and the periods of time concerned by this triggering. Those script could be used by any event, however it is typical to use them in the EVENT_TIME of a living object, so as to ensure the script is run often enough to react on time. However you could, without trouble, use it in EVEN_DEATH or a monster, EVENT_APPLY of a button, etc. Just keep in mind the script can't do anything unless it get called ;)
- 
- ==== On any matching period of time ====
- Script name: **/python/tod/push_one_period.py**
- 
- This will trigger the connected list if any of the specified periods matches the current time of server. The "source" of the trigger will be the object containing event. The script will "push" the connected list when entering period and "release" it when exiting period. The script will keep correct state, whatever happens concerning map loading / caching. Upon reload, it will resynchronized to current server state and take appropriate action to "release" or "push" the connected list. The first argument or parameter list is always the integer number of connected list to trigger.
- 
- Typical use:
+ For demonstration of the scripts, mapmakers are invited to take a look at the demo maps at /test/tod and test/tod2
  
-  arch event_time
-  title Python
-  slaying /python/tod/push_one_period.py
-  name 69,Morning,Noon
-  end
+ ===== Available scripts =====
+ ==== Filtering ====
+ **Script** /python/tod/filter.py
  
- This example will trigger the connected list number 69 on current map whenever it is Morning or Noon.
- ==== On matching all periods ====
- Script name: **/python/tod/push_all_periods.py**
+ **Description** TODO
  
- This will trigger the connected list if all of the specified periods matches the current time of server. The "source" of the trigger will be the object containing event. The script will "push" the connected list when entering period and "release" it when exiting period. The script will keep correct state, whatever happens concerning map loading / caching. Upon reload, it will resynchronized to current server state and take appropriate action to "release" or "push" the connected list. The first argument or parameter list is always the integer number of connected list to trigger.
+ **Parameters**
+   * **when**(list): periods of day when this filter lets event it is attached to happen.
+   * **match**: one or all, whethever only one match in list is needed or all must match current time
+   * **inverse**: if true, a match is seen as a non-match and vice version. See that as a "everytime except when ...." rule
  
- Typical use:
-   arch event_time
-   title Python
-   slaying /python/tod/push_all_periods.py
-   name 69,Morning,The Season of New Year
-   end
  
- This example will push the connected list number 69 of current Map upon entering a Morning of Season of New Year and release it when leaving that day. The source of the push and release will be the object the event is embedded in.
+ ==== Pushing ====
+ **Script** /python/tod/push.py
  
- ===== Changing object depending on time =====
- Those scripts can exchange object at specific period of times. When entering a matching period, the object for which the event is trigger get replaced by an object stored in the event. When leaving the matching period of time, the original object is restored and the replacement object is put back inside the event, hidden to the players. With this system you can replace any object with any other object. Typical use is to create gargoylesn that transfom into stone during the day, or werewolves that transforms during the nights of the Day of the moon. One important thing to keep in ming is that, is you use event_time to make the change, the originial object **and** the replacement object should create the time event. This is because the scriptnot only replace the orignial object by the one configured but also displace the event responsible for the script from the original object to the replacement.
+ **Description**: Schedules a map trigger at a specific period of time. It runs a "connected" list inside the current map, at a specific time. This script could be used by any event, however it is typical to use it in the EVENT_TIME of a living object, so as to ensure the script is run often enough to react on time. However you could, without trouble, use it in EVEN_DEATH or a monster, EVENT_APPLY of a button, etc. Just keep in mind the script can't do anything unless it get called ;) This script keep information on it's current push state, so it won't push twice the connected list and will release the connected list when needed.
  
- ==== Matching any period of a list ====
- Script name: **/python/tod/replace_one_period.py**
+ **Parameters**
+   * **when**(list): periods of day when this script will stay "pushed".
+   * **match**: one or all, whethever only one match in list is needed or all list must match current time
+   * **inverse**: if true, a match is seen as a non-match and vice version. See that as a "everytime except when ...." rule
+   * **connected**: what to push/release in map
  
- This script will make the replacement upon matching any period of time given in argument list. Typical use:
+ ==== Object transforming ====
+ **Script** /python/tod/replace.py
  
-   arch event_time
-   title Python
-   slaying /python/tod/replace_one_period.py
-   name Morning,Noon
-   arch beholder
-   end
-   end
+ **Description**:  Makes the object is is attached to swap at given periods of day with a specifc object in the event's inventory. To use it, give this event's parameters a period an a match rule. Put also in the inventory the swapped object (owner of event) the object that will replace it. The swap is reversed when leaving the swap matching period. This work both on map items and on inventory items. Typically this script would be attached to the event_time of the object to transform.
  
- This script will, between Morning and Noon, replace it's containing object by the beholder that is inside the script.
+ **Parameters**
+   * **when**(list): periods when this script's owner will stay transformed.
+   * **match**: one or all, whethever only one match in list is needed or all list must match current time
+   * **inverse**: if true, a match is seen as a non-match and vice version. See that as a "everytime except when ...." rule
  
- ==== Matching all periods of a list ====
- Script name: **/python/tod/replace_all_periods.py**
+ ==== Map transforming ====
  
- This script, when matching all period of time given as argument, will do the swap. Typical use:
+ **Script** /python/tod/replace_in_map.py
  
-   arch event_time
-   title Python
-   slaying /python/tod/replace_one_period.py
-   name Night,the Day of the Moon
-   arch beholder
-   end
-   end
+ **Description**:  Scan the current map of objects matching some criterias and transform them into another specific object. Like for Object Transforming, the transformation is reverted at end of specified period. This work ony on map items. Typically this script would be attached to the event_time of guardian object.
  
- This example will, during the Night of the Day of the Moon, replace it's container by a beholder. The container will be restored when leaving the period.
+ **Parameters**
+   * **when**(list): periods when this script's owner will stay transformed.
+   * **match**: one or all, whethever only one match in list is needed or all list must match current time
+   * **inverse**: if true, a match is seen as a non-match and vice version. See that as a "everytime except when ...." rule
+   * **from**(list): criterias that map object must match to be transformed
+   * **to**(list): name of object that will be created to replace transformed object. The newly created objects will be made unpickable so they stay on the map. 
+   * **key**: a keyword used to keep track of transformed object when time comes to untransform them. This is used to prevent clash if several transformation script are working on same map


IP-Address  : 91.177.206.171
Old Revision: http://wiki.metalforge.net/doku.php/cfpython:tod?rev=1195336081
New Revision: http://wiki.metalforge.net/doku.php/cfpython:tod

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




More information about the crossfire-wiki mailing list