www.ClassicTW.com
https://mail.black-squirrel.com/

qPlot include - Plots CF w/o triggers
https://mail.black-squirrel.com/viewtopic.php?f=15&t=32437
Page 1 of 1

Author:  Promethius [ Sun Oct 23, 2011 5:13 pm ]
Post subject:  qPlot include - Plots CF w/o triggers

To me it is easier than messing with set triggers to get the hops and plots in a course. Credit on the CURRENTANSILINE usage goes to EP from his qStats script challenge.

[Edit] Made it a little more useful and removed code that wasn't necessary.[/Edit]


The shortest path (14 hops, 56 turns) from sector 300 to sector 1500 is:
300 > (12268) > (4044) > (15408) > (11544) > (18471) > (16952) > (14595) >
(4128) > (18898) > (6368) > (12059) > (13421) > (19542) > (1500)


Computer command [TL=00:00:00]:[18491] (?=Help)? Q

<Computer deactivated

300 > 12268 > 4044 > 15408 > 11544 > 18471 > 16952 > 14595 > 4128 > 18898 > 6368
> 12059 > 13421 > 19542 > 1500

Hops: 14


Move to: 12268
Move to: 4044
Move to: 15408
Move to: 11544
Move to: 18471
Move to: 16952
Move to: 14595
Move to: 4128
Move to: 18898
Move to: 6368
Move to: 12059
Move to: 13421
Move to: 19542
Move to: 1500


The script:


# setup test plots
setVar $startPlot 300
setVar $endPlot 1500


:qPlot
setVar $hops 1
setVar $line ""
send "cf" $startPlot "*" $endPlot "*q"
waiton $startPlot & " >"
while (CURRENTANSILINE <> #13)
setVar $line $line & currentline
waitOn ""
end
stripText $line "("
stripText $line ")"
setVar $parseCnt 3
getword $line $moveTo[$hops] $parseCnt
while ($moveTo[$hops] <> 0)
add $parseCnt 2
add $hops 1
getword $line $moveTo[$hops] $parseCnt
end
subtract $hops 1

# display
echo ANSI_12 "**" & $line & "**"
echo ANSI_12 "Hops: " $hops "**"
setVar $i 1
while ($i <= $hops)
echo "* Move to: " $moveto[$i]
add $i 1
end

Author:  Promethius [ Sun Oct 23, 2011 6:47 pm ]
Post subject:  Re: qPlot include - Plots CF w/o triggers

... and if you prefer interrogation mode, it is the same script with one line change:

Code:
:qPlotInt
  setVar $hops 1
  setVar $line ""
  send "^f" $startPlot "*" $endPlot "*q"
  waiton $startPlot & " >"
  while (CURRENTANSILINE <> #13)
     setVar $line $line & currentline
     waitOn ""
  end
  stripText $line "("
  stripText $line ")"
setVar $parseCnt 3
  getword $line $moveTo[$hops] $parseCnt
  while ($moveTo[$hops] <> 0)
    add $parseCnt 2
    add $hops 1
    getword $line $moveTo[$hops] $parseCnt
  end
  subtract $hops 1

echo ANSI_12 "**" & $line & "**"
echo ANSI_12 "Hops: " $hops "**"
setVar $i 1
while ($i <= $hops)
     echo "* Move to: " $moveto[$i]
     add $i 1
end

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