Brandon's rules for scripts that don't get you killed:
Every script does two things: send a command, wait_for the response.
# Wait for the command prompt, then send a command
wait_for("Command [TL=00:00:00]:[1]?")
send("I")
# Wait for the info menu, then go back
wait_for("Information")
send("Q")
The wait_for looks at what the game actually sent. The send types your command. That's it. Everything else is just repeating this pattern.
Your script sees what you see. Learn the prompts:
Command [TL=00:00:00]:[1]? — the main prompt. You're at a sector.(?) Help — help menu is open.Commerce report — you just docked at a port.Match on the exact text. If the game says "Command" and you wait for "command" (lowercase), it won't match. Case matters.
Our tw.py helper gives you:
send(cmd) — send a command to the gamewait_for(text) — block until the game shows text! — script launcher from the telnet sessiontw.log (every session)Download: coming soon. Check back after release.
A port trader — buys and sells at the current sector's port:
#!/usr/bin/env python3
# port_trade.py - simple buy/sell loop
wait_for("Command")
send("P") # Port menu
wait_for("Commerce report")
send("S") # Sell everything
wait_for("How many holds")
send("9999") # All holds
wait_for("Commerce report")
send("B") # Buy
wait_for("How many holds")
send("9999")
wait_for("Commerce report")
send("Q") # Leave port
wait_for("Command")
print("Trade complete.")
Run it with !port_trade.py from the helper. Watch it work. Then modify it. That's how you learn.
Under construction. Coming next: