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
|
|