[Crossfire-wiki] [Crossfire DokuWiki] page changed: client_side_scripting:client_scripting_interface-basic_howto

no-reply_wiki at metalforge.org no-reply_wiki at metalforge.org
Fri Aug 18 11:52:41 CDT 2006


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



Date        : 2006/08/18 11:52

User        : eracc

Edit Summary: 



@@ -92,10 +92,10 @@

  \\ 

  == A strange C command ==

    fflush(stdout)

  

- The stdout has something called a buffer. When you write to output devic
e, it's not immediatly sent to it. For performance reasons, successive pri
nt to stdout are grouped. Most of the time, \n is enough to force sending 
of data, but we ensure all data are sent to client by flushing the stdout 
(force empty buffer). In the future, when you think client didn't get a co
mmand but the script did send it, ensure you flushed stdout.

- 

+ The stdout has something called a buffer. When you write to output devic
e, it's not immediatly sent to it. For performance reasons, successive pri
nt to stdout are grouped. Most of the time, \n is enough to force sending 
of data, but we ensure all data are sent to client by flushing the stdout 
(force empty buffer). In the future, when you think client didn't get a co
mmand but the script did send it, ensure you flushed stdout.\\ 

+ \\ 

  Then comes a loop. This loop will read from stdin (where client puts inf
ormations for the script) and copy them to stderr (our only access to cons
ole since stdout is a connection to client). Because I don't want to use s
canf I used the binary read and write commands. Stdin is the file handle 0
 and stderr is file handle 2. We first read up to 200 char from stdin and 
if we read something we write it to stderr. If we didn't read anything, th
at means we have lost the client (shouldn't happen) and we simply exit.

  

  Since we asked to monitor all commands from client to server, we get the
m. These commands are our move commands and they use the same format as is
sue. If you run our first script while this second script is still running
, you will still say hello world, but you'll get the following in your con
sole:

  

@@ -144,10 +144,9 @@

  

  === What's next? ===

  There are two things you can still do with Script. The first is to reque
st a bit of informations. The client then tells the script what it wants t
o know. The second thing is triggering an action of the script from client
 interface. The command scripttell allows player to say something to a scr
ipt. The script will get the exact command typed by player. See below for 
command list.

  

- **Commands to client**

- 

+ == Commands to client ==

  Here is a list of command the script can send to client.

  

    * //watch <command type>// - watch the given command from server-clien
t 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-c
lient protocol. <command type> specifies the commands we want to watch. Se
t to empty to get all commands.

@@ -180,10 +179,9 @@

    * //draw <color> <text>// - draw the following text on client interfac
e with given color. Usefull for debugging and may help you to forget about
 using the stderr

    * //monitor// - start monitoring commands send from client to server. 
Doesn't take any parameter.

    * //unmonitor// - stop monitoring commands send from client to server.
 Doesn't take any parameter.

  

- **Information from client**

- 

+ == Information from client ==

  Here is an incomplete list of information strings send by client to scri
pt. Those informations are sent only because the client asked them, except
 for scripttell.

  

    * //scripttell <yourname> <additional data>// - user send special comm
and to this script specifically

    * //monitor <repeat> <must_send> <command>//





IP-Address  : 72.4.41.2

Old Revision: http://wiki.metalforge.net/doku.php/client_side_scripting:cl
ient_scripting_interface-basic_howto?rev=1155919720

New Revision: http://wiki.metalforge.net/doku.php/client_side_scripting:cl
ient_scripting_interface-basic_howto



-- 

This mail was generated by DokuWiki at

http://wiki.metalforge.net/





More information about the crossfire-wiki mailing list