I've been from infinite loop errors while trying to add a check to prevent multiple ships from going to the same station. Different methods were tried, the latest (and possibly cleanest) being this:
Code: Select all
...
* number of scrapers
$scrapers = array alloc: size=0
if not $home -> get local variable: name=$whLocVar
| append [THIS] to array $scrapers
| $home -> set local variable: name=$whLocVar value=$scrapers
else
| $scrapers = $home -> get local variable: name=$whLocVar
| append [THIS] to array $scrapers
| $home -> set local variable: name=$whLocVar value=$scrapers
end
...
* Run through station list, get ware info for next station in loop
while $count < $numStat
| $station = $stations[$count]
| * Skip current station if homebase, duh!
| do if $station == $home
| continue
| * Check if another scraper is servicing the current station
| $serviced = 0
| $scrapers = $home -> get local variable: name=$whLocVar
| for each $scraper in array $scrapers
| do if [THIS] == $scraper
| continue
| $orders = $scraper -> get orders string
| $stationStr = $station -> get name
| $stationFound = find position of pattern $stationStr in $orders
| if $stationFound > -1
| $serviced = 1
| break
| end
| end
| do if $serviced
| continue
Code: Select all
for each $scraper in array $scrapers
...
Thank you,
-lpa
EDIT : The first ship runs fine, the infinite loop check triggers when starting the second ship.