| www.ClassicTW.com https://mail.black-squirrel.com/ |
|
| My first TWX script. https://mail.black-squirrel.com/viewtopic.php?f=15&t=33938 |
Page 1 of 1 |
| Author: | Micro [ Sun Apr 14, 2013 1:04 pm ] |
| Post subject: | My first TWX script. |
Even reading TWX script gives me a headache, so I swore I would never write anything in TWX script, but I have fallen to the DARK SIDE This script sends M()MBOT "Status" commands over SubSpace, parses the status reports, and displays a combined status report for the whole team. The report is sent over subspace, and displayed locally in color. Your comments and suggestions are welcome ![]() Code: :GetStatus loadVar $Team~BotList If ($Team~BotList = 0) getInput $Team~BotList "Please enter bot names seperated by spaces." saveVar $Team~BotList end echo ANSI_14 "Collecting Data...**" setVar $i 1 :Loop1 getWord $Team~BotList $TeamStatus~BotName[$i] $i #saveVar TeamStatus$BotName[$i] if ($TeamStatus~BotName[$i] <> 0) send "'" $TeamStatus~BotName[$i] " Status*" Gosub :LoadStatus add $i 1 goto :Loop1 end # Send Status over SubSpace send "'* *Player Sector Prompt Turns PH Mode IG Ship LP Time*" send "------------ ------- -------- ------- -- -------- --- ---- -- -------*" setVar $i 1 :Loop2 # Only use left 4 characters of the bot name. cutText "{" & $TeamStatus~BotName[$i] $BotName 1 5 cutText $BotName & "} " $BotName 1 6 if ($TeamStatus~BotName[$i] <> 0) send $TeamStatus~Player[$i] send $BotName " " if $TeamStatus~OnPlanet[$i] cutText $TeamStatus~Sector[$i] & "P " $Sector 1 7 else cutText $TeamStatus~Sector[$i] & " " $Sector 1 7 end send $Sector " " send $TeamStatus~Prompt[$i] " " send $TeamStatus~Turns[$i] " " send $TeamStatus~Photons[$i] " " send $TeamStatus~Mode[$i] " " send $TeamStatus~IG[$i] " " send $TeamStatus~Ship[$i] " " send $TeamStatus~LastPlanet[$i] " " send $TeamStatus~TimeLeft[$i] "*" add $i 1 goto :Loop2 end send "*" # Display Status Locally subtract $i 1 WaitFor $TeamStatus~Player[$i] & "{" WaitFor "Command [TL" echo ANSI_5 "**Player Sector Prompt Turns PH Mode IG Ship LP Time*" echo ANSI_15 "------------ ------- -------- ------- -- -------- --- ---- -- -------*" setVar $i 1 :Loop3 # Only use left 4 characters of the bot name. cutText "{" & $TeamStatus~BotName[$i] $BotName 1 5 cutText $BotName & "} " $BotName 1 6 if ($TeamStatus~BotName[$i] <> 0) echo ANSI_11 $TeamStatus~Player[$i] echo $BotName " " if $TeamStatus~OnPlanet[$i] cutText $TeamStatus~Sector[$i] & ANSI_12 & #27 & "[5mP" & #27 & "[0m " $Sector 1 22 else cutText $TeamStatus~Sector[$i] & " " $Sector 1 7 end echo ANSI_14 $Sector " " echo ANSI_10 $TeamStatus~Prompt[$i] " " echo ANSI_14 $TeamStatus~Turns[$i] " " echo ANSI_13 $TeamStatus~Photons[$i] " " echo ANSI_10 $TeamStatus~Mode[$i] " " echo ANSI_13 $TeamStatus~IG[$i] " " echo ANSI_10 $TeamStatus~Ship[$i] " " echo ANSI_13 $TeamStatus~LastPlanet[$i] " " echo ANSI_14 $TeamStatus~TimeLeft[$i] "*" add $i 1 goto :Loop3 end halt :LoadStatus WaitFor "--- Status Report ---" getWord CURRENTLINE $Channel 1 if ($Channel = "S:") setVar $WordOffset 5 setVar $TeamStatus~Player[$i] $TraderName else setVar $WordOffset 6 getWord CURRENTLINE $TeamStatus~Player[$i] 2 end cutText $TeamStatus~Player[$i] & " " $TeamStatus~Player[$i] 1 6 killAllTriggers setTextTrigger S0 :Trader "Trader Name" setTextTrigger S1 :Sector " - Sector" setTextTrigger S2 :Prompt " - Prompt" setTextTrigger S3 :Turns " - Turns" setTextTrigger S4 :Photons " - Photons" setTextTrigger S5 :Mode " - Mode" setTextTrigger S6 :IG " - IG" setTextTrigger S7 :Ship " - Ship" setTextTrigger S8 :Planet " - Planet" setTextTrigger S9 :LastPlanet " - Last Planet" setTextTrigger S10 :Team " - Team" setTextTrigger S11 :TimeLeft " - Time Left" pause :Trader getWord CURRENTLINE $TraderName 5 # if $TraderName # getWord CURRENTLINE $TraderName 5 #end cutText $TraderName & " " $TraderName 1 6 goto :LoadStatus :Sector getWord CURRENTLINE $TeamStatus~Sector[$i] $WordOffset pause :Prompt getWord CURRENTLINE $TeamStatus~Prompt[$i] $WordOffset cutText $TeamStatus~Prompt[$i] & " " $TeamStatus~Prompt[$i] 1 8 pause :Turns getWord CURRENTLINE $TeamStatus~Turns[$i] $WordOffset cutText $TeamStatus~Turns[$i] & " " $TeamStatus~Turns[$i] 1 7 pause :Photons getWord CURRENTLINE $TeamStatus~Photons[$i] $WordOffset cutText $TeamStatus~Photons[$i] & " " $TeamStatus~Photons[$i] 1 2 pause :Mode getWord CURRENTLINE $TeamStatus~Mode[$i] $WordOffset cutText $TeamStatus~Mode[$i] & " " $TeamStatus~Mode[$i] 1 8 pause :IG getWord CURRENTLINE $TeamStatus~IG[$i] $WordOffset cutText $TeamStatus~IG[$i] & " " $TeamStatus~IG[$i] 1 3 pause :Ship getWord CURRENTLINE $TeamStatus~Ship[$i] $WordOffset cutText $TeamStatus~Ship[$i] & " " $TeamStatus~Ship[$i] 1 4 pause :Planet getWord CURRENTLINE $TeamStatus~LastPlanet[$i] $WordOffset cutText $TeamStatus~LastPlanet[$i] & " " $TeamStatus~LastPlanet[$i] 1 2 setVar $TeamStatus~OnPlanet[$i] 1 pause :LastPlanet getWord CURRENTLINE $TeamStatus~LastPlanet[$i] $WordOffset + 1 cutText $TeamStatus~LastPlanet[$i] & " " $TeamStatus~LastPlanet[$i] 1 2 setVar $TeamStatus~OnPlanet[$i] 0 pause :Team getWord CURRENTLINE $TeamStatus~Team[$i] $WordOffset cutText $TeamStatus~Team[$i] & " " $TeamStatus~Team[$i] 1 4 pause :TimeLeft getWord CURRENTLINE $TeamStatus~TimeLeft[$i] $WordOffset + 1 cutText $TeamStatus~TimeLeft[$i] & " " $TeamStatus~TimeLeft[$i] 1 7 return |
|
| Author: | Mongoose [ Sun Apr 14, 2013 2:04 pm ] |
| Post subject: | Re: My first TWX script. |
Congrats, I guess. |
|
| Author: | Micro [ Sun Apr 14, 2013 2:20 pm ] |
| Post subject: | Re: My first TWX script. |
Mongoose wrote: Congrats, I guess. Not really; I almost threw up several times. Using TWX script just encourages me to work more on FirstMate. I still hate TWX script, and I always will. I couldn't help but notice that portions of that script are actually event driven. It seems to be very common in the examples I have been reading. |
|
| Author: | Cruncher [ Sun Apr 14, 2013 5:20 pm ] |
| Post subject: | Re: My first TWX script. |
Personally I really dislike corpmates spamming SS when they want to gather info. If you can make it echo only to you, I think your corpmates would appreciate it. Or, give them the option at the very least. |
|
| Author: | Micro [ Sun Apr 14, 2013 5:48 pm ] |
| Post subject: | Re: My first TWX script. |
Cruncher wrote: Personally I really dislike corpmates spamming SS when they want to gather info. If you can make it echo only to you, I think your corpmates would appreciate it. Or, give them the option at the very least. That will be an option for the final report, but unfortunately there is no silent way to collect the information using M()MBOT as it has to send a status request to each bot. If I want to know how many turns each player has (for instance), I would have to ask each player or send the status request anyway. This just makes it faster. I actually wrote it to see if everyone was in the correct ships, at valid prompts, etc... to make sure everyone was ready before starting TSDT. |
|
| Author: | Cruncher [ Sun Apr 14, 2013 8:21 pm ] |
| Post subject: | Re: My first TWX script. |
Micro wrote: Cruncher wrote: Personally I really dislike corpmates spamming SS when they want to gather info. If you can make it echo only to you, I think your corpmates would appreciate it. Or, give them the option at the very least. That will be an option for the final report, but unfortunately there is no silent way to collect the information using M()MBOT as it has to send a status request to each bot. If I want to know how many turns each player has (for instance), I would have to ask each player or send the status request anyway. This just makes it faster. I actually wrote it to see if everyone was in the correct ships, at valid prompts, etc... to make sure everyone was ready before starting TSDT. The team SDT that I use does do a status report on everyone before starting. |
|
| Author: | Micro [ Sun Apr 14, 2013 9:15 pm ] |
| Post subject: | Re: My first TWX script. |
Cruncher wrote: The team SDT that I use does do a status report on everyone before starting. Which one are you using? |
|
| Author: | Cruncher [ Sun Apr 14, 2013 9:47 pm ] |
| Post subject: | Re: My first TWX script. |
Micro wrote: Cruncher wrote: The team SDT that I use does do a status report on everyone before starting. Which one are you using? Boo SDT, Xanos wrote it, upgraded it a bit for Killbillies. He's asked me to not distributed it. Before he made his final tweeks he gave all of Boo the file just before we had the Boo vs Boo game. |
|
| Author: | mob [ Mon Apr 15, 2013 12:39 pm ] |
| Post subject: | Re: My first TWX script. |
Nice script... It's interesting to see the differences between scripts who's authors are programmers vs non-programmers. Micro, are you a programmer? |
|
| Author: | mob [ Mon Apr 15, 2013 12:51 pm ] |
| Post subject: | Re: My first TWX script. |
I wrote this during one of our death matches, it worked on two people then crosby got me.. This is one of my first scripts I wrote to work with m()m bot. I would love to get back into writing. I loved playing with a few good friends and being asked to come up with something on the fly. Code: # After plock turn on citkill # # systemscript loadvar $bot_name send "'*" send "Starting Active Plock/Auto Citkilla**" :starttriggers settexttrigger 1 :activeplock "{" & $bot_name & "} - PLOCK Ready to fire Sector:" settexttrigger 2 :cleared "{" & $bot_name & "} - PLOCK Sector Cleared" echo "***...Waiting for plock to fire...***" echo "***...Be sure that you do not have (kill) option on...***" pause :activeplock killtrigger 1 killtrigger 2 settexttrigger 3 :plockdone " -PLOCK Launched" pause :plockdone killtrigger 3 send "'*" send $bot_name " citkill on dt smart**" :cleared killalltriggers send "'Resetting triggers!*" goto :starttriggers #disrupted 12 of your mines in 19146 |
|
| Author: | Micro [ Mon Apr 15, 2013 11:41 pm ] |
| Post subject: | Re: My first TWX script. |
mob wrote: Micro, are you a programmer? Yes, for as long as I can remember. Started with gwbasic, assembler, and c (before ++) back in the 80's. Now I prefer C#/WPF. |
|
| Author: | mob [ Tue Apr 16, 2013 4:14 am ] |
| Post subject: | Re: My first TWX script. |
Micro wrote: mob wrote: Micro, are you a programmer? Yes, for as long as I can remember. Started with gwbasic, assembler, and c (before ++) back in the 80's. Now I prefer C#/WPF. Yeah, and I'm not. You can see the difference in the script. Nice job though man. |
|
| Author: | Kaus [ Fri Apr 19, 2013 6:47 am ] |
| Post subject: | Re: My first TWX script. |
Lots of way's to skin a cat, personally I would have used a while instead of the that loop and used a "&" during your send spam. But for a first time with TWX it's good, very readable which I'm a fan of. However, not sure what you were expecting from a scripting language; event driven and all It's not like it's Objective C or something |
|
| Author: | Micro [ Sun Apr 21, 2013 5:26 pm ] |
| Post subject: | Re: My first TWX script. |
Actually, I didn't even know TWX had "WHILE". Normally I would use a "for" or "foreach" in this scenario, but TWX doesn't have those. I prefer C#/WPF, so I actually don't like using "GOTO" at ALL! |
|
| Page 1 of 1 | All times are UTC - 5 hours |
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |
|