www.ClassicTW.com
https://www.classictw.com/

Working with charCodes in Scripts
https://www.classictw.com/viewtopic.php?f=15&t=34474
Page 1 of 1

Author:  SteveH_66 [ Tue Nov 18, 2014 3:15 pm ]
Post subject:  Working with charCodes in Scripts

I know that you can use character codes in TWX scripts like in triggers, I am using #11 to trip a trigger in a script now when I press Ctrl + k. What I am wondering is if there is any way to pass character codes back and forth between scripts?

If that were possible, you could use that to communicate between scripts and even call and kill scripts automatically between scripts. I have tried send #11, send #12, things like that and it doesn't work. Can anyone think of something that would work?

Author:  Vid Kid [ Wed Nov 19, 2014 8:03 am ]
Post subject:  Re: Working with charCodes in Scripts

SteveH_66 wrote:
I know that you can use character codes in TWX scripts like in triggers, I am using #11 to trip a trigger in a script now when I press Ctrl + k. What I am wondering is if there is any way to pass character codes back and forth between scripts?

If that were possible, you could use that to communicate between scripts and even call and kill scripts automatically between scripts. I have tried send #11, send #12, things like that and it doesn't work. Can anyone think of something that would work?


I'm not going to type a lot on the subject but look into the commands

processIn
processOut

These will lead you in the direction your after.

Vid

Author:  Adept [ Sat Mar 05, 2016 4:26 am ]
Post subject:  Re: Working with charCodes in Scripts

Where is there a list of these available character codes for use by TWXProxy?

I keep seeing use of whatever they are as triggers in scripts such as #145 & #8, #145, etc. I have searched but cannot find anything referencing what these actually represent or how to apply them, e.g., ASCII, character codes, or keyboard codes.

ETA:

I believe this is what I was looking for (the decimal codes): http://www.asciitable.com/

Author:  Grey Gamer [ Mon Aug 01, 2022 6:59 pm ]
Post subject:  Re: Working with charCodes in Scripts

When I was a teenager I bought a giant book called "The QuickBasic Bible." It was a thousand pages and I held onto it for years just because it had an ASCII table on the inside back cover.

You don't think I could have just photocopied that one page, do you? :D

Author:  Micro [ Tue Aug 02, 2022 12:45 am ]
Post subject:  Re: Working with charCodes in Scripts

Adept wrote:
Where is there a list of these available character codes for use by TWXProxy?

I keep seeing use of whatever they are as triggers in scripts such as #145 & #8, #145, etc. I have searched but cannot find anything referencing what these actually represent or how to apply them, e.g., ASCII, character codes, or keyboard codes.

ETA:

I believe this is what I was looking for (the decimal codes): http://www.asciitable.com/

Correct those are ascii characters, and characters > 127 are Code Page 437 drawing characters, also called IBM Extended Ascii although IBM never endorsed the name.

Ascii Codes < 32 are not printable (i.e. 8 = backspace)

You willl see Zedbot use:

Code:
        Send #145
        WaitOn #145 & #8


#145 is a "non-printer" or "Invisible" character. TWGS will echo it followed by a #8 (backspace). You would have to ask JP why TWGS/TW2002 does this, as I have no idea.

The end result is that if tou send a long macro:

Code:
        Send "l j" #8 #8 $z_planet "* * c x q * " #145
        WaitOn #145 & #8


The script will not continue until your macro finishes.

Author:  Micro [ Tue Aug 02, 2022 1:08 am ]
Post subject:  Re: Working with charCodes in Scripts

SteveH_66 wrote:
I know that you can use character codes in TWX scripts like in triggers, I am using #11 to trip a trigger in a script now when I press Ctrl + k. What I am wondering is if there is any way to pass character codes back and forth between scripts?

If that were possible, you could use that to communicate between scripts and even call and kill scripts automatically between scripts. I have tried send #11, send #12, things like that and it doesn't work. Can anyone think of something that would work?


Ascii characters < 32 are called control characters #10 is LF, #13 is CR, and you need both of those to start a new line.

If you send control characters #11, send #12 to TWGS/TW2002 it will ignore them and not echo them. This is how a server should correctly handle this.

There are a commands in TWX for interscript communication. Here is an excerpt from Zedbot:

Code:
# In Z-Bot Version Command
:INTCOM_VER
        SetVar $Z_Lib~message $scripttitle & " v" & $version & "*"
        SetVar $Z_Lib~messageto $sender
        SetVar $Z_Lib~messagemode "R"
        Gosub :MSGBRIDGE

        PROCESSIN 1 "[Z]VERSION[Z]"
        Return

# In other scripts i.e. ComsGuard:
        SetTextTrigger      ver :VERSION "[Z]VERSION[Z]"


PROCESSIN sends a line of text, as if it came from the server, but it not actually sent or echoed.

The end result is that all Zedbot daemons that are running will report their version immediately after Zedbot does.

Zedbot uses a lot of these, including to shudown daemons cleanly.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/