Jun. 23, 2018

Hello der,  Guest
Trader Name:
Password:
 | Home | Forum List | Active Threads | Search:
Page: of 1   
TWX Development > 2.04b bug with event triggers  
<< Thread >>
Subscribed:  
Sketch

Joined: Jun 2006

posted: 08/11/2006 at 11:41 AM Post #1

There seems to be a bug with event triggers in seperate files.  I have a main file that sets an event trigger for connection lost, this includes several other files.  If the script is executing in one of the included files and the connection is lost, the script exits saying it can't find the label for the connection lost trigger.  Below is an example that is a big extreme by forcing a disconnect, but it simulates what happens.  Of course, if I disconnect in the main file, everything works fine. 

This worked in 2.03 since I had a script that would cash 24/7 and if disconnected, it would wait a minute and then reconnect and continue the script.

Example:
# File S_Tmp.ts
setEventTrigger timeout :S_Tmp~timeout "connection lost"
# Note: I've tried the above line with and without the S_Tmp~ in front of the label with no luck
gosub :Tmp~func
halt

:timeout
echo "hit timeout*"
pause

include "Tmp.ts"

# File Tmp.ts
:func
disconnect
pause

##########

Here is the output of the execution:
Loading and compiling script: scripts\s_tmp.ts


Disconnecting from server...

Command [TL=00:00:00]:[3308] (?=Help)? :
Connection lost.
Script run-time error (trigger activation): Goto label not found 'S_TMP~TIMEOUT'

Script terminated: scripts\s_tmp.ts


#############
If I run this slightly modified script it works:
setEventTrigger timeout :timeout "connection lost"
disconnect
pause

:timeout
echo "hit timeout*"
pause

############
This version of the script crashes TWX
setEventTrigger timeout :S_Tmp~timeout "connection lost"
disconnect
halt

:timeout
echo "hit timeout*"
pause
Dnyarri


Joined: Jun 2005

posted: 08/11/2006 at 06:39 PM Post #2

Includes have seperate labeling than the main code. It's a kind of private namespace for labels in a way. So if you fire off a main code trigger in an include you will get this problem. If you reverse it... and set the trigger label as the include label, you might not have that problem.

You might also have luck setting the trigger label as a main label rather than letting twx decide run-time with something like...

setEventTrigger timeout :~timeout "connection lost"
pause

:timeout
# timeout code here

If you use a :~ with nothing in between the : and ~ you are telling TWX to run the main label.

All of this equals a big pain in the butt tho, in general you want to kill triggers between includes and the main. You might want to try using background scripts instead. Setting the event trigger(s) in a BG script and using that as a kind of daemon to catch the disconnect.


edited by: Dnyarri on 08/11/2006 at 06:43 PM

The NavHaz Junction - http://www.navhaz.com
Sketch

Joined: Jun 2006

posted: 08/12/2006 at 06:33 PM Post #3

That worked, thanks!  I would have never guessed to take out the main filename.

It's working now just fine, thanks again!
TWX Development >  2.04b bug with event triggers
<< Thread >>
Subscribed:  
 | Home | Forum List | Active Threads | Search:
Page: of 1   

"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.447 seconds.