This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
cfpython:cfpython [2020/03/04 04:58] meta-aeon [WhoAmI] |
cfpython:cfpython [2020/03/07 12:12] meta-aeon [SetReturnValue] |
||
---|---|---|---|
Line 169: | Line 169: | ||
==== WhoIsActivator ==== | ==== WhoIsActivator ==== | ||
- | Returns the ''Crossfire.Object'' having caused the event being handled, corresponds to the ''[[server_plugin#Hooking to an object-specific event|activator]]'' parameter of the event. Can be ''None''. | + | Returns the ''Crossfire.Object'' having caused the event being handled, corresponds to the ''[[server_plugin#Hooking to an object-specific event|activator]]'' parameter of the event. Can be ''None''. For example, if the script was activated by a player applying an item, then WhoIsActivator points to the player. |
=== Examples === | === Examples === | ||
* [[cfpython#Move a player onto a map]] | * [[cfpython#Move a player onto a map]] | ||
Line 194: | Line 195: | ||
Sets the value the plugin will return to the server when the script exits. Value and effect depend on the event being handled. | Sets the value the plugin will return to the server when the script exits. Value and effect depend on the event being handled. | ||
+ | |||
+ | For "apply" events, ''Crossfire.SetReturnValue(0)'' will cause both the script to run and the item to be applied. ''Crossfire.SetReturnValue(1)'' will instead cause only the script to run - the apply to the item will be intercepted. For example, if a script is attached to a carrot, then ''0'' will run the script and eat the carrot, and ''1'' will run the script without eating the carrot. | ||
==== PluginVersion ==== | ==== PluginVersion ==== | ||
Returns an integer representing the Python plugin version. | Returns an integer representing the Python plugin version. | ||
Line 860: | Line 863: | ||
==== WriteKey ==== | ==== WriteKey ==== | ||
- | Inserts specified key/value in the object. | + | Inserts specified key/value in the object. If the object is persistent (such as a player, or an item with the unique attribute set to 1), then the key will persist between server restarts. |
Arguments: | Arguments: | ||
Line 913: | Line 916: | ||
Arguments: | Arguments: | ||
- | * ''String'', name of object to create | + | * ''String'', arch name of object to create |
- | * ''Integer'', ''x'' and ''y'', coordinates | + | * ''Tuple'', containing an ''x'' ''Integer'' and a ''y'' ''Integer'', as coordinates |
- | Equivalent of calling ''Crossfire.CreateObjectByName()'' (creates an item from archetype or name) and inserting it in the map at the specified location | + | Equivalent of calling ''Crossfire.CreateObjectByName()'' (creates an item from archetype or name) and inserting it in the map at the specified location. |
+ | |||
+ | Example of format: | ||
+ | <code>examplemap.CreateObject('tree5', (3, 8))</code> | ||
==== Check ==== | ==== Check ==== | ||
Arguments: | Arguments: | ||
- | * ''String'', name of object to check for. Should be a raw name, without the bonuses and title and such. | + | * ''String'', name of object to check for. Should be a raw arch name, without the bonuses and title and such. |
- | * ''Integer'', optional ''x'' and ''y'' coordinates | + | * ''Tuple'', containing an ''x'' ''Integer'' and a ''y'' ''Integer'', as coordinates |
Return: | Return: | ||
- | * the first object at the specified location matching specified name | + | * the first object at the specified location matching specified arch name |
+ | |||
+ | Example of format: | ||
+ | <code>examplemap.Check('tree5', (3, 8))</code> | ||
==== Next ==== | ==== Next ==== |