www.ClassicTW.com
http://www.classictw.com/

Second Mod for OCSBot
http://www.classictw.com/viewtopic.php?f=15&t=21703
Page 1 of 1

Author:  Thrawn [ Sat Mar 21, 2009 5:06 pm ]
Post subject:  Second Mod for OCSBot

I'm working on a second mod for our OCSBot called OCSBot_Patrol. This script will work in conjunction with our TradeWars Academy game. The idea is to get a list of sectors from sector 1 to StarDock, write to a text file, then go into the editor and enter each sector listed in the text file. It will set the beacon, remove any figs or mines from those sectors only. It is the same concept as those fedsweeper scripts, except it only does the route to and from StarDock. It is also my attempt to write a script that will get info and write to a text file, then use that data to perform functions.

I've been bombarding Promethius with questions on this mod and have probably worn him out ;) I'm encountering an error with the script and would like to try to figure out why. The way it works is this. OCSBot.ts runs in a session and loads our OCSBot_Recon script. When I load the OCSBot_Patrol script, it is to get the sectors to StarDock, then stop the OCSBot_Recon script, enter the editor, and edit those sectors that are in the list, where I can set the beacon, set the figs and mines to 0. When I load the OCSBot_Patrol script, it works right up to the point to the editor and then I get the following error:

Trade Wars 2002 Editor (?=Help) [?] : Script run-time error in 'OCSBOT_PATROL.TS': 'SentryList.txt' is not a decimal number, line 27

Script terminated: F:\games\TradeWars\twxproxy_ocs2a\Scripts\OCSBot\mods\OCSBot_patrol.ts

I have noticed that when it writes the sectors to the text file, there is a blank line at the end of the file. Is that the issue?

Here is the script code I am stuck on:

Code:

WaitOn "Editor (?="
fileExists $fileAvail $SentryFile
if ($fileAvail = FALSE)
    halt
end
   readtoarray $SentryFile $SentryCount
   setVar $i 2
   while ($i <= $SentryFile)
        send "s" 
        WaitFor "Sector number (0="
        send $SentryCount[$i]
        getLength $len $sentryCount[$i]
        if ($len < 5)
            send "*"
        end
        add $i 1           
end
send "n"
send $beacon "*"


Author:  Promethius [ Sat Mar 21, 2009 9:03 pm ]
Post subject:  Re: Second Mod for OCSBot

k, think I might see where it is and changed it below.

readtoarray $SentryFile $SentryCount
setVar $i 2
##### the following line is probably as it should have been, I most likely typed in the wrong var #####
while ($i <= $SentryCount)
send "s"
WaitFor "Sector number (0="
send $SentryCount[$i]
getLength $len $sentryCount[$i]
if ($len < 5)
send "*"
end
add $i 1
end

Author:  V'Ger [ Sat Mar 21, 2009 9:10 pm ]
Post subject:  Re: Second Mod for OCSBot

Thrawn,

That could very well be the problem... what you might want to do is put a pause after the readtoarray command and then do a dump of the variables, and see what is actually in the array, that should let you know for sure if it is erroring out on a blank record.

Author:  Thrawn [ Sat Mar 21, 2009 9:50 pm ]
Post subject:  Re: Second Mod for OCSBot

Ok Promethius, I have made the change according to your direction. Fixed the previous error. The script goes into the editor, presses "s" for sector editor, inputs the number from the list, then presses "n" to enter the beacon, then presses "x" to return to the tedit. The only problem is it goes to enter a 5 character sector number (ex: 12095) and next thing is it is back at the main tedit screen. The 4 character sectors work fine, just the 5 character sectors.

Other question I'd like to ask is see in the script where I return to the game. Is there a "shorter" way to tell the script anytime it sees [Pause] then enter is pressed, rather than typing out the multiple lines I have done?

Here's what I have now (section snip):

Code:
   readtoarray $SentryFile $SentryCount
   setVar $i 2
   while ($i <= $SentryCount)
        send "s" 
        WaitFor "Sector number (0="
        send $SentryCount[$i]
        getLength $len $sentryCount[$i]
        if ($len < 5)
            send "*"
        end
        send "n"
        waitfor "Enter new Marker Beacon:"
        send $beacon "*"
        send "x"
        add $i 1           
end
send "x"
send "q"
waitfor "Selection"
send "$"
send GAME
waitfor "[Press Space or Enter to continue]"
send "*"
waitfor "[Pause]"
send "*"
waitfor "Enter your choice:"
send "t*"
waitfor "Show today's log? (Y/N) [N]"
send "n"
waitfor "[Pause]"
send "*"
waitfor "Password?"
send Password "*"
waitfor "[Pause]"
send "*"
Send "*"
halt


Author:  Promethius [ Sat Mar 21, 2009 10:07 pm ]
Post subject:  Re: Second Mod for OCSBot

Change: getLength $len $sentryCount[$i]
to: getLength $sentryCount[$i] $len

That will fix the length error. I have a tendency for some reason to transpose that command.

Author:  Thrawn [ Sat Mar 21, 2009 10:36 pm ]
Post subject:  Re: Second Mod for OCSBot

Promethius wrote:
Change: getLength $len $sentryCount[$i]
to: getLength $sentryCount[$i] $len

That will fix the length error. I have a tendency for some reason to transpose that command.


That was it. Thank you once again for all your help.

Author:  Thrawn [ Sun Mar 22, 2009 1:24 am ]
Post subject:  Re: Second Mod for OCSBot

In my mod I am writing, it gets the course from Sector 1 to StarDock. I noticed in one test game I run, the OCSBot Recon follows the same path from Sector 1 to StarDock and back. For example, it has the course: 5, 5997, 2338, 12065, 3253 (StarDock). It enters each of these sectors to and from.

In a second test game I noticed my OCSBot Recon takes path to StarDock, but on the return it changes course midway to Sector 1. So the course is: 2, 8, 3745, 17230, 2538, 7288, 158, 12654 (StarDock). On the return to Sector 1, it hits 158, 7288, 2538, and instead of going to 17230, it takes an alternate route and ends up at Sector 1 (backdoor perhaps?)

I am wondering if someone may be able to tell me why that could be?

Author:  Yop_Solo [ Sun Mar 22, 2009 9:25 am ]
Post subject:  Re: Second Mod for OCSBot

Maybe your script take a shorter way...
If you want to have the same path, put the values sector into an array and reverse it...

Author:  Singularity [ Sun Mar 22, 2009 10:11 am ]
Post subject:  Re: Second Mod for OCSBot

Quote:
I am wondering if someone may be able to tell me why that could be?


You using a CF plot? If so, then it's because there's a backdoor that creates a quicker route in that direction. The path to dock and the path from dock are not always the same.

Author:  Thrawn [ Sun Mar 22, 2009 10:57 am ]
Post subject:  Re: Second Mod for OCSBot

Singularity wrote:
Quote:
I am wondering if someone may be able to tell me why that could be?


You using a CF plot? If so, then it's because there's a backdoor that creates a quicker route in that direction. The path to dock and the path from dock are not always the same.


The exact plot I am using is:

send "^f1*" $sd "*q"
waitfor "TO > " & $SD

It produced the same as if I used the "cf" method. I just thought it weird in one game it used the same sectors to and from, and another it used the backdoor to return to sector 1. I'm fine with it in any event. It provides a clear path from sector 1 to StarDock only, does not do adjacent sectors like other sweeper scripts do.

Author:  Singularity [ Sun Mar 22, 2009 5:35 pm ]
Post subject:  Re: Second Mod for OCSBot

Nod. That method is the same as a CF plot. It uses your in-game avoids to build a course. It is vulnerable to back doors.

Author:  Thrawn [ Sun Mar 22, 2009 6:34 pm ]
Post subject:  Re: Second Mod for OCSBot

Understood. I just happened to notice it during a final test run before I put it together and upload/update OCSBot. I was excited to have this mod work, but it was strange seeing this event happen. I started disecting my code thinking I made a mistake. Hence i had to ask before I deleted it and restarted from scratch.

Thanks Sing for the info.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/