FAQ for TWX Proxy
Created 7 January 2002
This FAQ is created by Duanne ‘nzthordm’ McMahon by using
all the interesting and lame questions put to the forum. Where possible I will use actual copies of the
question and answer from the forum, with notes added to help understand both
the question and answer. This FAQ will
be in no particular order however, as it is a first read, first added basis.
I have made some minor corrections along the lines or removing
invalid/outdated entries, but no spelling or gramma corrections have been
made. So all spelling/gramma errors are
the responsibility of the writer of each question/answer.
Question and Answer Shortcuts
Question 1. Gathering Information
Question 2. Multiple Connections to one TWX Proxy?
Question 3. What can be done to speed up script
execution?
Question 4. Reading/Writing files, and Loading Files?
Question 5. Where can one find the scripts to load?
Question 6. What hidden Variables/Commands are there?
Question 7. Connecting to TWX Proxy from external?
Question 8. To SINGLEKEY or not to SINGLEKEY? GetConsoleInput command explained.
Question 9. Where can the GOTO take you?
Question 10. IF, ELSEIF, ELSE, and the dreaded UNKNOWN
ERROR.
Question 11. Tips to debug with...
Question 12. ANSI_ ahoy!
Question 13. Hows does the TWX directory get used in
READ/WRITE/LOAD commands?
Question 14. How big can she go, before she blows? Variable size.
Question 15. To see or not to see, what triggers there
be?
Question 16. Why ISNUMBER will not work right?
Question 17. Running double TWX trouble?
Question 18. Spacing, Spacing... It's all about writing scripts.
Question 19. How do you use triggers? And stay safe?
Along with CURRENTLINE?
Question 20. TWX Database gone phooey?
Question 21. Counting backwards to 0, for looping in
scripts.
Question 22. Running Double TWX trouble #2?
Questions/Answers start here
Question 1.
Gathering Information
|
Alloy - 10/27/01
11:30:35 PM (CST)
|
|
Xide,
I'm trying to figure out a way to run a script which will figure out how much
experience my character has and then displays it back to me. If this seems
like a rather useless script, thats because it is and I'm just tyring to
figure out how to get information out of something several lines up.
Your help is much appreciated.
Alloy
|
Answer 1.
|
Xide - 10/29/01
5:11:40 AM (CST)
|
|
The easiest way of doing this is by getting the script to send an 'i', then
setting the right textLineTrigger to get the info off the right line. There
should be several scripts in pack1 that do this - you could take an example
from scripts which get the current sector the player is in:
send "d"
setTextLineTrigger getSector :getSector "Sector : "
pause
:getSector
getWord CURRENTLINE $sector 3
echo "current sector is " $sector
For theory on the text and textLine triggers, I recommend you look them up in
the help file :)
|
|
blackice - 11/1/01
12:18:28 PM (CST)
|
|
*****************************************************
send "i"
setTextLineTrigger getexp :getexp "Rank and Exp : "
pause
:getSector
getWord CURRENTLINE $currentexp 5
echo "Your Level of Experience Is:" $currentexp
****************************************************
Well Alloy, one reason I see it isnt returning it, is because your trigger is
messed up.
Your creatin a trigger to go to a line named :getexp, but then u name the
actual line u want, :getSector. They need to match. So just change that line
to :getexp and it should work fine. It also might just display the exp at end
of line, if u want it on a seperate line, just add a carraige return
"*", echo "*Your...."
|
Question 2.
Multiple Connections to one TWX Proxy?
|
Alloy - 10/28/01
1:27:54 AM (CST)
|
|
Hello,
I've loaded TWXPROXY on a different machine than the one I use. I've given it
a high port number for access and when I connect to it I'm locked in a view
only mode. Is there a way that I can make TWX alloy me to control it
remotely.
Alloy
|
Answer 2.
|
Xide - 10/29/01
5:13:56 AM (CST)
|
|
The view only lock is designed to prevent people from duping using
eachothers IP addresses (in particular during tournaments). The program will not
lock you in view only mode if you are connecting using a network address
(192.168.*.*, 10.*.*.*, 127.0.0.1).
|
Question 3.
What can be done to speed up script
execution?
|
nzthordm -
11/12/01 11:04:47 PM (CST)
|
|
Here is a question... Does have remarks, i.e. lines starting with #, slow
down the execution of scripts? Namely inside large loops where you might want
to comment on what the loop is doing...???
|
Answer 3.
|
Xide - 11/12/01
11:06:42 PM (CST)
|
|
Marginally yes. It won't make any big difference, but because the script
is interpreted (not compiled), every extra character the interpreter has to
loop through will slow it down.
|
Question 4.
Reading/Writing files, and Loading
Files?
|
nzthordm - 11/14/01
12:38:25 AM (CST)
|
|
Could someone please explain how this is done? also how to run a second
script from running only the first?
|
Answer 4.
|
Tweety - 11/14/01
1:33:29 AM (CST)
|
|
May i ask what exactly you are trying to do? Writing to a file is VERY
easy. It involves the WRITE command.
Syntax:
WRITE <path> <var>
each time you run this command, it will automatically place the text on the
next line.
So,
WRITE c:\myflie.txt "Line 1"
WRITE c:\myflie.txt "Line 2"
WRITE c:\myflie.txt "Line 3"
would produce a file that contains this:
1
2
3
So if you are trying to put a bunch of variables on one line, you may want to
merge them into one string, or use the concatination or however you spell it
character "&".
Here is a quick example that should store fed communication into a file hehe.
Don't be mad if it doesn't work, or had bugs hehe. I'm writing this from my
head. What i will do is set a trigger to watch for F, R and P, and then place
that data into a file.
:resetTriggers
killAllTriggers
setTextLineTrigger fed :recordMsg "F "
setTextLineTrigger priv :recordMsg "P "
setTextLineTrigger sub :recordMsg "R "
PAUSE
:recordMsg
setVar $targetline CURRENTLINE
WRITE c:\fedchatter.txt $targetline
GOTO :resetTriggers
remember, this script might have flaws hehe. i never tested it. but it does
show how to use the command.
|
|
blackice -
11/14/01 6:26:14 PM (CST)
|
|
Hey, Tweety, read it slower ;)
The load command will load another script and run it in parallel with
the current one.
Usage:
load scriptFile> [parameters...]
scriptFile> is a variable or hard coded value containing the name of
the script which is to be loaded.
[parameters...] is a variable or hard coded value containing the parameter
list to be passed to the script being loaded. The target script can read
these parameters which are stored in the $parm[x] indexed variable.
|
Question 5.
Where can one find the scripts to load?
|
helps - 11/13/01
4:47:29 PM (CST)
|
|
hi! i've just started twx and i don't know
how to get the scripts? i down loaded twx and got teraterm. can any one help
me. i don't how to get the scripts out of teraterm. and i also don't know how
to use the scripts.
thanks
helps.........
|
|
helps - 11/13/01
5:37:58 PM (CST)
|
|
xide if this is a good trade wars program i will register it once i learn
how to use the scripts on teraterm ok thanks.........
i still don't know how to get the scripts from tera term or how to use them
in tera term... if u could help me out with that?please thanks......
helps
|
Answer 5.
|
nzthordm -
11/14/01 12:41:28 AM (CST)
|
|
For starters, the scripts in tera term and in twxproxy are two totaly
different things...
to access twxproxy scripts, right-click on the twxproxy icon bottom of
screen, and select load script.
what ever scripts you have for tera term, is you business... those script,
unless design for tradewars, dont belong on this forum...
|
|
Tweety - 11/14/01
1:23:29 AM (CST)
|
|
Let me first start off and ask you to read the First Tutorial posted on this
website in the Tutorials section. There will explain about TWX Proxy, and
what it is intended to do. Will even tell you how to get started.
Once you complete what is mentioned there, running scripts is a breeze. Like
mentioned before, you just right click the TWX icon in the bottom right tray
and select Load Script. Or if you feel more comfortable, and know which
script your loading by name, you can use the command menu by pressing $. if
you press ? you can get a list of commands that you can use. The next few
tutorials talk about this too. So please read the tutorials.
If you still have questions, post them here and we will help you out ASAP.
|
|
helps - 11/14/01
5:37:58 AM (CST)
|
|
i still can't find where the i con is to work the scripts what does the
icon look like ? it's definatly not at the bottom of teraterm
|
|
blackice -
11/14/01 6:28:48 PM (CST)
|
|
Sorry Helps, I must agree with Tweety, go read the tutorial. It walks you
step by step on installing and running TWX Proxy. And the Icon Nz was talkin
about is in your taskbar down by the clock of windows, ONCE you run the TWX
program. You use TeraTerm to connect to TWX
|
|
Tweety - 11/14/01
6:48:53 PM (CST)
|
|
This is how TWX Proxy works. TWX sits between the game server and the
terminal program(tera term, whatever) and relays the data and stores some.
example:
TWGS GAME SERVER <-->TWX Proxy<--> TERA TERM PRO
So you use tera term to connect to say localhost:23, this is assuming that
TWX proxy is watching for connections on port 23 of your local machine. Then
you will see a Beautiful menu saying that you connected to TWX Proxy and some
other stuff. Now locate that TWX icon beside you clock on the bottom right of
your screen. it says TWX in a little black circle. If you still can't see it,
it will sit with your ICQ icon if you see that heh. right click it and select
connect. of course you need to have a game setup already
|
|
Xide - 11/14/01
7:00:41 PM (CST)
|
|
They said it better than I could - have a good read of the readme.txt file
or the first tutorial on this site.
|
Question 6.
What hidden Variables/Commands are
there?
|
blackice -
11/16/01 1:56:55 PM (CST)
|
|
Anyone found a way to pull what the name of database TWX is currently
using? Maybe hiddne variable? (doubt it though). I even tried a EventTrigger,
which you would have to run the script, then reload the database for the
trigger to activate, but couldn't get any of them to work for this.
BTW, what's the Program Loaded event used for? Its not for scripts and it
doesn't activate when you load/unload a database, and it also wont trigger
when you start TWX (if setup in the event dialog inside TWX)
|
Answer 6.
|
Xide - 11/16/01
2:11:41 PM (CST)
|
|
There is a constant called 'GAMENAME' that returns the name of the
selected database. Sorry another undocumented :(
|
|
Xide - 11/16/01
2:14:51 PM (CST)
|
|
Hmm.. its SUPPOSED to activate when TWX is started. Thanks for reporting
the bug, on the list it goes...
|
|
blackice -
11/16/01 3:34:25 PM (CST)
|
|
Sweet works, thnx Xide.
|
|
Tweety - 11/16/01
5:14:54 PM (CST)
|
|
Shrug hehe, I use version 1.08b the newer version of it hehe. and i Use
the Program Loaded event inside twx to load my online script heh. it works
great
|
|
Tweety - 11/16/01
5:22:47 PM (CST)
|
|
Here are the built-in variables I KNOW exist in TWX:
CURRENTLINE
LOGINNAME
PASSWORD
GAME
CONNECTED
SECTORS
LICENSENAME
Below are the color variables usually used with the ECHO command:
ANSI_1
ANSI_2
ANSI_3
ANSI_4
ANSI_5
ANSI_6
ANSI_7
ANSI_8
ANSI_9
ANSI_10
ANSI_11
ANSI_12
ANSI_13
ANSI_14
ANSI_15
and here are the commands that I know exist:
(i may have missed some)
Add var value>
ClearProgVar name
ClientMessage value>
Connect
CutText line> storageVar cutFrom> cutLength>
Delete file>
Disconnect
Divide var value>
Echo values ...>
EchoChar char>
Else
ElseIf (value1> operator value2>)
End
GetConsoleInput inputVar [singleKey?]
GetCourse (not sure what the parameters are)
GetDate var
GetDistance var from> to>
GetInput inputVar prompt>
GetLength text> var
GetRnd storageVar lowestValue> highestValue>
GetSector sectorIndex> storageVar
GetText line> var startStr> endStr>
GetTime var
GetWord line> storageVar wordNum>
GetWordPos text> storageVar subString>
Gosub :label>
Goto :label>
If (value1> operator value2>)
IsNumber storageVar conditionVar
KillAllTriggers
KillTrigger triggerName>
KillWindow name
ListTriggers
Load scriptFile> [parameters ...>]
Logging setting>
MergeText value1> value2> mergedVar
Multiply var value>
OutputVars
Read file> storageVar line>
ReplaceText var oldText> newText>
Return
Send values ...>
SetDelayTrigger name> :label> delay>
SetEventTrigger name> :label> value> [param>]
SetProgVar name value>
SetTextLineTrigger name> :label> value>
SetTextTrigger name> :label> value>
SetVar var value>
SetWindowContents name contents>
Sound file>
Stop scriptName>
StripText var text>
Subtract var value>
SystemScript
WaitFor value>
Window name sizeX> sizeY> title> [ontop?]
Write file> text>
|
|
blackice -
11/16/01 8:54:58 PM (CST)
|
|
U my hero Tweety. Couple questions though ;)
GetCourse - Whats it do and only avail in 1.08?
GetDistance - Only avail in 1.08?
Gosub - Go to a line already inside a routine?
SetProgVar - shrug> Global variable for all scripts? 1.08?
Sound - No matter what I try, wont work. Fixed or somethin I'm missing? I've
done .wav in same dir and tried puttin path to it, never plays.
SystemScript - Whats it used for and 1.08 only?
|
|
blackice -
11/16/01 8:56:59 PM (CST)
|
|
Ohh ya, and what does RETURN actually return?
|
|
Tweety - 11/16/01
11:42:32 PM (CST)
|
|
GetCourse - Whats it do and only avail in 1.08?
GetDistance - Only avail in 1.08?
Gosub - Go to a line already inside a routine?
SetProgVar - shrug> Global variable for all scripts? 1.08?
Sound - No matter what I try, wont work. Fixed or somethin I'm missing? I've
done .wav in same dir and tried puttin path to it, never plays.
SystemScript - Whats it used for and 1.08 only?
Ok, getCourse and getDistance are only available in version 1.08+
goSub and RETURN work together. goSub will go to a specified label, then it
will execute that code. when the RETURN command is found, it will return to
just after executing the goSub command.
example 1:
goSub :validate
clientMessage "Validation was a success!"
:validate
clientMessage "Validating... please wait..."
RETURN
the above example is simple heh, but you should understand how it can be
used. heh if you were to run it, it would say Validating... then it would end
with validation was a success.
setProgVar, i think your right about it being where you can set a global
variable for all running scripts. I have never actually used this command
yet. but i think thats it.
SystemScript, this command can be used to load a script and keep it loaded
until you manually cancel it from the TWX icon. It will NOT be unloaded if
you do the quick stop All scripts from the TWX menu "$sx". i like
to put SystemScript in my online script at the top heh, that way it stays
online. even if i shut off all scripts
SOUND, this command as you may well know plays a sound heh. here is an
example of a script i use hehe, it wakes me up when i need it to:
example 2:
:resetTriggers
killAllTriggers
setTextLineTrigger fig :Alert "Report Sector"
setTextLineTrigger limp :Alert "Limpet mine in"
setTextLineTrigger mine :Alert "Your mines in"
PAUSE
:Alert
killAllTriggers
getWord CURRENTLINE $char 1
if ($char = "F") OR ($char = "P") OR ($char =
"R") OR ($char = ">")
GOTO :resetTriggers
end
SOUND ChatBeep.wav
setDelayTrigger 0 :Alert 1000
PAUSE
place the WAV, "ChatBeep.wav", in the directory of the TWXProxy.exe
file, or i beleive you can specify the full path like
SOUND c:\myfiles\ChatBeep.wav
|
|
blackice -
11/17/01 8:05:52 PM (CST)
|
|
Thnx Tweety for the explanations. BTW, for some
reason when I tried the SOUND again, it works. lol. Duno what I was doin
wrong month ago.
|
Question 7.
Connecting to TWX Proxy from external?
|
Morden Khai -
11/19/01 10:43:30 PM (CST)
|
|
I haven't used TWX in a while, and went to use it again today. I went into
setup and made a new game, since I was gonna go try my luck in a game I
hadn't been in yet. Whenever I tried to connect to TWX through SWATH, then
ZOC, I got a connected message and a disconnected message immediately after.
I told TWX to accept external connections, cause I haven't messed with it
before and thought maybe I was supposed to have that checked, and it lets me
in. However it only lets me look, I cant even type in to log in hehe Can
anyone tell me what I messed up? I am clueless hehe
Thanks in advance,
Morden Khai
|
Answer 7.
|
Tweety - 11/20/01
12:50:07 AM (CST)
|
|
The Accept External connections check box is used to allow other computers/users
to connect to your TWX proxy server and view what you see.
If someone has your IP address and the Port number, they could telnet there
and watch waht your doing. I'd recommend unchecking that box unless you
really want other people to see.
as for connecting/disconnecting. Are you connecting your SWATH to 127.0.0.1
(localhost)on the port that TWX Proxy is listening on?
if TWX proxy is listening on port 23, you would use your terminal program
(SWATH, ATTAC) to connect to:
localhost:23
or
127.0.0.1:23
|
Question 8.
To SINGLEKEY or not to SINGLEKEY? GetConsoleInput command explained.
|
The WABBIT -
11/27/01 8:28:57 PM (CST)
|
|
1 last question for today. It is about the
following command:
GetConsoleInput inputVar [singleKey?]
Can this be used to for single key entry?
If so how?
When I use it the it waits until the return key
is pressed before excepting the input.
|
Answer 8.
|
Tweety - 11/28/01
12:46:10 AM (CST)
|
|
Yup. This command was designed to allow for a single key stroke. here is
an example:
ECHO "Do you like dogs? (y/n) "
getConsoleInput $answer SINGLEKEY
if ($answer = "Y")
clientMessage "Cool!"
else
clientMessage "You don't know what your missing"
end
the parameter i put as SINGLEKEY can be anything. the command jsut requires
something there to tell it that it is a single key entry. If you do NOT put
something in place of SINGLEKEY it will wait for the ENTER key.
|
|
blackice -
11/28/01 9:41:50 AM (CST)
|
|
Tweety is correct. I too just put SINGLEKEY just outta habit because it
tells me it just needs a SINGLEKEY entered.
If you use Tweety's example and only want Y or N to be choices, do this:
:Menu
ECHO "Do you like dogs? (y/n) "
getConsoleInput $answer SINGLEKEY
if ($answer = "Y") OR ($answer = "y")
clientMessage "Cool!"
elseif ($answer = "N" OR ($answer = "n")
clientMessage "You don't know what your missing"
else
clientMessage "Not a valid choice"
goto :Menu
end
|
|
Tweety - 11/28/01 3:22:48
PM (CST)
|
|
If i'm not mistaken, the getConsoleInput command returns a Capitalized
letter, so there shouldn't be any need to check if it is a upper or lowercase
letter.
|
|
The WABBIT -
11/28/01 5:37:35 PM (CST)
|
|
thanks tweety :-)
I will give it a test run and see if it only returns
the upper case letter or not. But putting the command
as is displayed in the cmd.txt file.
GetConsoleInput inputVar [singleKey?]
makes it look like a question on wether or not it can
do single key input. At least to me it does.
|
Question 9.
Where can the GOTO take you?
|
avonavilla -
11/29/01 9:31:23 PM (CST)
|
|
So I have a new issue in my script. Basically I have some code that looks
like this:
:loop
if ($foo > 0)
#do stuff
subtract $foo 1
goto :loop
end
When I ran this I got an error saying script error goto marker not found
:loop.
If I moved the goto :loop outside of the if block, I get an unknown error.
Any thoughts?
|
Answer 9.
|
avonavilla -
11/29/01 9:44:32 PM (CST)
|
|
I fixed the problem, but the issue might be a bug. My script was actually
more like this:
setvar $foo 1
if ($foo = 1)
:loop
if ($foo2 > 0)
#do stuff
subtract $foo2 1
goto :loop
end
end
That code failed with the goto label unknown, however if you remove the outer
if block it works.
|
|
Xide - 11/29/01
9:57:11 PM (CST)
|
|
This could be the famous tabulation bug.
The script interpreter seems to have problems with tab characters place by some
text editors. Try removing your tabulation or replacing it with spaces.
|
|
blackice -
11/30/01 11:22:11 AM (CST)
|
|
Tabs work fine in my TextPad (awesome text editor for anything). I'd actually
rewrite your script to look like this. That way it only does the stuff while
$foo is > 0. If its not, it exits the loop and goes on to other stuff if u
have it.
setvar $foo 1
:loop
if ($foo2 > 0)
&NBSP &NBSP #do stuff
&NBSP &NBSP subtract $foo2 1
&NBSP &NBSP goto :loop
end
|
|
blackice -
11/30/01 11:24:18 AM (CST)
|
|
Ok, who's the wise guy who turned off my pretty HTML code? :( = 1
space
|
|
blackice -
11/30/01 11:25:42 AM (CST)
|
|
lol, nm. I figured it out. Your forum database is parsing uppercase
'&NBSP' as text. For real HTML space ya gotta use lower case . Just
a FYI
|
Question 10.
IF, ELSEIF, ELSE, and the dreaded
UNKNOWN ERROR.
|
avonavilla -
11/29/01 1:41:26 AM (CST)
|
|
I'm trying to write a script that does the
following:
1) Checks if there is a port in the current sector
2) if there is, looks for a paired port in an adjacent sector
3) if there is, moves to that sector
4) verifies the ports can be pair traded by checking that it didn't just
cross a one way warp.
5) if it found a valid pair port, it trades between them.
I've written some of the script, and it's rather ugly to be honest, but when
I try to run it I get an unknown error. The error occurs after the clientMessage
"1" call, but before the next clientMessage. There is nothing wrong
with the statement that gives the error, and if it is removed the error just
occurs on the next line. If any one has suggestions I'd love to hear them.
========= Start Script =========
# First get the sector we are in
clientMessage "Getting current sector"
setTextLineTrigger 1 :getSectorNumber "Sector : "
send "d"
pause
:getSectorNumber
clientMessage "In label"
getWord CURRENTLINE $sectorIndx 3
clientMessage $sectorIndx
setvar $sector $sectorIndx
# Next see if we have pair ports.
getSector $sector $curSector
clientMessage "Checking if port exists"
if ($curSector.port.exists = 1)
clientMessage "Port exists. Setting pair matrix"
clientMessage $curSector.port.name
clientMessage $curSector.port.class
# Set up our possible pair ports
setvar $pairOne = 11
setvar $pairTwo = 11
setvar $pairThree = 11
if ($curSector.port.class = 1)
setvar $pairOne 2
setvar $pairTwo 3
setvar $pairThree 4
end
if ($curSector.port.class = 2)
setvar $pairOne 1
setvar $pairTwo 3
setvar $pairThree 5
end
clientMessage "1"
if ($curSector.port.class = 3)
setvar $pairOne 1
setvar $pairTwo 2
setvar $pairThree 6
end
clientMessage "2"
if ($curSector.port.class = 4)
setvar $pairOne 1
setvar $pairTwo 5
setvar $pairThree 6
end
if ($curSector.port.class = 5)
setvar $pairOne 2
setvar $pairTwo 4
setvar $pairThree 6
end
if ($curSector.port.class = 6)
setvar $pairOne 3
setvar $pairTwo 4
setvar $pairThree 5
end
clientMessage "Done setting matrix"
# Loop over all my warps to see if they have compatible ports
clientMessage "Looking for pairs"
setvar $warps $sector.warps
:loop
if ($warps > 0)
getSector $sector.warp[$warps] $pairSector
clientMessage "Checking " $sector.warp[$warps]
if ($pairSector.port.exists)
clientMessage "Port exists. Checking if compatible"
if ($pairSector.density = 100)
if ($pairSector.port.class = $pairOne)
goto :check_one_way
end
if ($pairSector.port.class = $pairTwo)
goto :check_one_way
end
if ($pairSector.port.class = $pairThree)
goto :check_one_way
end
end
clientMessage "Not compatible"
end
subtract $warps 1
goto :loop
end
goto :no_trade
:check_one_way
# Check for a one way by moving then looking for a return
clientMessage "Checking for one way warp"
setvar $pairIndx $sector.warp[$warps]
send $pairIndx "*"
waitfor "Sector : "
setvar $warps $sector.warps
:loop_2
if ($warps > 0)
if ($pairSector.warp[$warps] = $sectorIndx)
goto :trade
end
subtract $warps 1
goto :loop_2
end
:trade
clientMessage "Trading with " $sectorIndx $pairIndx
:no_trade
clientMessage "Not Trading"
end
======= End Script =======
Also are there any plans to add functions calls to this language? Or the
ability to import other scripts? Any chance the perl interpreter could get
embedded into TWX? Thanks.
|
Answer 10.
|
Tweety - 11/29/01 2:56:49
AM (CST)
|
|
First off let me tell you to be careful when you use the setVar command. I
noticed that you put something like setvar $pairOne = 11 in your code in
3 places. This would set the variable $pairOne to =. NOT 11
If i'm not mistaken, and i could be here. But i think the variable from the
getSector command called $pairSector.port.exists will contain TRUE or
FALSE. and in TWX i think you actually have to do something like this:
if ($pairSector.port.exists = TRUE)
....
end
Its annoying i know heh.
Xide has thought about adding more scripting language support, but i don't
think that is in his immediate plans at the moment. If you wait Xide will
probably reply too :P
|
|
avonavilla -
11/29/01 1:00:09 PM (CST)
|
|
The GetSector.port.exists call seems to work OK, if I compare it to 1. It
didn't work using it by itself in the if statement.
I use setvar pairOne 11, so I have a known value to compare those guys to.
That way if I hit a class or 9 port, I don't bother trying to trade with it.
It's weird though, it's kinda like the script dies from too many if's, or too
many setvar's since it runs further if I remove all the if (port.class = ?)
setvar blocks.
|
|
Xide - 11/29/01
3:57:04 PM (CST)
|
|
I hate unknown errors - they can be difficult to track. Best way of
finding out exactly what is causing them is to just place checkpoints in your
code to see how far it gets. The most common mistakes behind unknown errors
are:
1. Database corruption (trying to run a getSector command on a sector that is
corrupted in your database)
2. Syntax errors
3. Mismatched conditions (i.e. your IFs and ENDs not matching up)
|
|
blackice -
11/29/01 6:05:21 PM (CST)
|
|
I've never had a prob with TWX dyin or gettin confused from too many IF
statements, but a couple words of advice for scripting to make finding
problems easier.
1. when doin IF statements, always indent/tab the lines after the IF
line. Example
IF ($curSector.port.class = 1)
setvar $pairOne 2
setvar $pairTwo 3
setvar $pairThree 4
end
2. Simplify and reduce the # of IF's u use. Combine multiple IF's into
one. Example
BEFORE
if ($curSector.port.class = 1)
setvar $pairOne 2
setvar $pairTwo 3
setvar $pairThree 4
end
if ($curSector.port.class = 2)
setvar $pairOne 1
setvar $pairTwo 3
setvar $pairThree 5
end
clientMessage "1"
if ($curSector.port.class = 3)
setvar $pairOne 1
setvar $pairTwo 2
setvar $pairThree 6
end
AFTER
IF ($curSector.port.class = 1)
setvar $pairOne 2
setvar $pairTwo 3
setvar $pairThree 4
ELSEIF ($curSector.port.class = 2)
setvar $pairOne 1
setvar $pairTwo 3
setvar $pairThree 5
clientMessage "1"
ELSEIF ($curSector.port.class = 3)
setvar $pairOne 1
setvar $pairTwo 2
setvar $pairThree 6
END
3. I'm assuming all those ClientMessages is to let you know what the
script is doing. Another helpful way to see how far its getting, is to put
PAUSE statements after those Messages and echo any variables u wanna make
sure are gettin set right. Just rem to delete the PAUSE when u want it to go
further ;)
4. Like Tweety pointed out, You are using the syntax for setVar
incorrectly
setvar $pairOne = 11
setvar $pairTwo = 11
setvar $pairThree = 11
Should be...
setvar $pairOne 11
setvar $pairTwo 11
setvar $pairThree 11
Hope some of these tips help ya
|
|
blackice -
11/29/01 6:07:09 PM (CST)
|
|
Sorry, Forum removes all spacing and identing.
test
|
|
avonavilla -
11/29/01 7:27:54 PM (CST)
|
|
Thanks, cleaning up the setvar was the problem. It probably corrupted
something internal, which caused the script to die later on. I also switched
to if/elseif blocks, which I would have done from the start, but I wasn't
sure if it was supported. Does anyone know if the language supports loops, or
case/switch statements? Thanks.
|
|
blackice -
11/30/01 11:16:13 AM (CST)
|
|
Does support loops. And normal IF..ElseIF statements. Not sure what u mean
by the Case/Switch, but lemme take a stab.
You can do stuff like
IF ($name = "bob") OR ($name = "steve")
&NBSP &NBSP &NBSP echo "Sup dudes"
Elseif ($name = "Marry") AND ($name2 = "Wendy")
&NBSP &NBSP &NBSP echo "Hello my 2 ladies"
End
Those only 2 Operands I've ever used and know about for TWX.
If ya talkin case of letters, everything is Case sensitive for the most part.
|
|
Tweety - 11/30/01
1:29:50 PM (CST)
|
|
Currently it does NOT support for loops, while loops. Does NOT have a case
statement.
You have to use probably if statements with maybe elseif
loops for now have to be done with GOTO sigh...
I keep asking Xide to bring in loops, functions etc... hehe. I know he wants
loops as well.
|
|
The WABBIT -
12/1/01 9:01:03 PM (CST)
|
|
blackice,
I have never been able to get a If ... ElseIf statement to work past the
first and only else if.
I have tried all combo's of If ... ElseIf. Example:
If ($x > 5)
...
elseIf ($x < 3)
...
elseIf ($z = 100)
...
end
The above never works for me. I always get and error.
But, if I remove the last elseIf and make it a seperate If statement
I have no problems
Xide,
I have always had problems with TWX not finding labels if they are indented.
I have used the following
to write my scripts:
Word Perfect v9.0
MS Word
Wordpad
NotePad
DOS's Edit
and EditPad Lite
With all of these I have not been
able to get a label that is indented to work.
|
|
avonavilla -
12/1/01 11:22:22 PM (CST)
|
|
I'm using XEmacs on NT, and I find that if a line begins with a tab, the
parser ignores that line. If you replace your tabs with spaces, it might
work.
|
|
Tweety - 12/2/01
2:39:58 AM (CST)
|
|
I use Windows Notepad. i have no problems, but i never use the tab key
cause it makes too large of a space for my liking :P
i always use spaces to indent
|
|
blackice - 12/3/01
11:34:28 AM (CST)
|
|
Avon, for your IF ELSEIF statements, trying adding a ELSE after last
ELSEIF. I dont remember if mine does work w/o it, but you could try. ICQ me
if ya still have a prob 48105781
IF ($x > 5)
...
ELSEIF ($x < 3)
...
ELSEIF ($z = 100)
...
ELSE
do something or leave blank
END
I too have had probs with indented label lines. Of course I used tabs but its
never had a prob before. Maybe I'll try just spaces
|
Question 11.
Tips to debug with…
|
Smart Idiot -
12/6/01 5:26:13 PM (CST)
|
|
I have been having fun learning about the scripting langauge (Thanks Xide
for a great product) and was having to run my script to test it. Many times I
wanted to see what a value was at a particular spot. So I made this
pause routine and thought I'd share it. Hope it helps anyone wanted to write
scripts.
echo "Hey, you are stopped here for some reason*"
echo "Press space to continue.*"
:getspace
getConsoleInput $test SINGLEKEY
if ($test <> " ")
goto :getspace
end
|
Answer 11.
|
blackice - 12/6/01
6:52:06 PM (CST)
|
|
Glad we got more people learning to script. Since I've been doin this for
awhile, lemme share some easier techniques.
1.
blah blah..code doing stuff...blah blah
echo "**" $whatevervariable
pause
(Easiest to chk value of variables, but ya gotta Manually stop the script, it
wont continue. You also could use instead of the echo, ClientMessage
$variable)
2.
blah blah..code doing stuff...blah blah
echo "**Made It"
pause
3.
If ya wanna be really cool ;) create a window and display the variable or
"Made it" text in that, but always follow it with a PAUSE so it
stops.
4. If ya workin with crap loads of variables, and dont wanna echo all those
variables, just do a OutputVars on its own line. Spits out all variables and
what they equal.
*Note, instead of pauses and manually stopping, you could just use a HALT so
it terminates the script.
GL man, and always post if ya got a question. There's always ppl here to
answer em and help ya.
|
Question 12.
ANSI_ ahoy!
|
blackice - 12/7/01
5:18:45 PM (CST)
|
|
Would it be possible to enhance TWX's ability to read the ANSI_## code
from a variable. Couple cases I've found to be cool to do, would be add a
random color feature. So I could do soemthing like this:
getRnd $rndcolor 1 14
echo ANSI_$rndcolor "text here"
OR
mergeText "ANSI_" $rndcolor $CompletedAnsi
echo $CompleteAnsi "text here"
Maybe a work around someone knows of?
|
Answer 12.
|
Tweety - 12/7/01
6:13:01 PM (CST)
|
|
You can embed ANSI color codes in the test you send by means of ECHO or
clientMessage. however you have to send the escape sequence first then the
code.
eg 1) Red text, then i turn off the ANSI codes at the end of the text.
ECHO
"*[31mThis is Red[0m"
eg 2) Red Text ALL blinking, and then ANSI codes off at the end.
ECHO
"*[5;31mThis is Red Blinking[0m"
eg 3) Red text with a blue background. Only the word RED is blinking. i also
turned the ANSI codes off at the end.
ECHO
"*[0;31;44mThis is [5mRed[0;31;44m with a Blue Background and Red is
blinking[0m"
You could also use the getRnd command to produce a random value in the ANSI
color range 30-37 for foreground colors, 40-47 for background colors. Then
you just put them in with the MergeText command or the concatination
character &
this example below gives a random forground color:
getRnd $num 30 37
ECHO "*["&$num&"mThis is a random color"
|
|
blackice - 12/8/01
3:35:17 AM (CST)
|
|
Hrmm, I'll have to try that. Thnx Tweety
|
|
blackice - 12/8/01
7:18:40 PM (CST)
|
|
One more quick question, for makin the escape character, u doin it in like
DOS then copyin it, or your text editor let u do it in there? And what key
combo is it for it.
|
|
Xide - 12/9/01
12:14:47 AM (CST)
|
|
You can specify the escape character in the script using #27
The # operator lets you get character codes and write them into the script...
i.e:
echo #27 "[31m"
|
|
Tweety - 12/9/01
1:46:53 AM (CST)
|
|
cool, i didn't know that heh
|
Question 13.
Hows does the TWX directory get used in
READ/WRITE/LOAD commands?
|
nzthordm -
11/14/01 6:28:20 PM (CST)
|
|
Is there a varible or command that can get the current script
folder/path??? so that instead of supplying the full path to run a script from
inside another script, we just grab the scripts path, and then add script
want to run??? and if not in version 1.07, is there plans to add it to 1.08?
|
Answer 13.
|
blackice -
11/14/01 6:32:42 PM (CST)
|
|
None that I have heard of. Most programs that support scripting have
built-in variables and one of them is typically a $path type variable that
displays the current path. Far as I can tell, Xide never added anything like
that, but maybe he knows more then he is telling ;) I've also had no luck
finding anyway to speghetti code it to work either, so until Xide spills his
guts, or adds in next version, dont count on it.
|
|
Tweety - 11/14/01
6:37:22 PM (CST)
|
|
As far as i know, there is NO variable to use to get the Path to the
script directory.
You could say NO directory and just the filename i think hehe. it will
probably default to the TWX directory where the twxproxy.exe file is.
|
|
blackice - 11/14/01
6:56:18 PM (CST)
|
|
Well, yes and no Tweety. It will default to the main TWX directory, but
thats only spot you can load a file from, or write to. Doesnt that kinda
sound pointless to have a scripts folder if you cant actually send or get
external data from it? ;) It may be a by-product of having a $path type
variable, but those programs let you read and save to DIFFERENT folders other
then the root the program resides in.
This all would be easier if he could get it to access other directories, but
may not due to some limitation in code. If that's the case, it might be
better to change the default directory, if possible, to the Scripts directory
|
|
Tweety - 11/14/01
6:59:25 PM (CST)
|
|
hehe true true
|
|
Xide - 11/14/01
7:05:53 PM (CST)
|
|
No variable or built in support for this (yet), I'll add it to my list for
1.08b. Although you should be able to specify relative to the script your
running, i.e:
load "myscripts\myscript.ts"
Not tested, but the below might work too:
load "..\myscripts\myscript.ts"
|
|
blackice -
11/15/01 1:46:44 PM (CST)
|
|
I got bored at work, but did alot more testing this time ;)
Example path of your installation
C:\Program Files\TWX\Scripts
write .\scripts\script.ts
puts file here
c:\Program Files\TWX\Scripts\script.ts
write ..\script.ts
puts file here
c:\Program Files\TWX\script.ts
write \\diablo\scripts - network'd PC name of diablo in directory name
'scripts'
puts file here
\\diablo\scripts\script.ts
write D:\My Stuff\TWX\Scripts.ts - Different HardDrive
puts file here
D:\My Stuff\TWX\Scripts.ts
I shoulda tried all this before, which I thought I did, but I apologize for
the mis-information earlier
|
|
blackice -
11/16/01 1:21:26 PM (CST)
|
|
Ohh ya, forgot to add, if you puttin it to a diff directory other then the
default TWX directory, the destination directory/path has to exist already.
TWX WILL NOT CREATE IT IF DOES NOT EXIST ALREADY
|
|
Xide - 11/17/01
4:33:37 AM (CST)
|
|
LOL I think you know more about how my program handles paths than I do
now... [writes it down]
|
|
nzthordm - 12/1/01
1:20:33 PM (CST)
|
|
I just tried to use the load command, and got unknown error... I tried it
multiple ways.
load C:\WINDOWS\Desktop\TWXProxy107b\scripts\captest.ts shipcap.txt
load ..\scripts\captest.ts shipcap.txt
load .\scripts\captest.ts shipcap.txt
well that unknown error was actually a file not found error... i had the
wrong script name, should have been captext.ts not captest.ts
Now i get...
Loading script: C:\WINDOWS\DESKTOP\TWXPROXY107B\SCRIPTS\CAPTEXT.TS
Script Error on line 8: Insufficient parameters
Command [TL=00:00:00]:[17039] (?=Help)? :
Script terminated: C:\WINDOWS\DESKTOP\TWXPROXY107B\SCRIPTS\CAPTEXT.TS
i take it from the help file that you dont need " around the value you
want to pass along, but i get that error from if ($parm[0] = "") as
in im cheacking that it wass called by another script and has the filename
passed to it...
Any ideas anyone? has anyone here actually used the load command and passed
along parameters? I also tried if ($parm[1] = "") and got the same
error.
|
|
Xide - 12/1/01
6:20:46 PM (CST)
|
|
I think the error may be in your syntax. Can you post the block of code
giving you the error?
|
|
nzthordm - 12/3/01
2:51:42 AM (CST)
|
|
if ($parm[0] = "")
echo "**Must be loaded by another script!**"
halt
else
setvar $name $parm[0]
end
also tried if ($parm[1] = "") but still gave an insufficent
parameters error
|
|
Tweety - 12/3/01
4:52:38 PM (CST)
|
|
I copied and pasted that exact code into a file and ran it. had no
problems other than it not saying "Must be loaded by another script!"
I have noticed that if there has been NO parameter given, parm[0] will
contain 0 not an empty string like ""
|
|
Tweety - 12/3/01
4:54:17 PM (CST)
|
|
The insufficient parameter error tends to make me believe you have a syntax
error maybe up higher.
|
|
nzthordm - 12/3/01
8:01:17 PM (CST)
|
|
It might actually be a 1.07 bug, as i believe u have 1.08 tweety... but
thanks for letting me know its $parm[0]=0 instead of ""
It it isn't a script error above that parm check, as that is the first
codeing, the rest above it is just comments...
|
|
nzthordm -
12/12/01 3:49:17 AM (CST)
|
|
I finaly wrote a script that loads another script ontop.
lol... anways, something i found interesting in 1.07b, is that using load
"script.ts" loads the script from the scripts folder, and not the
TWX root like i thought...
|
Question 14.
How big can she go, before she
blows? Variable size.
|
blackice - 12/5/01
7:59:14 PM (CST)
|
|
I was just messing around and found something very interesting.
First I found that I cant do ANY addition that the sum would be over
2,147,483,647. It starts returning negative #'s.
1,000,000,000 + 1,47,483,647 = 2,147,483,647
1,000,000,001 + 1,47,483,647 = -2,147,483,648
If you do any DIVIDE, MULTIPLY, or SUBTRACT of a # greater then 2,147,483,647
it will return a Bad Numeric Value error not matter what your other value is
or the result will be.
I think its a limitation on how much a variable can hold because only happens
when variables are in the equation
Anyone else ran into this?
|
Answer 14.
|
nzthordm - 12/5/01
11:17:38 PM (CST)
|
|
That number limit is caused by programming in general... in order to keep twx
proxy fast i believe he limited the numbers to 16 bit, also called long
intergers... that way it uses only 2 bytes for the memory, makeing it both
faster and uses less memory...
For larger number he would have to use whats called double long. However that
uses 4 bytes, at about a 3-4 times speed difference.
Now i believe that a double long can hold like 1x10^299 or something as big
as that, when it comes to speed, it can slow done quite a bit... it really
depends on why you want to use such large numbers...
|
|
blackice - 12/6/01
12:23:06 AM (CST)
|
|
True, but why the strange uneven number?
and BTW, I was using a variable to hold cash amount, and the math was
crashing because it was exceeding 2billion. If this is a limitation, can u guys
think of a work around when doin math with that large of numbers?
|
|
Lostone - 12/12/01
1:25:40 PM (CST)
|
|
On this note... check this script out real
quick...
getInput $figs "Enter the number of figs this ship can hold"
getInput $planet "Enter the planet number the cash is in"
getInput $secfigs "Enter the number of Fighters in the sector"
getInput $sec "enter the sec to deploy"
getInput $stock "enter the class 0 port sector"
######THIS IS THE VARIABLE I AM TALKING ABOUT
getInput $max "enter the max amount of money to take"
##### Try replacing it with a setVar $max 999999999 and I always had the
script crash on me... When I added this getInput to enter it manually it
worked fine.. I think this is also similar to your maxnumber problem... although
it is a number not even half as large as yours...
:run
send "i"
setTextLineTrigger 2 :cash "Credits :"
pause
:cash
getWord CURRENTLINE $cash 3
stripText $cash ","
if ($cash < 100000000)
goto :subcash
end
send $stock "*ne"
send "ptb" $figs "*q"
send $sec "*ne"
add $secfigs $figs
send "f" $secfigs "*cd"
waitfor "Done. "
goto :run
:subcash
setVar $needed $max
subtract $needed $cash
send "l" $planet "*ctf" $needed "*qtnt1*q*"
goto :run
|
|
blackice -
12/13/01 8:35:35 PM (CST)
|
|
Ya, thats what I'm talkin about. You can set variables and such with the
high #'s, but try and output it or manipulate it, its barfs on ya :/
|
Question 15.
To see or not to see, what triggers
there be?
|
Zentock - 12/13/01
2:19:33 PM (CST)
|
|
If while running multiple scripts or newly aquired scripts i wanted too
see what triggers r active.
what would the exact code look like that would be placed just b4 the exit ?
and how do i check for unneeded or unwanted triggers.
also what would kill all triggers look like?
thanks too anyone that can/does help.
|
Answer 15.
|
blackice -
12/13/01 8:45:27 PM (CST)
|
|
Currently, as far as I know, you can only View and Kill triggers within
the current script.
ViewTriggers
KillAllTriggers
You would have to place a ViewTriggers at end of every script.
Theres no command to run and chk for useless triggers. Ya just gotta walk
thru your script step by step and see whats not needed. You could actually
right click TWX icon, goto VIEW, then do Script Triggers and that will show u
all triggers loaded for that script chosen(drop down box on top to choose
which script).
kill all triggers is just, KillAllTriggers
|
Question 16.
Why ISNUMBER will not work right? And Answer
16.
|
blackice - 12/6/01
7:28:51 PM (CST)
|
|
just a FYI to fix for 1.08 if it isn't already. The isNumber function is
backwards. I'll show you.
Code:
setVar $i 23
isNumber $result $i
echo "*"
outputVars
setvar $i abc
isNumber $result $i
echo "*"
outputVars
Results:
$I: 23
$RESULT: FALSE
$I: ABC
$RESULT: TRUE
|
|
The WABBIT -
12/14/01 12:40:08 AM (CST)
|
|
Yes this is a bug. I had cought it about a month and a half ago. I had
told xide then. I even sent a test script for him to use.
He stated that it would be fix in 1.08b. We'll see, since he has alot on his
plate for bugs this time around.
|
Question 17.
Running double TWX trouble?
|
Thor - 12/16/01
7:05:06 PM (CST)
|
|
I want to run TWX more than once, so that i can work in more than one game
at a time. Is there any way to do this?
|
Answer 17.
|
blackice -
12/16/01 9:26:01 PM (CST)
|
|
Yep, just load up a 2nd copy, then u gotta go set its internal port to listen
on something other then default of 23. Then just have your 2nd Telnet app
connect to 127.0.0.1 on that new port #
|
Question 18.
Spacing, Spacing… It’s all about writing scripts.
|
Thor - 12/17/01
10:04:21 PM (CST)
|
|
I changed the lines of code as black ice
recommended, kept getting error messages that the IF line didn't have enough
information. So, I changed the code so that the IF THEN and setVar were all
on one line, with END after each IF THEN statement. Now, I don't get the
error messages about not having enough information, instead the script just
sits there and does nothing. Here is all the code, can anyone help? Thanks
for any help you can give. :)
Thor
getInput $ts "what is the trouble sector?"
IF ($ts=2299) THEN setVar $ns 779
END
IF ($ts=779) THEN setVar $ns 2299
END
IF ($ts=160) THEN setVar $ns 1628
END
IF ($ts=1628) THEN setVar $ns 160
END
IF ($ts=842) THEN setVar $ns 1389
END
IF ($ts=1389) THEN setVar $ns 842
END
IF ($ts=2008) THEN setVar $ns 260
END
IF ($ts=260) THEN setVar $ns 2008
END
# SEND "x"
# WAITFOR "o beam to (Q=Quit) "
# SEND "44"
# WAITFOR "S Indiana[0;35m : "
# SEND "zebra8"
# WAITFOR "o beam to (Q=Quit) "
# SEND "q"
# WAITFOR "m?=Help[0;35m)? : "
IF ($ns<600) THEN send $ns"*"
END
IF ($ns>599) THEN send $ns
END
WAITFOR "Warp [0;32mdrive? "
SEND "y"
WAITFOR ", shall we engage? "
SEND "y"
SEND "s"
WAITFOR "m?=Help[0;35m)? : "
SEND "h"
# WAITFOR "m?=Help[0;35m)? : "
# SEND "c"
# WAITFOR "33m?=Help[0;35m)? "
# SEND "p"
# WAITFOR "sh to launch one ? "
# send "y"
# WAITFOR "ector? (Q to quit) "
# IF ($ts<600) THEN send $ts "*"
# END
# IF ($ts>599) THEN send $ts
# END
# WAITFOR "33m?=Help[0;35m)? "
# SEND "q"
END
|
Answer 18.
|
blackice -
12/18/01 1:30:28 AM (CST)
|
|
Couple things I still see wrong. Theres no THEN statements. You also cant
bunch all the IF testing info together like yours ($ts=779), has to be spaced
($ts = 779). You also don't have to enter the escape characters in your
waitFor's, text is text no matter what color as far as TWX is concerned.
Below is the redone of yours. I think you also had an extra END statment at
very bottom that was messin ya up.
getInput $ts "what is the trouble sector?"
IF ($ts = 2299)
setVar $ns 779
ELSEIF ($ts = 779)
setVar $ns 2299
ELSEIF ($ts = 160)
setVar $ns 1628
ELSEIF ($ts = 1628)
setVar $ns 160
ELSEIF ($ts = 842)
setVar $ns 1389
ELSEIF ($ts = 1389)
setVar $ns 842
ELSEIF ($ts = 2008)
setVar $ns 260
ELSEIF ($ts = 260)
setVar $ns 2008
END
#Left out all your commented lines
IF ($ns < 600)
send $ns "*"
ELSEIF ($ns > 599)
send $ns
END
WAITFOR "Warp drive? "
SEND "y"
WAITFOR ", shall we engage? "
SEND "ys"
#For next WAITFOR, most ppl usually use WAITFOR "Command [TL="
#But Its just preference I think, plus it helps to understand which prompt u
really lookin at :P
WAITFOR "m?=Help)? : "
SEND "h"
|
|
Tweety - 12/18/01
4:12:17 AM (CST)
|
|
The TWX script engine works in lines. every command is on its own line. You
can NOT place multiple commands on one line.
For example:
setVar $name
"Tweety" setVar $age 21
Script Engine Result: FAILED
You will want to do them on individual lines like this:
setVar $name "Tweety"
setVar $age 21
Script Engine Result: SUCCESS!!
And again, you can NOT leave out the spaces like blackice mentioned above.
The TWX engine doesn't like that one bit.
Eg 1)
if($name="Tweety")
end
Script Engine Result: FAILED
Eg 2)
if ($name = "Tweety")
end
Script Engine Result: SUCCESS!!
|
Question 19.
How do you use triggers? And stay safe?
Along with CURRENTLINE?
|
Thor - 12/17/01
7:47:21 PM (CST)
|
|
I THINK (?) :) I have figured out how I would set up a script trigger. But
I want to know how to set up the program so that it gets information out of
the current line, the same one it uses to do a trigger, and use that as a
variable. The part of the current line I want to use is sector numbers when a
fighter reports someone has entered my sector. So that my script is totally
automatic pretty much. I would really appreciate any help any of you can give
me.
Thor
|
Answer 19.
|
Tweety - 12/17/01
9:07:18 PM (CST)
|
|
Sounds like a simple script. here is a simple script that will pull the
sector number out of a Report Sector message you may see when someone hits a
fighter. This example does NOT have any validation to make sure that this
wasn't a false message sent by fed com.
setTextLineTrigger fig :execute "Report Sector"
PAUSE
:execute
getText CURRENTLINE $sector "Sector " ":"
clientMessage $sector
HALT
The variable CURRENTLINE is a built in variable you use to grab the current
line when a trigger has executed. i use the getText command to pull the text
between Sector and : in the real Report sector message and place it in the
bariable called $sector. then i just print out on the screen the sector
number i pulled out.
|
|
Thor - 12/17/01
9:26:35 PM (CST)
|
|
Thanks Tweety, that helps a lot. How would i designate this information as
a variable? What I want to do is to warp to a sector where I have a fighter
next to the one where they just came into. So, I am doing up an if then list
of fighter pairs, and I want to get the sector number out of this alert so
that I can have the TWX script automatially take me to the nearby sector as
soon as someone wanders into this other sector. Appreciate the help on
getting out input.
Thor
|
|
blackice -
12/18/01 1:19:34 AM (CST)
|
|
setTextTrigger 1 :Fig "Deployed Fighters "
pause
:Fig
setVar $line CURRENTLINE
stripText $line ":"
getWord $line $sector 5
send "M" $sector
send "*"
Very simple usage of it. When someone hits ANY fig, it triggers off the
Deployed Fig line, then goes to the :Fig line. We then save that whole line
that contained our trigger word, and save it to variable $line. Then we strip
the colon off it because its in same word as the sector # we want.
(Ex. Deployed Fighters in Sector :253)
Then we just want the 5th word, which is our sector, and save that word as
variable $sector. So now we got the sector stored so all we gotta do is our
move command. Sends M to move, then enters variable which is actually sec
253, and the * means enter.
Of course this doesnt take into acct TWarp on, or stuff that gets in the way
of warping. And like Tweety pointed out, anyone could just type a msg on
fedcom or subspace channel and it would trigger if the words matched your
trigger. So you would need to validate that first. Just get the 1st word and
make sure its not a F, P, or a R. (Fedcom, private hail, subspace)
|
|
Tweety - 12/18/01
3:59:04 AM (CST)
|
|
Watch out with your approach there blackice, sometimes you get different
messages when people hit fighters, depending on the game settings i guess.
sometimes you see Deployed Fighters, sometimes you don't and get Report
Sector. but both of the phrases have report sector it in anyway.
if you want to find an adjacent fighter to where someone hit, your going to
have to either read in from a file a list of sector where you have fighters
located, or grab them from the game before the script waits for someone to
hit the fighter. I would suggest loading them into an array, and then
checking later. I'm not going to write the whole thing for you, but here is a
little bit of what i think you need to know.
here is an example:
SEND "g"
WaitFor "===="
:resetFtrTriggers
killAllTriggers
setTextLineTrigger corp :recordFtr "Corp"
setTextLineTrigger pers :recordFtr "Personal"
setTextLineTrigger done :startScript "Total"
PAUSE
:recordFtr
getWord CURRENTLINE $sectornum 1
setVar $fig[$sectornum] "TRUE"
GOTO :resetFtrTriggers
:startScript
killAllTriggers
setTextLineTrigger fig :execute "Report Sector"
PAUSE
:execute
getText CURRENTLINE $sectornum "Sector "
":"
getSector $sector $sectordata
setVar $warpnum 1
:searchLoop
if ($warpnum > 6)
GOTO :nojump
end
setVar $jumpsector $sectordata.warp[$warpnum]
if ($jumpsector = 0)
GOTO :nojump
end
if ($fig[$jumpsector] = "TRUE")
GOTO :GO
else
ADD $warpnum 1
GOTO :searchLoop
end
:nojump
clientMessage "Script Resetting: No
ajacent fig to warp."
GOTO :startScript
:GO
SEND "m"&$jumpsector&"*"
HALT
This script will NOT actually take you all the way there, but it gets you
started anyway heh. Or i think it should. I have not tested this. What I have
done was make this script send g at the start of the script and record all
the fighters you have deployed into an array called $fig. well i didn't
really record the sector number, rather marked an index part of the array as
TRUE if a fig exists in the sector. then once all that was completed, I
started up the script waiting for the Report Sector message like my previous
example. This time when it activates, it grabs the sector number from the
message, stores it in a variable called $sectornum and then immediately goes
to the TWX database and looks for the adjacent warps. It then cycles through
until it finds an adjacent sector with a fighter in it, if not it tells you
and resets waiting for the next fighter to be hit. This script will require
that you run either 1_ZTM.ts or 2_ZTM.ets to do some Zero Turn mapping so
that TWX Proxy has the warps of the game in its database.
|
|
blackice -
12/18/01 10:37:39 AM (CST)
|
|
Really Tweety? I've used it at like 3 diff servers and I've also had it work
fine off the Deployed Fighters. It's lil early to be sure, but I thought it
was deployed fighters was in both msgs. Guess if ya unsure, use both
text triggers to go to same :line :P
Thor, it's also maybe a lil early for u to be tackling arrays if ya haven't
got the hang of the language and the simplier stuff. You may wanna just make
a couple practice scripts to get the hang of how TWX works and runs scripts.
|
|
Thor - 12/18/01
4:17:41 PM (CST)
|
|
Thanks Tweety and Black Ice, appreciate the advice :)
|
|
Tweety - 12/18/01
4:34:20 PM (CST)
|
|
Maybe now TWGS has a generic Report Sector message, but i know from when i
first started TWX scripting hehe. i was pounding the keyboard cause a script didn't
work. It would work in one game but not the other. later i figured out that
it was because it was trying to grab the wrong data from the line. Thats when
i think i asked Xide to give me the getText command. this was WAY back in
TWGS versions though heh i think in the .3x or so but i don't remember for
sure.
|
Question 20.
TWX Database gone phooey?
|
blackice -
12/13/01 8:31:20 PM (CST)
|
|
About week and half ago, Win2k barfed on me and gave blue screen of death and
did the whole core dump while I was playin TWX with SWATH. Rebooted and
everything ok til I tried to log back in to play. I did a holo scan and TWX
just closes, no errors. Repeated and rebooted numerous times. I renamed the
database file thinkin it went corrupt and sure enuf it works ok now. Just
tonite, I logged in and holo scan'd and its crashin TWX again. I renamed the
database file and all's good again. Weird thing is nothing happened this last
time to cause the corruption. Its also annoyin to loose your whole database
file :/ Anyone else had any probs like this or thoughts?
|
Answer 20.
|
Tweety - 12/18/01
6:09:49 PM (CST)
|
|
I do know Xide mentioned one time before that when you scanned from a planet,
it corrupts the database heh. I think he mentioned that he fixed that. I just
don't have the fixed version. however i have never had windows crash on me
when i scan. I use win 98 though. i do have win 2k server on another
partition, but its only a trial version so i haven't really tested twx on it.
|
Question 21.
Counting backwards to 0, for looping in
scripts.
|
Thor - 12/20/01
12:39:32 AM (CST)
|
|
Hi everyone. You have been great to give support in the past. I am learing
a lot from the answers to the questions. I wrote a script trying to go to the
port at terra and get shields and shield a planet. I want to modify the
script somewhat, once I get the basic thing going. Everything is running
well, except the countdown code I put into the script at the bottom. Could
someone take a look at this and tell me what I am doing wrong? I put the text
from the whole script in here, but it's just the countdown stuff at the end
that is giving me fits. Thanks for any help you can give.
getInput $nr "how many times to repeat the script?"
getInput $pl "which planet to shield?"
setVar $count $nr
#$count is the variable I want to use for the countdown
END
:subOne
send "l"
waitFor "Land on which planet"
send $pl "*"
waitFor "?=help"
send "tnt1*"
waitFor "?=help"
send "cgt"
waitFor "to transfer?"
send "200*"
waitFor "=help"
send "b1*y"
waitFor "Command [TL="
send "ptc"
waitFor "How many shield armor points"
send "2000*"
waitFor "Which item do you wish to buy? (A,B,C,Q,?)"
send "q"
waitFor "Command [TL="
send "n1yy"
waitFor "Command [TL="
send "l"
waitFor "Land on which planet"
send $pl "*"
waitFor "?=help"
send "cgt"
waitFor "to transfer?"
send "200*"
waitFor "?=help"
send "q"
waitFor "?=help"
send "q"
END
# this is the code I am trying to use to get a countdown so that the
# script will run the number of times specified in $nr and quit
setVar $count = ($nr - 1)
IF ($count = 0)
THEN
goto :end
ELSE
goto :subOne
:end
|
Answer 21.
|
Jama - 12/20/01
12:58:50 AM (CST)
|
|
I dont know anything about scripting in TWX but....
Maybe the reason it isnt working is that you are setting the variable AFTER
you get the input from the person?
getInput $nr "how many times to repeat the script?"
getInput $pl "which planet to shield?"
setVar $count $nr
#$count is the variable I want to use for the countdown
END
Jama
PS Have we played in the same game before Thor?
|
|
blackice -
12/20/01 1:50:24 AM (CST)
|
|
subtract $nr 1
IF ($nr = 0)
goto :end
ELSE
goto :subOne
END
:end
OR how I would write it (personal taste)
subtract $nr 1
IF ($nr <> 0)
goto :subOne
END
|
|
Tweety - 12/20/01
2:12:19 AM (CST)
|
|
This section of your code is causing you some problems:
setVar
$count = ($nr - 1)
IF ($count = 0)
THEN
goto :end
ELSE
goto :subOne
:end
what you are doing here is setting the variable $count to equal =. and there
is no command called THEN, you would get an error there. I also think you
forgot the END in your if statement.
what you will want to do is something like this:
SUBTRACT $count 1
IF ($count = 0)
GOTO :end
ELSE
GOTO :subOne
END
:end
this would do what i think you are trying to do above. cause all you want to
do i think i subtract 1 from your count. cause above in your script you did
set count as what someone inputed i think it was $nr.
|
|
blackice -
12/20/01 3:12:19 PM (CST)
|
|
Wow, is there an echo in this thread? ;)
|
|
nzthordm -
12/21/01 8:26:58 PM (CST)
|
|
ECHO...
echo...
e c h o . . .
=P
|
|
Thor - 12/21/01
9:28:29 PM (CST)
|
|
Thanks for the help everyone, I think I can see what you mean and where I
am getting the code wrong. Yes, I think we have played on the same game
together Jama, don't remember if it was the Index BBS one or the one on
Memphis Tradewars.Thanks again for the help everyone. Thor
|
Question 22.
Running Double TWX trouble #2?
|
Ahab - 12/21/01
7:50:55 AM (CST)
|
|
Ok. As it says, this is the seemingly stupid question of the week. I've been
seeing a lot of questions about the ability to run 2 Twx's at the same time
and the answer is always to 'assign another listening port'. Well, how DOES
one do that? If 23 is default, how does a player find out what other ports
are available to use?
|
Answer 22.
|
Angus - 12/21/01
1:53:23 PM (CST)
|
|
Use the command "netstat -an" from the command prompt. The port
numbers for all your open ports will be to the right of the colon. You are
only interested in the TCP ports that are "Listening".
When created extra ports I usually add 1000, so you could try 1023 for
telnet.
|
|
blackice -
12/21/01 2:47:12 PM (CST)
|
|
IF ya didn't understand that Ahab, lemme try top simplify it.
There are a total of 65,535 possible TCP ports your computer can use. Average
computer uses like a total of 10-15 at one time(at the most). If you wanna
find a port that u can use, go to your command prompt/DOS. And do the NETSTAT
-AN. It will show you all open ports on your computer. The ones you wanna
look at are the TCP ports, that are LISTENING. Those are ports already taken
and waiting for data. Pick ANY other # thats not listed in that TCP LISTENING
and your fine. You can use a port from the other categories, but you may run
into conflicts with other stuff. But geez, you got 65k diff ports you can use
anyways :P
To change the listenin port in TWX, just right click on its Icon, and go to
Setup. Then click the Program tab on top. Set the port you wanna use, then go
to your telnet app and have it connect to 127.0.0.1 and that new port u just
stuck in. Some apps wont let you choose which port to telnet on, like some
old versions of ZOC, so what u do is type it in as 127.0.0.1:port# (replace
port# with the actual port #)
|
|
Ahab - 12/22/01
6:17:29 AM (CST)
|
|
Thanks you guys. I'd been wondering about that for some time, just never
asked.
|