Loading...
 

Triggers are essential to any TradeWars script, and allow events to trigger actions. This is usually in the form of waiting for the response to a command you sent and parsing lines of text produced by that command. Triggers are also used to respond to in-game events like fig/mine hits, a player entering a sector, or even commands sent to your bot over SubSpace. Event triggers can be used to respond to internal events like when a script ends or you get disconnected from a server.

  • setAutoTrigger - NEW Creates a trigger that automatically responds to an event.
  • setDelayTrigger - Creates a trigger that will activate after a specified time period.
  • setEventTrigger - Creates a trigger that will activate on a certain program event.
  • setTextLineTrigger - Creates a trigger activated when specific text is received from Server.
  • setTextOutTrigger - Creates a trigger activated when specific text is received from Client.
  • setTextTrigger - Creates a text trigger activated when specific text is received.
  • killAllTriggers - Terminates all triggers in the script and its included subroutines.
  • killTrigger - Terminates the specified trigger.
  • pause - Pauses the script's execution, allowing it to wait for its triggers to activate.
  • WaitFor - Pauses script execution, waiting for specified text from server connection.
  • WaitOn - create a temporary TextTrigger using a macro.



waitOn can be used as a substitute for a waitFor command that will not be 'broken' if another trigger activates while the script is waiting for text. waitFor works well for short delays, but will not return the correct CURRENTLINE when triggered. waitOn literally places a setTextTrigger, pause and a temporary :label in your compiled code. sleep is a pause with a timeout. sleep literally compiles as a setDelayTrigger, pause, and a temporary :label in your compiled code.

setEventTrigger    T1 :DisConnect "CONNECTION LOST"
setDelayTrigger    T2 :Timeout wait 60000
setTextLineTrigger T3 :Label1 "Trigger String"
setTextLineTrigger T4 :Label2 "Trigger String"
setTextTrigger     T5 :Done   "Command [TL="
pause

:DisConnect

:Timeout

:Label1

:Label2

:Done