User Tools

Site Tools


client_side_scripting:client_scripting_interface-basic_howto

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
client_side_scripting:client_scripting_interface-basic_howto [2020/02/02 09:35]
boingman
client_side_scripting:client_scripting_interface-basic_howto [2020/07/30 16:08]
boingman Added some specific information about newlines and additional watch arguments with expected results; amended version numbers with client
Line 8: Line 8:
 ===== Before we start ===== ===== Before we start =====
  
-Various and sundry ​clients are available for this game. For JXClient, ​the snapshot build as of 27-Jan-2020 is current.+Several ​clients are available for this game. This page documents ​the scripting capabilities of version 1.71.0 GTK2 client and the JXClient ​of 27-Jan-2020
 + 
 +CrossFire scripting does not use carriage return (hexadecimal 0d) characters as part of newlines regardless of operating system. Only the linefeed (hexadecimal 0a) character ​is acceptable as a line terminator.
  
 ===== Getting Started ===== ===== Getting Started =====
  
 The ''​script''​ command starts a script at the given path. The script must be executable (''​chmod +x''​ with an appropriate shebang). For some languages, it may be necessary to write a wrapper script to execute the actual program. The ''​script''​ command starts a script at the given path. The script must be executable (''​chmod +x''​ with an appropriate shebang). For some languages, it may be necessary to write a wrapper script to execute the actual program.
 +
 +Additionally,​ on Windows systems where the shebang is not supported, the player must provide a means of running such a script. For example ''​script python <​path-to-script>''​ if you are using python.
  
 The ''​scripts''​ command lists running scripts with a numeric identifier. Scripts can be stopped using the ''​scriptkill''​ command. The ''​scripttell''​ command can be used to send arbitrary commands to a script. The ''​scripts''​ command lists running scripts with a numeric identifier. Scripts can be stopped using the ''​scriptkill''​ command. The ''​scripttell''​ command can be used to send arbitrary commands to a script.
Line 90: Line 94:
 or or
   scriptkill <​number>​   scriptkill <​number>​
 +
 +the JXClient additionally supports
 +  scriptkillall
  
 Then type __scripts__ to ensure it's stopped (or to figure out the number of the script). Edit it, comment the line printf("​monitor\n"​),​ compile and run the script again. Move and look at console. You see nothing. The script didn't ask anything so the client didn't tell it anything. Your script will only get that for which it asks. Then type __scripts__ to ensure it's stopped (or to figure out the number of the script). Edit it, comment the line printf("​monitor\n"​),​ compile and run the script again. Move and look at console. You see nothing. The script didn't ask anything so the client didn't tell it anything. Your script will only get that for which it asks.
Line 134: Line 141:
  
   * //watch <command type>// - watch the given command from server-client protocol. <command type> specifies the commands we want to watch. Set to empty to get all commands.   * //watch <command type>// - watch the given command from server-client protocol. <command type> specifies the commands we want to watch. Set to empty to get all commands.
 +    * Besides what is already documented, watch also supports "​tick",​ "​drawinfo"​ (GTK2 client) and "​drawextinfo"​ (JXClient).
 +    * The "​tick"​ argument will provide the script with "watch tick <​integer>",​ as a tick of the client'​s clock.
 +    * The "​draw"​ commands are functionally equivalent in the GTK2 client and the JXClient with some minor differences. Both will provide the script with text printed in the Messages text area. The GTK2 provides the script with "watch drawinfo <​integer>​ <​message>",​ while the JXClient will provide "watch drawextinfo <​integer>​ <​integer>​ <​message>"​.
   * //unwatch <command type>// - unwatch the given command from server-client protocol. <command type> specifies the commands we want to watch. Set to empty to get all commands.   * //unwatch <command type>// - unwatch the given command from server-client protocol. <command type> specifies the commands we want to watch. Set to empty to get all commands.
   * //request <data type>// - Request a piece of informations from client memory. Following is a table of <data type> allowed:   * //request <data type>// - Request a piece of informations from client memory. Following is a table of <data type> allowed:
Line 160: Line 170:
 | spells ​     | Return a list of known spells, one per line | | spells ​     | Return a list of known spells, one per line |
 | stat paths  | Return spell paths: attuned, repelled, denied | | stat paths  | Return spell paths: attuned, repelled, denied |
-Note: player, skills, spells, stat path were added between versions 1.11 and 1.50 of the client.\\ 
-</​box>​ 
  
-FIXME \\ +Noteplayer, skills, spells, stat path were added between versions 1.11 and 1.50 of the GTK2 client.\\
-:!: In order to get the result ​of the request into your script'​s stdin you have to "watch request <data type>"​ before you do the request.\\ +
-:!: No, you do not need to watch requests (anymore?). The client will send the request to stdin of the script.+
  
   * //issue <​repeat>​ <​must_send>​ <​command>//​ - send <​command>​ to server on behalf of client. <​repeat>​ is the number of times to execute command <​must_send>​ tells whether or not the command must sent at all cost (1 or 0). <​repeat>​ and <​must_send>​ are optional parameters. See [[#The Issue Command]] for more details.   * //issue <​repeat>​ <​must_send>​ <​command>//​ - send <​command>​ to server on behalf of client. <​repeat>​ is the number of times to execute command <​must_send>​ tells whether or not the command must sent at all cost (1 or 0). <​repeat>​ and <​must_send>​ are optional parameters. See [[#The Issue Command]] for more details.
Line 177: Line 183:
 Here is an incomplete list of information strings send by client to script. Those informations are sent only because the client asked them, except for scripttell. Here is an incomplete list of information strings send by client to script. Those informations are sent only because the client asked them, except for scripttell.
  
-  * //​scripttell <yourname> <​additional data>// - user send special command to this script specifically+  * //​scripttell <scriptnumber> <​additional data>// - user send special command to this script specifically
   * //monitor <​repeat>​ <​must_send>​ <​command>//​   * //monitor <​repeat>​ <​must_send>​ <​command>//​
   * //monitor mark <​tag>//​   * //monitor mark <​tag>//​
client_side_scripting/client_scripting_interface-basic_howto.txt · Last modified: 2021/06/19 08:12 by boingman