Sep. 24, 2018

Hello der,  Guest
Trader Name:
Password:
 | Home | Forum List | Active Threads | Search:
Page: of 1   
Script Feedback > Would having a good ping cause a script hiccup?  
<< Thread >>
Subscribed:  
Maniac

Joined: Apr 2005

posted: 02/14/2008 at 01:23 AM Post #1

I state this because I have successfully ran a script I wrote on several servers, several times all with out incident. But recently I found another connection and can get sub 200 ms pings and tried to run the same script.  I kept getting an error that -- is not a decimal # on a line similar to this
if ($Planet <> "---" ) and ($planetno) and ($planet > 0) and ($PlanetName <> "XX") and ($planet <> $oldplanet)

I fixed my error by making it similar to this
if ($planet <> "---")
  if ($planetno)
  if ($planet > 0)
  if ($planetName= "XX")
  if ($planet <> $oldplanet)

I was wondering if there is a "short circuit" logic in TWX that might cause this error....
I did not dump any variables or anything as I have had it working before without incident but lately with a good ping/bandwidth I might be receiving information faster than my program can handle. The -- that I error on, is the start of the next line. 

Sometimes I can't read the information that comes from the TWX Server it scrolls by so fast.
This happens on other scripts that I have ran (where the zoc/swath scrolling is so fast you can only guess what is scrolling by).

Now to rephrase my original question Could a poorly written script fubar when the connection is too "fast"? 


ElderProphet
TWX Development Team

Joined: Mar 2005

posted: 02/16/2008 at 07:17 PM Post #2

The answer to your final question is yes, absolutely.  And the poorly written part is typically the lack of a waitOn trigger before a setTextTrigger or setTextLineTrigger.

The classic scenario is where you send a string of commands to the TW server and immediately set a text trigger expecting it to only fire after the last of those commands executes.  What usually happens though is that your trigger fires early because the triggering text appears not just after the final part of your burst, causing unpredictable behavior.  Consider the following:
# Land, dump Fuel, buy more
send "l" $planet "*tnl1*q pt**"
# And we want to see how much Fuel the port has left
setTextLineTrigger checkPortFuel :portFuel "Fuel Ore"
pause

We're trying to dump fuel, and buy more, checking the port's qty on hand when done.  The problem is that the string "Fuel Ore" appears earlier when your are dumping fuel, so you end up capturing the wrong data.  You should have used a waitOn just before the setTextLineTrigger that would delay the trigger being set until you were actually porting, like waitOn "Docking...".

While this example shouldn't be timing sensitive, it illustrates the need for controlled trigger setting.  Script problems that show up when ping times change are almost always (read: always) caused by this kind of error.

+EP+

Haggle Blog-> http://jroller.com/page/ElderProphet

"why hello der matey! have a sit and buy me an ale, eh?" -- The Grimy Old Trader

The Grimy Trader is best viewed at 1024x768 resolution -- this page was generated in: 0.478 seconds.