View unanswered posts | View active topics It is currently Fri Mar 29, 2024 5:30 am



Reply to topic  [ 7 posts ] 
 TWX Proxy not processing line correctly 
Author Message
Ensign

Joined: Wed Nov 06, 2002 3:00 am
Posts: 268
Unread post TWX Proxy not processing line correctly
I am using Windows 7, running TWGS 2.02b game server, and running the TWX Proxy 2.05.73 version of TWX that I downloaded from Archy's Portal. I started working on a script last night, a simple script for no alignment port upgrades. My first problem was with my first check to make sure you're at the command prompt in the game.

I used CURRENTANSILINE, and it appears there must be some hidden ansi characters in there from the game server, cause according to TWX the word Command is NOT the first word in the ANSI line. So, I changed it to CURRENTLINE, it processed the line and worked fine.

My next problem I ran into, which is still driving me crazy is that TWX is not processing the
Quote:
How many units do you want to invest? (3426 max, 0 to quit)
line correctly.

I have tried waitON's, setTextTriggers, etc. It will not process that line right. In the first script, it was getting the line as CURRENTLINE and it was getting the number of units available to upgrade the way it was supposed t. But it would NOT execute correctly. It always somehow sent some character that didn't upgrade the fuel ore on the port but got you kicked off the upgrade prompt - then pretty as you please as soon as it would hit the Command prompt in the game, it would throw the variable it was supposed to throw for the no exp ore upgrade and then try to move you to that sector.

I tried everything, as I said I tried waitON's, I tried setTextTriggers, I made sure there were pauses after every block of code you could put a pause without breaking the script, I put so many killAllTriggers in that sucker I think at one time I had that command on every other line. I turned that script into the worst spaghetti code you ever saw, and I think that's quite an accomplishment for a TWX script if I do say so myself.

I switched around to every version of TWX Proxy 2.05 I have on hand, an exe of it from 2011 another from 2012, another from 2013 I think, and of course 2.05.73 - didn't work any better with any of them.

So then I got disgusted, deleted the script and started over from scratch. Now with this new attempt I am partway into, it isn't processing the
Quote:
How many units do you want to invest? (3426 max, 0 to quit)
line correctly at all, not even close. I am using a CURRENTLINE instead of a CURRENTANSILINE as you can see in the code below. As you can also see in the code below, I am checking to make sure that the script is processing the correct line. As you can see, I am using CURRENTLINE not CURRENTANSILINE, and the checkword, units, should be the 3rd word on a CURRENTLINE.

Code:
:oreMath
killAllTriggers
setvar $oreMathChkLine CURRENTLINE
getWordPos $oreMathChkLine $oreMathChk "units"

if ($oreMathChk <> 3)
  echo "*" "Script Error!!!"
  PAUSE
END


Now a copy of the dumped triggers and variables:

Quote:
Command [TL=00:00:00]:[7108] (?=Help)? :
Author's Suggestion : Go to Port upgrade, get Max upgrade levels
don't do any upgrades, quit Port upgrade screen
Make sure you have enough cash on hand, run from command prompt
<Re-Display>

Sector : 7108 in uncharted space.
Ports : Addison Primus, Class 8 (BBB)
Fighters: 1 (belong to your Corp) [Defensive]
Warps to Sector(s) : 5539 - 6660 - 19633

Command [TL=00:00:00]:[7108] (?=Help)? :
Enter how many units of each product you want to upgrade.
Enter 0 (Zero) if you do not want to upgrade that category.
Enter (Y)es if you have enough money, (Q)uit if not.
How many fuel ore units to upgrade?
Command [TL=00:00:00]:[7108] (?=Help)? :
How many organics units to upgrade?
Command [TL=00:00:00]:[7108] (?=Help)? :
How many equipment units to upgrade?
Command [TL=00:00:00]:[7108] (?=Help)? :
Do you have enough credits? Y (yes) or N (no) ?
Command [TL=00:00:00]:[7108] (?=Help)? : O
<Construct Starbase>

(Upgrade StarPort)


ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
º Upgrade Starport Production º
ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
º 1 Fuel Ore, costs $250/unit º
º 2 Organics, costs $500/unit º
º 3 Equipment, costs $900/unit º
ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
º Choose 1, 2, 3 or Q to quit º
ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
Choice ? 1

That will cost 250 per unit to upgrade the Fuel Ore
How many units do you want to invest? (3426 max, 0 to quit)
Script Error!!!
Script>
Trigger dump for script: C:\My Programs\TWXProxy 2_05\scripts\myInclude\test06.t
s

Text Triggers:
Text-Line Triggers:
Text-Out Triggers:
Delay Triggers:
Event Triggers:

Script>
Enter a full or partial variable name to search for (or blank to list them all)

Dumping all script variables
>
Variable dump for script: C:\My Programs\TWXProxy 2_05\scripts\myInclude\test06.
ts

"$A" = "0"
"$CMD" = "1"
"$CMDLINE" = "Command [TL=00:00:00]:[7108] (?=Help)? : "
"$CONDITION" = "7"
"$COUNT" = "0"
"$CREDCHK" = "y"
"$CYCLES" = "0"
"$EQUAMT" = "50"
"$EQUUP" = "0"
"$EQUUPMAX" = "3"
"$OREAMT" = "50"
"$OREMATHCHK" = "10"
"$OREMATHCHKLINE" = "How many units do you want to invest? (3426 max, 0 to quit)
"
"$OREMAX" = "0"
"$OREUP" = "9"
"$OREUPCHKLINE" = "Choice ? "
"$OREUPCHKPOS" = "1"
"$OREUPMAX" = "9"
"$ORGAMT" = "50"
"$ORGUP" = "0"
"$ORGUPMAX" = "4"
"$POS" = "7"
"$W" = "0"
"$X" = "0"
"$Y" = "0"
"$Z" = "0"

Variable Dump Complete.
>

Stopping all non-system scripts

How many units do you want to invest? (3426 max, 0 to quit)
Script terminated: C:\My Programs\TWXProxy 2_05\scripts\myInclude\test06.ts


As you can see from the screen cap of what is happening and the trigger & variable dumps, it is working on the right line for CURRENTLINE. But as you can see from the code snippet I posted, it is looking for units as the 3rd word in the line (line is $OREMATHCHKLINE). It is showing that it IS the 3rd word in that line when you look at the screen cap. But, if you look at the check variable ($OREMATHCHK) for getWordPos, TWX is saying it is the 10th word - "$OREMATHCHK" = "10"

So, what is happening here? Do I have the right version of TWX Proxy 2.05.73? Is my copy of 2.05.73 corrupted? I am totally stumped and would appreciate any help you can give me.

Thanks, Thor

EDIT :
I probably should have posted all the code of the script, so people can try it out and see if it works in their game. So, I will post it below. Keep in mind, this is not a whole working script, I stopped adding to it as soon as I started having this error.

Code:
# No Experience Port Upgrade Script
# Version 0.1
# Author : Thor

# This Script will upgrade a port with
# no experience gain

echo "*" "Author's Suggestion : Go to Port upgrade, get Max upgrade levels"
echo "*" "don't do any upgrades, quit Port upgrade screen"
echo "*" "Make sure you have enough cash on hand, run from command prompt"

:preparation
setVar $a 0
setVar $w 0
setVar $x 0
setVar $y 0
setVar $z 0
setVar $count 0
setVar $cycles 0
setVar $oreUpMax 9
setVar $orgUpMax 4
setVar $equUpMax 3
setVar $pos 1
setVar $condition 1

setTextTrigger cmdCheck :cmdCheck "Command [TL=00:00:00]"
send "*"
PAUSE

:cmdCheck
killAllTriggers
setVar $cmdLine CURRENTLINE
getWordPos $cmdLine $cmd "Command"

IF ($cmd <> 1)
  echo "*" "Not at command prompt, spoofed, other malfunction"
  setVar $pos 2
  setVar $condition 2
  HALT
Else
  goto :input
END
PAUSE

:input
killAllTriggers
setVar $pos 3
setVar $condition 3
echo "*" "Enter how many units of each product you want to upgrade."
echo "*" "Enter 0 (Zero) if you do not want to upgrade that category."
echo "*" "Enter (Y)es if you have enough money, (Q)uit if not."


getInput $oreAmt "How many fuel ore units to upgrade?"
getInput $orgAmt "How many organics units to upgrade?"
getInput $equAmt "How many equipment units to upgrade?"
getInput $credChk "Do you have enough credits? Y (yes) or N (no) ?"

IF ($credChk = "N") OR ($credChk = "n")
  echo "*" "Not enough credits, stopping script."
  HALT
Else
  setVar $pos 4
  setVar $condition 4
  goto :action1
END
PAUSE

:action1
setVar $pos 5
setVar $condition 5
killAllTriggers

IF ($oreAmt > 0)
  setVar $oreUp $oreUpMax
  goto :ore
END

IF ($oreAmt = 0) AND ($orgAmt > 0)
  setVar $orgUp $orgUpMax
  goto :org
END

IF ($oreAmt = 0) AND ($orgAmt = 0) AND ($equAmt > 0)
  setVar $equUp $equUpMax
  goto :equ
END

IF ($oreAmt = 0) AND ($orgAmt = 0) AND ($equAmt = 0)
  echo "*" "Upgrades finished or script error. Stopping Script."
  HALT
END
PAUSE

:ore
setVar $pos 6
setVar $condition 6
setTextLineTrigger oreUpgrade1 :oreUpgrade1 "Upgrade Starport Production"
send "O"
PAUSE

:oreUpgrade1
killAllTriggers
waitON "Choice ?"
setVar $oreUpChkLine CURRENTLINE
getWordPos $oreUpChkLine $oreUpChkPos "Choice"

IF ($oreUpChkPos = 1)
  setVar $pos 7
  setVar $condition 7
  goto :oreUpgrade2
Else
  echo "*" "script Error"
  setVar $pos 8
  setVar $condition 8
  PAUSE
END

:oreUpgrade2
setTextTrigger oreMath :oreMath "How many units do you want to invest?"
send "1"
PAUSE

:oreMath
killAllTriggers
setvar $oreMathChkLine CURRENTLINE
getWordPos $oreMathChkLine $oreMathChk "units"

if ($oreMathChk <> 3)
  echo "*" "Script Error!!!"
  PAUSE
END
PAUSE

getText CURRENTLINE $oreMax "want to invest? (" "max, 0 to quit)"
stripText $oreMax " "
PAUSE


So that's all the script code up to this problem. Thanks


Wed May 21, 2014 5:42 pm
Profile
Commander
User avatar

Joined: Fri Jun 09, 2006 2:00 am
Posts: 1396
Location: Canada
Unread post Re: TWX Proxy not processing line correctly
Been a while since I've done any scripting. But it looks to me that "10" value returned by the getwordpos is trying to tell you that the U in Units is at the tenth character position in the string.

The example in the twx scripting reference HTML shows this:
Code:
setVar $line "This is a line of text"
getWordPos $line $pos "line"

# displays: 11
echo $pos


Hope this helps

_________________
----------------------------
-= QUANTUM Computing 101: 15 = 3 x 5 ... 48% of the time.
-= There are 10 types of people in the world: Those that understand Binary and those who do not
-= If Oil is made from Dinosaurs, and Plastic is made from Oil... are plastic Dinosaurs made from real Dinosaurs?
-= I like to keep my friends and my enemies rich, and wait to see which is which - Tony Stark (R.I.P.)


Thu May 22, 2014 12:13 am
Profile ICQ YIM
Ensign

Joined: Wed Nov 06, 2002 3:00 am
Posts: 268
Unread post Re: TWX Proxy not processing line correctly
Doh!! :oops: Thanks Lone, I believe that's the problem. Maybe all the hair I pulled out (which I really can't spare, too much has gone AWOL as it is :lol: ) and the marks I got from banging my head on the wall will remind me of the old adage we used in the Army about reading the manual. Lol


Thu May 22, 2014 3:05 am
Profile
Commander
User avatar

Joined: Fri Jun 09, 2006 2:00 am
Posts: 1396
Location: Canada
Unread post Re: TWX Proxy not processing line correctly
Good to see that you're using the LoneStar Approved Method of Debugging. ;)

_________________
----------------------------
-= QUANTUM Computing 101: 15 = 3 x 5 ... 48% of the time.
-= There are 10 types of people in the world: Those that understand Binary and those who do not
-= If Oil is made from Dinosaurs, and Plastic is made from Oil... are plastic Dinosaurs made from real Dinosaurs?
-= I like to keep my friends and my enemies rich, and wait to see which is which - Tony Stark (R.I.P.)


Thu May 22, 2014 4:14 pm
Profile ICQ YIM
Ensign

Joined: Wed Nov 06, 2002 3:00 am
Posts: 268
Unread post Re: TWX Proxy not processing line correctly
Ya the LAMD, no pain no gain :lol:


Thu May 22, 2014 5:24 pm
Profile
Commander

Joined: Sun Feb 25, 2001 3:00 am
Posts: 1837
Location: Guam USA
Unread post Re: TWX Proxy not processing line correctly
I stopped reading your post part way through .. at about 70% or so .. it was long but I think I seen why you may have problems ..

You trigger on unit .. but your value is a bit after that .. so script may leave you with a zero value because it may not get that far when triggering.

I would use "0 to quit)" so that you could use getword and locate the value there.

I like to grab the line at a part after where I need the data if possible.
Todays processors run much faster then they did when this stuff first came out and many older scripts have to be re-thunk do to that fact.

Hope this helps.

_________________
TWGS V2 Vids World on Guam Port 2002
Telnet://vkworld.ddns.net:2002
Discord @ DiverDave#8374
Vid's World Discord

Founding Member -=[Team Kraaken]=- Ka Pla

Image
Winners of Gridwars 2010
MBN Fall Tournament 2011 winners Team Kraaken
Undisputed Champions of 2019 HHT Just for showing up!

The Oldist , Longist Running , Orginal Registered Owner of a TWGS server :
Vids World On Guam


Fri May 23, 2014 12:16 pm
Profile WWW
Ensign

Joined: Wed Nov 06, 2002 3:00 am
Posts: 268
Unread post Re: TWX Proxy not processing line correctly
Thanks Vid, that sounds like a better way to do it. Great scripting tip. :)


Sun May 25, 2014 12:30 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 7 posts ] 

Who is online

Users browsing this forum: No registered users and 5 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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware.