Author |
Message |
Crosby
Lieutenant Commander
Joined: Sun Jan 29, 2006 3:00 am Posts: 793 Location: Iowa
|
Mass Merch Script for testing
I have added a few things to LoneStar's Mass Merch script: http://www.tw2002.info/ls_dny_help/scripting_201.htmThis script will use m()m's 'merch' script to sell off all product from all the planets in a sector...buying fuel at each port and put all cash in the starting citadel. Code: # Copy of LS's Mom Bot Merch # A simple script that Utilizes MOM modules to Merch Org and Equip. from # planets in a sector. # -- Modified slightly by crosby...less input from user required. # Getword currentline $prompt 1 If $prompt <> "Citadel" echo "*Dude, you need to start this in a Cit..." halt End LoadVar $bot If $bot = 0 echo ANSI_3 "*Yo..what's yer bot's name? " getconsoleinput $bot saveVar $bot End
# If you want Merch to buydown ore from ports, change the False to True setVar $Buyfuel true # Do Port CIM Update
setVar $Do_CIM true # Bank Planet where funds are deposited. **Must Be in same sector** send "QDCS" waitfor "in sector" getword currentline $bank_planet 2 striptext $bank_planet "#" setVar $start_sector currentsector # Minimum product amount for the Merch cmd line setVar $Product_Amount 1500 setVar $Planets_Sect SECTOR.PLANETCOUNT[$start_sector] setArray $Planets $Planets_Sect # List of Planets in Current Sector. $Bank_Planet, must be in the sector as well. :grab_planets setvar $counter 0 send "q q q q **L" waiton "-------------------------------------------------------------------------------" settextlinetrigger next_planet :next_planet "<" settexttrigger done_grabbing :done_grabbing "Land on which " pause
:next_planet setvar $counter $counter + 1 getword currentline $Planets[$counter] 2 striptext $Planets[$counter] ">"
echo "* Grabbed planet " & $Planets[$counter] & "*"
settextlinetrigger next_planet :next_planet "<" pause
:done_grabbing killtrigger next_planet
echo "* Made it to :done_grabbing*"
send "**" # Get to Command Prompt --- should be there... send " q q q z n * * /" waiton (#179 & "Turns") if ($Do_Cim) # Update Port-Cim. Only really needs to be done once per session. setEventTrigger cim_detect :cim_detect "SCRIPT STOPPED" "scripts\MomBot\Commands\Data\cim.cts" setEventTRigger cim_timeout :cim_timeout 300000 send "'" & $bot & " cim*" waiton "Message sent on sub-space channel" pause :Cim_timeout killalltriggers echo "***Cim Timed Out ( 5 mins expired. )***" halt :cim_detect killalltriggers end setvar $planets_idx 1 While ($planets_idx <= $planets_sect) if ($planets[$planets_idx] <> 0) setvar $p $planets[$planets_idx] gosub :gogo if ($fini) goto :endgame end end add $planets_idx 1 end :endgame send "'" & $bot & " land " & $bank_planet & "*" settextlinetrigger ilanded :ilanded "- In Cit - Planet" pause :ilanded killalltriggers # Tries to Return Planet to starting sector
send "'" & $bot & " pwarp " & $start_sector & "*" waiton "Message sent on sub-space channel" halt # --------------------------------------------------------
:gogo send "'" & $bot & " land " & $p & "*" settextlinetrigger landed :landed "- In Cit - Planet" pause :landed killalltriggers setvar $fini false if ($buyfuel) send "'" & $bot & " merch 1500 o e neg skipcim buyfuel*" else send "'" & $bot & " merch 1500 o e neg skipcim *" end waiton "Message sent on sub-space channel" settextlinetrigger done_merch :done_merch "- Planet Merchant completed." settextlinetrigger done_done :done_done "Can't find a route to any other ports." pause :done_done setvar $fini true pause :done_merch killalltriggers send "'" & $bot & " with*" waiton "Message sent on sub-space channel" settextlinetrigger with :with "credits taken from citadel." pause :with # send "'" & $bot & " figmove s*" # waiton "Message sent on sub-space channel" # settextlinetrigger moved :moved "{" & $bot & "} - fighters moved" # pause :moved killalltriggers send "q q q z n * L " & $bank_planet & "* c '" & $bot & " dep*" waiton "Message sent on sub-space channel" settextlinetrigger dep :dep "credits deposited into citadel." pause :dep killalltriggers send "q q q z n ** " waiton "Warps to Sector(s) :" return
_________________ #+++ The early bird may get the worm, but the second mouse gets the cheese. #---
|
Fri Sep 13, 2013 4:41 pm |
|
|
Astrochimp
Ensign
Joined: Mon Dec 26, 2011 8:41 am Posts: 206
|
Re: Mass Merch Script for testing
Thanks Crosby, I'll let you know how my testing goes...
|
Sat Sep 14, 2013 9:57 am |
|
|
Astrochimp
Ensign
Joined: Mon Dec 26, 2011 8:41 am Posts: 206
|
Re: Mass Merch Script for testing
Output below; it's trying to reference $Planets[4] even though there are only 3 planets in the sector.
Command [TL=00:00:00]:[15300] (?=Help)? : L <Preparing ship to land on planet surface>
<Atmospheric maneuvering system engaged> Registry# and Planet Name Citadel RLvl Fighters QCanRLvl Cls ------------------------------------------------------------------------------- < 35> . Level 4 0% 0 0% M Owned by: . [3] < 47> . Level 5 0% 8T 0% H Owned by: . [3] < 52> . Level 6 0% 39 0% M Owned by: . [3]
Land on which planet <Q to abort> ?
Displaying all messages.
Land on which planet <Q to abort> ? Grabbed planet 35
Grabbed planet 47
Grabbed planet 52 Script run-time error in 'MASSMERCH.TS': Static array index '4' is out of range (must be 1-3), line 44
Made it to :done_grabbing
Script terminated: scripts\mombot\modes\cashing\massmerch.ts
|
Sat Sep 14, 2013 11:46 am |
|
|
Crosby
Lieutenant Commander
Joined: Sun Jan 29, 2006 3:00 am Posts: 793 Location: Iowa
|
Re: Mass Merch Script for testing
Thanks for your help testing Astro, it's funny how it made it to :done_grabbing
I'm trying to recreate this error... for me the big downer is the long drawn out cim at the beginning..
_________________ #+++ The early bird may get the worm, but the second mouse gets the cheese. #---
|
Sat Sep 14, 2013 12:23 pm |
|
|
Astrochimp
Ensign
Joined: Mon Dec 26, 2011 8:41 am Posts: 206
|
Re: Mass Merch Script for testing
Crosby wrote: Thanks for your help testing Astro, it's funny how it made it to :done_grabbing
I'm trying to recreate this error... for me the big downer is the long drawn out cim at the beginning.. Yeah, I know... my understanding of twx scripting isn't that strong so I could be wrong but to me it looks like the next_planet trigger is firing immediately after done_grabbing, before the latter has a chance to execute its first line of continuation code. Maybe you can add a condition around the line where you set the next_planet trigger, so it only gets set if $counter is less or equal to the size of the $planets array.
|
Sat Sep 14, 2013 1:54 pm |
|
|
Archy
Immortal Op
Joined: Fri Jun 25, 2010 6:33 am Posts: 257 Location: Sydney Australia
|
Re: Mass Merch Script for testing
The problem here is that the routine that grabs the planet is grabbing the blank line between the last planet and the "Land on which" prompt and incrementing the planet index past the size of the array. Test the planet number for a null string before incrementing the planet number... Example: Code: :next_planet GetText CURRENTLINE $temp "<" ">" If ($temp <> "") StripText $temp " " setvar $counter ($counter + 1) SetVar $Planets[$counter] $temp echo "* Grabbed planet " & $Planets[$counter] & "*" End SetTextLineTrigger next_planet :next_planet ">" pause
_________________ Teamspeak3: 60.242.57.40:9987 Z-Bot does my dirty work!
|
Sat Sep 14, 2013 2:30 pm |
|
|
Astrochimp
Ensign
Joined: Mon Dec 26, 2011 8:41 am Posts: 206
|
Re: Mass Merch Script for testing
Archy wrote: The problem here is that the routine that grabs the planet is grabbing the blank line between the last planet and the "Land on which" prompt and incrementing the planet index past the size of the array. Test the planet number for a null string before incrementing the planet number... Example: Code: :next_planet GetText CURRENTLINE $temp "<" ">" If ($temp <> "") StripText $temp " " setvar $counter ($counter + 1) SetVar $Planets[$counter] $temp echo "* Grabbed planet " & $Planets[$counter] & "*" End SetTextLineTrigger next_planet :next_planet ">" pause
Thanks, I tried your code, but got the same error. Seems to work when I do this: Code: :next_planet setvar $counter $counter + 1 getword currentline $Planets[$counter] 2 striptext $Planets[$counter] ">"
echo "* Grabbed planet " & $Planets[$counter] & "*"
if ($counter < SECTOR.PLANETCOUNT[$start_sector]) SetTextLineTrigger next_planet :next_planet ">" end pause
|
Sat Sep 14, 2013 2:57 pm |
|
|
Astrochimp
Ensign
Joined: Mon Dec 26, 2011 8:41 am Posts: 206
|
Re: Mass Merch Script for testing
Next problem: after the cim, nothing happens. When I check triggers, the only thing massMerch is waiting on is cim_detect which is looking for a SCRIPT_STOPPED event on "scripts\MomBot\Commands\Data\cim.cts", which when I scroll up looks like it should have triggered, but actually maybe z-bot is doing stuff that massmerch is not expecting: Code: '{hd} - Processing CIM...
Message sent on sub-space channel 905.
Command [TL=00:00:00]:[15300] (?=Help)? :
²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²T
Corp Menu Corporate command [TL=00:00:00]:[15300] (?=Help)? T
Establishing connection with Corporate M.A.I.L. Server.
Type corporate message [<ENTER> to send line. Blank line to end transmission] C: -----hd----- C: Upped Ports: (At least 10000 product level) C: 2792(SBB) 4208(SSB) 4958(BSB) 5959(BSB) 6160(SBB) 8446(SBB) Script terminated: scripts\mombot\commands\data\cim.cts
18775(BSB) C:
edit: I guess I can't expect everything to be compatible with z-bot... the cim being called here is mombot's cim, which I'd added to z-bot's 'xtra' scripts.
Last edited by Astrochimp on Sat Sep 14, 2013 3:25 pm, edited 1 time in total.
|
Sat Sep 14, 2013 3:08 pm |
|
|
Archy
Immortal Op
Joined: Fri Jun 25, 2010 6:33 am Posts: 257 Location: Sydney Australia
|
Re: Mass Merch Script for testing
Astrochimp wrote: Next problem: after the cim, nothing happens. When I check triggers, the only thing massMerch is waiting on is cim_detect which is looking for a SCRIPT_STOPPED event on "scripts\MomBot\Commands\Data\cim.cts", which when I scroll up looks like it should have triggered, but actually maybe z-bot is doing stuff that massmerch is not expecting: Code: '{hd} - Processing CIM...
Message sent on sub-space channel 905.
Command [TL=00:00:00]:[15300] (?=Help)? :
²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²T
Corp Menu Corporate command [TL=00:00:00]:[15300] (?=Help)? T
Establishing connection with Corporate M.A.I.L. Server.
Type corporate message [<ENTER> to send line. Blank line to end transmission] C: -----hd----- C: Upped Ports: (At least 10000 product level) C: 2792(SBB) 4208(SSB) 4958(BSB) 5959(BSB) 6160(SBB) 8446(SBB) Script terminated: scripts\mombot\commands\data\cim.cts
18775(BSB) C:
Z-Bot would be standing down while an external script is running. I would try setting it up as a DAEMON in the doubletap menu, making the bot stand to attention automatically as soon as the script starts. That is, if you need the z-bot awake while your script is running.
_________________ Teamspeak3: 60.242.57.40:9987 Z-Bot does my dirty work!
|
Sat Sep 14, 2013 3:23 pm |
|
|
Astrochimp
Ensign
Joined: Mon Dec 26, 2011 8:41 am Posts: 206
|
Re: Mass Merch Script for testing
Archy wrote: Z-Bot would be standing down while an external script is running. I would try setting it up as a DAEMON in the doubletap menu, making the bot stand to attention automatically as soon as the script starts. Oh, currently I have it set as a Daemon in the xtra menu... I'll try the doubletap instead. Archy wrote: That is, if you need the z-bot awake while your script is running. I would like bbop to gather the mcics if possible... is that how it works? If I have bbop on while merching will it collect mcics?
Last edited by Astrochimp on Sat Sep 14, 2013 3:28 pm, edited 1 time in total.
|
Sat Sep 14, 2013 3:26 pm |
|
|
Archy
Immortal Op
Joined: Fri Jun 25, 2010 6:33 am Posts: 257 Location: Sydney Australia
|
Re: Mass Merch Script for testing
may need to go voice with this one Astro.. im in channel now if you want to come in.
_________________ Teamspeak3: 60.242.57.40:9987 Z-Bot does my dirty work!
|
Sat Sep 14, 2013 3:28 pm |
|
|
Crosby
Lieutenant Commander
Joined: Sun Jan 29, 2006 3:00 am Posts: 793 Location: Iowa
|
Re: Mass Merch Script for testing
Quote: after the cim, nothing happens Here is where I thought I had a problem...I would sit forever after the cim seemed over, waiting. It's taken over an hour to continue after it seemed the cim was done. - gathering the mcic's would be great, upgrading the best ports would be even better... I wanted to keep with the spirit of this script, as LoneStar started, as a public exercise in twx scripting. Thanks for your help!
_________________ #+++ The early bird may get the worm, but the second mouse gets the cheese. #---
|
Sat Sep 14, 2013 3:39 pm |
|
|
Astrochimp
Ensign
Joined: Mon Dec 26, 2011 8:41 am Posts: 206
|
Re: Mass Merch Script for testing
Crosby wrote: - gathering the mcic's would be great, upgrading the best ports would be even better... Oops, I was actually talking to Archy, my fault for mixing topics. Anyway his P-Driver (and z-bot runs ck haggle for mcic) does all that stuff... I guess I don't need this for now, but yeah it's good as a public exercise in scripting.
|
Sat Sep 14, 2013 4:16 pm |
|
|
|