View unanswered posts | View active topics It is currently Thu Feb 21, 2019 7:41 am

Reply to topic  [ 4 posts ] 
 Help with REXX script, parsing text colors? 
Author Message
Staff Sergeant

Joined: Sun Jun 14, 2015 9:24 pm
Posts: 12
Unread post Help with REXX script, parsing text colors?
I am trying to write a ZOC-REXX combat script to capture or kill Ferrengi and Evil Alien Trader ships, and could use some help with one question: Is there a command within ZOC-Rexx to determine the color attribute of text being written to the window by the game server? My problem is this: I want the script to be fully automatic, but it needs to be able to distinguish between Good and Evil AI ships, and only attack Evils, and since about 25% of the Alien Traders are Good, there's almost always some of these mixed in with Evil Aliens in sectors like Rylos or Stardock, where they tend to congregate. I only want to attack Evil Aliens, and since the Alien server assigns names and ship types at random to both Good and Evil aliens, I can't use just the name itself to determine alignment. The Attack command produces this response:
"Attack Shugi Maoshez's Scout Marauder (400,000-250) (Y/N) [N]?"
The only way to tell if this is a Good or Evil Alien Trader, at least at this particular prompt, is by the color in which the name is written to the screen; Evil aliens are colored Red, Good aliens are colored Cyan. Is there any way in Rexx to parse this color attribute? I've not been able to find one, but then I'm not an expert in Rexx. Thanks!

Tue Aug 30, 2016 4:08 pm
User avatar

Joined: Wed Apr 20, 2011 1:19 pm
Posts: 2119
Location: Oklahoma City, OK 73170 US
Unread post Re: Help with REXX script, parsing text colors?
I don't know anything about ZOC-REXX, but you are looking for an ANSI escape sequence (i.e. ^[[1;33;m). You will need to make sure the program isn't stripping out the color codes.

As an alternative, you could look at the alien's rank before initiating the attack.


TWGS2.20b/TW3.34: telnet://

Do not try and bend the spoon. That’s impossible.
Instead… only try to realize there is no spoon.

Tue Aug 30, 2016 11:12 pm
User avatar

Joined: Tue Oct 07, 2003 2:00 am
Posts: 1115
Location: Augusta, GA
Unread post Re: Help with REXX script, parsing text colors?
Just to add to what Micro said, the telnet colors are changed by a sequence of characters that begin with the ESC key code, hence the term escape codes. The Escape key (decimal 27) is usually represented as 2 characters, ^[. Then the escape sequence begins with an open bracket, and ends with the letter m.

Scroll to the bottom of this link for a simple table of codes:

I wrote a script in TWX to help display the codes coming across a telnet session, to aid in determining the right codes to watch for. I can point you towards that script if it would help.


Claim to Fame: only guy to ever crack the TW haggle algorithm, and fig/shield/hold price formula, twice.

Mon Sep 05, 2016 8:19 pm
Profile WWW

Joined: Wed Feb 28, 2001 3:00 am
Posts: 1389
Location: Boo! inc. Ireland
Unread post Re: Help with REXX script, parsing text colors?
ZOC can only capture the text that you see on the display, no ANSI data. As Micro wrote, simpler to parse the other information to determine red/blue alien. Use command line :

call zocwait _trigger_
wye= ZocGetInfo("CURSOR-Y") - where Y is the line at the trigger,

- goes back -1 (or whatever) to grab the the line with the alien info.

Fri Sep 09, 2016 1:49 pm
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: Google [Bot] and 6 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware.