<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:blogChannel="http://backend.userland.com/blogChannelModule" >
  <channel>
  <title>cc-memo</title>
  <link>https://cct.blog.shinobi.jp/</link>
  <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="https://cct.blog.shinobi.jp/RSS/" />
  <description>Computer Craft  のメモ</description>
  <lastBuildDate>Sun, 15 Jun 2014 01:26:29 GMT</lastBuildDate>
  <language>ja</language>
  <copyright>© Ninja Tools Inc.</copyright>
  <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" />

    <item>
    <title>build craftの水門とタートルを使ったバケツフィラー（動画有り）</title>
    <description>
    <![CDATA[<img src="//cct.blog.shinobi.jp/File/2014-06-15_09.06.48.png" alt="" /><br />
・空バケツで液体を汲む作業の自動化。バケツフィラーのタートル版。<br />
・前回作った「autoRefuel」で面倒くさかった、溶岩バケツの補充を楽にする為に作成。<br />
<span style="color: #ff0000;">・この &rdquo;システム&rdquo; から、どこかの「autoRefuel」施設までバケツを運ぶ部分は</span><span style="color: #ff0000;">未完なので、<br />
　まだ面倒くさいままですが。</span><br />
・溶岩以外の液体でも使用可能。Build Craftのオイルとか。<br />
・作っている途中で「<a href="http://hevohevo.hatenablog.com" title="" target="_blank">Minecraftとタートルと僕</a>」の中の人に、<br />
　<a href="http://forum.minecraftuser.jp/viewtopic.php?t=17132" title="" target="_blank">MoreTurtles</a>の「液体タートル」を使う方法を教えていただいたのですが、<br />
　作りかけを捨てるのももったいないので、意地で作成。<br />
　（早くこれを終わらせてえさやりタートル使いたい、、、）<br />
<br />
【構成要素の説明】<br />
<img src="//cct.blog.shinobi.jp/File/33fbc813.jpeg" alt="" /><br /><br /><a href="https://cct.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/build%20craft%E3%81%AE%E6%B0%B4%E9%96%80%E3%81%A8%E3%82%BF%E3%83%BC%E3%83%88%E3%83%AB%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%9F%E3%83%90%E3%82%B1%E3%83%84" target="_blank">つづきはこちら</a>]]>
    </description>
    <category>未選択</category>
    <link>https://cct.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/build%20craft%E3%81%AE%E6%B0%B4%E9%96%80%E3%81%A8%E3%82%BF%E3%83%BC%E3%83%88%E3%83%AB%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%9F%E3%83%90%E3%82%B1%E3%83%84</link>
    <pubDate>Sun, 15 Jun 2014 04:22:29 GMT</pubDate>
    <guid isPermaLink="false">cct.blog.shinobi.jp://entry/17</guid>
  </item>
    <item>
    <title>filer（ファイラー）</title>
    <description>
    <![CDATA[標準の ls が遅いので、単に早いだけの ls を作ろうとしていたはずだったのだが、ついつい機能を追加してしまい、ファイラーのようなものになってしまったので、filerという名前にした。<br />
※どうでもいいけど、得られる便利さに見合わないぐらいソースが長い気がする、、、<br />
<br />
画像で説明<br />
<img src="//cct.blog.shinobi.jp/File/2014-06-02_02.00.02.png" alt="" /> <br />
filerコマンドを実行すると、カレントディレクトリのファイルとディレクトリが、画像のように表示される。<br />
・qキーを押すと、filerコマンドを終了する。<br />
・カーソルの上下でページを切り替えることができる。<br />
　&rArr;５ページ目を表示した後で、４ページ目に戻る、という操作が可能。<br />
・この状態でカーソルキーの右を押すと、、、<br />
<br />
<img src="//cct.blog.shinobi.jp/File/2014-06-02_02.06.07.png" alt="" /> <br />
画像のように、ファイル／ディレクトリを選択する矢印（--&gt;）が表示される。<br />
・カーソルキーの左を押すと、最初の状態（矢印が表示されない状態）に戻る。<br />
・カーソルキーの右を押すことで、矢印の左側にある&rdquo;アクション&rdquo;を切り替える事ができる。<br />
　以下の&rdquo;アクション&rdquo;が選択できる。<br />
　・cd　　 ディレクトリ移動（選択項目がディレクトリの場合）<br />
　・edit　　選択したファイルを edit コマンドで開く（選択項目がファイルの場合）<br />
　・delete　選択したファイルを削除する<br />
　・rename　選択したファイルのファイル名を変更する<br />
　・copy　　選択したファイルをコピーする。（同一ディレクトリ内でのコピー専用）<br />
　・move　　選択したファイルを移動、または、コピーする。<br />
　　（別のディレクトリに移動／コピーする場合に使用）<br />
　・[other]　任意のコマンドを実行する。<br />
　　　コマンドを入力する場面で、カーソルキーの上を押すと、<br />
　　　選択したファイル／ディレクトリ名が表示され、それを編集できるので、少し楽かも。<br /><br /><a href="https://cct.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/filer%EF%BC%88%E3%83%95%E3%82%A1%E3%82%A4%E3%83%A9%E3%83%BC%EF%BC%89" target="_blank">つづきはこちら</a>]]>
    </description>
    <category>未選択</category>
    <link>https://cct.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/filer%EF%BC%88%E3%83%95%E3%82%A1%E3%82%A4%E3%83%A9%E3%83%BC%EF%BC%89</link>
    <pubDate>Sun, 01 Jun 2014 17:49:24 GMT</pubDate>
    <guid isPermaLink="false">cct.blog.shinobi.jp://entry/16</guid>
  </item>
    <item>
    <title>tr (turtle runner)</title>
    <description>
    <![CDATA[<img src="//cct.blog.shinobi.jp/File/2014-05-19_04.35.34.png" alt="" /> <br />
・trというコマンドを作ってみた。<br />
・いつもの俺々フレームワークの「ミニ言語」を使ってタートルを動かす為のプログラム。<br />
・ちょっとした用事の為にタートルを使いたいと思っても、<br />
　わざわざその為のプログラムを書くは面倒くさい、という場合に<br />
　このtrコマンドを使って、使い捨てのプログラムを作って走らせると良いかもしれない。<br />
　ファイルに保存することも可能。<br />
　そのファイルをeditで編集して、trで実行させることも可能。<br />
　（但しまだ改行は非対応、、、だと思う）<br />
・ヘルプ機能付き。<br />
<br />
　tr --help<br />
<br />
　というように、trコマンドの後に「--help」オプションを付けて実行すると、<br />
　linuxとかの「manページ」風のヘルプが表示される。<br />
<br />
　また、「ミニ言語」のスクリプト入力中に、<br />
　どんなコマンドが有るか忘れてしまった場合は、スクリプト中に「?」と入力し、<br />
　Enterキーを押すことでもヘルプが表示される。<br />
　ヘルプ終了後、元のスクリプトの作成を再開することができる。<br />
・もう少し盛り込みたい機能もあるのだが、とりあえず投稿。<br />
<br />
画像で説明。<br />
<img src="//cct.blog.shinobi.jp/File/2014-05-19_03.50.27.png" alt="" /> <br />
trと打つと上記のメッセージが表示されるので、ここにタートルを動かす手順を記入する。<br />
この例では<br />
((ffr)4)2<br />
と入力しているが、これは<br />
前進、前進、右に９０度回転<br />
を８回繰り返す、という意味。<br /><br /><a href="https://cct.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/tr%20-turtle%20runner-" target="_blank">つづきはこちら</a>]]>
    </description>
    <category>未選択</category>
    <link>https://cct.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/tr%20-turtle%20runner-</link>
    <pubDate>Sun, 18 May 2014 19:32:21 GMT</pubDate>
    <guid isPermaLink="false">cct.blog.shinobi.jp://entry/14</guid>
  </item>
    <item>
    <title>autoRefuel</title>
    <description>
    <![CDATA[タートルの給油、面倒ですよね。<br />
<img src="//cct.blog.shinobi.jp/File/2014-05-14_03.33.26.png" alt="" /><br />
<br />
そこで今回ご紹介したいのが、この、<br />
<br />
<iframe width="600" height="338" src="http://www.youtube.com/embed/8abg6NEl1cU" frameborder="0" allowfullscreen=""></iframe><br /><br /><a href="https://cct.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/autorefuel" target="_blank">つづきはこちら</a>]]>
    </description>
    <category>未選択</category>
    <link>https://cct.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/autorefuel</link>
    <pubDate>Thu, 15 May 2014 19:44:44 GMT</pubDate>
    <guid isPermaLink="false">cct.blog.shinobi.jp://entry/13</guid>
  </item>
    <item>
    <title>バグ取り</title>
    <description>
    <![CDATA[<span style="color: #ff0000;">（注：バグまだ取れてません、、、）</span><br />
<br />
『テスト用拠点６号』。<br />
<img src="//cct.blog.shinobi.jp/File/2014-05-13_20.45.17.png" alt="" /> <br />
<span style="color: #000000;">『遠征どこでもドア』と『ChickenChunks』を愛用しています。</span><br />
<br />
今回はバグ取りをしてゆきます。<br />
<img src="//cct.blog.shinobi.jp/File/2014-05-13_20.57.49.png" alt="" /> <br />
タートル同士で共食いをしてしまう件。掘られたタートルが持っていたアイテムが散らばってしまうので、デフォルトでは行えないようにする。&lt;&lt;&lt; 1 &gt;&gt;&gt;<br />
<br />
目の前にブロックが有って、それがタートルではない場合は掘っても良い。という条件にした。<br />
（turtle.detect() == true かつ、peripheral.getType("front") が "turtle" を返さない場合。）<br />
<br />
turtle.detect()を条件に加えていないと、<br />
判定しようとしている場所に、タートルが移動して入り込んできているが、まだ止まっていない状態を検知できずに、タートルをdig()してしまう。<br />
この時、peripheral.getType("front") 等が "turtle" を返さない為。<br />
<br />
でも、溶岩や水源等もturtle.detect() == falseなので、それらを掘って排除することが出来なくなってしまった。<br />
<br />
拠点を作ろうとした場所に溶岩の池があったとしても、これまでは、溶岩を掘って消し去ることが出来たのだが、これからどうしたものか、、、（拠点を作る場合は、他のタートルを壊しても良い、というふうに割り切るのも何か微妙。）<br />
<br />
次、<br /><br /><a href="https://cct.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/%E3%83%90%E3%82%B0%E5%8F%96%E3%82%8A" target="_blank">つづきはこちら</a>]]>
    </description>
    <category>未選択</category>
    <link>https://cct.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/%E3%83%90%E3%82%B0%E5%8F%96%E3%82%8A</link>
    <pubDate>Tue, 13 May 2014 12:39:42 GMT</pubDate>
    <guid isPermaLink="false">cct.blog.shinobi.jp://entry/12</guid>
  </item>
    <item>
    <title>昨晩のブランチマイニング結果</title>
    <description>
    <![CDATA[バグ取りする気が起きないので、ちょっとお茶を濁してみる。<br />
<img src="//cct.blog.shinobi.jp/File/2014-05-12_19.54.54.png" alt="" />『テスト用拠点４号』。マイニングタートル８機で採掘。<br />
上段の４機は行儀良く待機していてくれたが、エラーが出てた。<br />
<img src="//cct.blog.shinobi.jp/File/2014-05-12_19.55.37.png" alt="" /> <br />
下段の４機には、fuelLevelが2000以下の時にスタート地点で中断するコードが入っていなかった為、各機好き勝手な場所で燃料切れ。<br />
<img src="//cct.blog.shinobi.jp/File/2014-05-12_20.10.40.png" alt="" /><br />
別のタートルに掘られてチェストに収まってるやつとかも居た。<br />
<img src="//cct.blog.shinobi.jp/File/2014-05-12_20.11.30.png" alt="" /> <br />
成績はこんな感じ。<br />
<img src="//cct.blog.shinobi.jp/File/2014-05-12_21.25.55.png" alt="" /><br /><br /><a href="https://cct.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/%E6%98%A8%E6%99%A9%E3%81%AE%E3%83%96%E3%83%A9%E3%83%B3%E3%83%81%E3%83%9E%E3%82%A4%E3%83%8B%E3%83%B3%E3%82%B0%E7%B5%90%E6%9E%9C" target="_blank">つづきはこちら</a>]]>
    </description>
    <category>未選択</category>
    <link>https://cct.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/%E6%98%A8%E6%99%A9%E3%81%AE%E3%83%96%E3%83%A9%E3%83%B3%E3%83%81%E3%83%9E%E3%82%A4%E3%83%8B%E3%83%B3%E3%82%B0%E7%B5%90%E6%9E%9C</link>
    <pubDate>Mon, 12 May 2014 12:59:14 GMT</pubDate>
    <guid isPermaLink="false">cct.blog.shinobi.jp://entry/11</guid>
  </item>
    <item>
    <title>mining （ブランチマイニング）</title>
    <description>
    <![CDATA[<img src="//cct.blog.shinobi.jp/File/mining_img.jpg" alt="" /> <br />
<br />
mining<br />
ブランチマイニングを行うプログラム。<br /><br /><a href="https://cct.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/mining%20%EF%BC%88%E3%83%96%E3%83%A9%E3%83%B3%E3%83%81%E3%83%9E%E3%82%A4%E3%83%8B%E3%83%B3%E3%82%B0%EF%BC%89" target="_blank">つづきはこちら</a>]]>
    </description>
    <category>未選択</category>
    <link>https://cct.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/mining%20%EF%BC%88%E3%83%96%E3%83%A9%E3%83%B3%E3%83%81%E3%83%9E%E3%82%A4%E3%83%8B%E3%83%B3%E3%82%B0%EF%BC%89</link>
    <pubDate>Thu, 08 May 2014 14:59:24 GMT</pubDate>
    <guid isPermaLink="false">cct.blog.shinobi.jp://entry/10</guid>
  </item>
    <item>
    <title>nekoPosi() / nekoNega()</title>
    <description>
    <![CDATA[<iframe width="400" height="225" src="http://www.youtube.com/embed/2lMCYawDoTw" frameborder="0" allowfullscreen=""></iframe> <br />
<br />
lib_neko_0.1.1<br />
マイニングタートルで、ブランチマイニングをする時などに使用する、<br />
必要なブロックだけを根こそぎ採集するプログラム（ライブラリ）。<br /><br /><a href="https://cct.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/nekoposi_nekonega" target="_blank">つづきはこちら</a>]]>
    </description>
    <category>未選択</category>
    <link>https://cct.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/nekoposi_nekonega</link>
    <pubDate>Wed, 07 May 2014 08:12:16 GMT</pubDate>
    <guid isPermaLink="false">cct.blog.shinobi.jp://entry/9</guid>
  </item>
    <item>
    <title>kyoten／採掘・移動に失敗する場合の考慮</title>
    <description>
    <![CDATA[kyoten<br />
地下深くに拠点（と称した適当な大きさの部屋）を作るプログラム。<br />
ブランチマイニングの拠点として使用する場合は、高度80以下の場所から開始する必要有り。<br />
<br />
lib_turtle_0.2.1<br />
毎度の俺々フレームワーク<br />
以下は、lib_turtle_0.2.0からの更新点<br />
<br />
[採掘時に砂とか砂利が落ちてくる場合を考慮して処理を追加した]<br />
上を掘る場合<br />
砂や砂利が崩れてくる場合があるので、掘った方向のブロックがなくなるまで、採掘を繰り返す。<br />
<br />
正面を掘る場合<br />
砂や砂利が崩れてくる場合があるので、掘った方向のブロックがなくなるまで、採掘を繰り返す。<br />
<br />
①はsleep(0)の間隔で目の前のブロックがなくなるまでdig()することでクリア出来るが、、、<br />
<br />
①<br />
　砂<br />
　砂<br />
　砂<br />
亀石<br />
石石石<br /><br /><a href="https://cct.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/kyoten%EF%BC%8F%E6%8E%A1%E6%8E%98%E3%83%BB%E7%A7%BB%E5%8B%95%E3%81%AB%E5%A4%B1%E6%95%97%E3%81%99%E3%82%8B%E5%A0%B4%E5%90%88%E3%81%AE%E8%80%83%E6%85%AE" target="_blank">つづきはこちら</a>]]>
    </description>
    <category>未選択</category>
    <link>https://cct.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/kyoten%EF%BC%8F%E6%8E%A1%E6%8E%98%E3%83%BB%E7%A7%BB%E5%8B%95%E3%81%AB%E5%A4%B1%E6%95%97%E3%81%99%E3%82%8B%E5%A0%B4%E5%90%88%E3%81%AE%E8%80%83%E6%85%AE</link>
    <pubDate>Fri, 02 May 2014 09:20:47 GMT</pubDate>
    <guid isPermaLink="false">cct.blog.shinobi.jp://entry/8</guid>
  </item>
    <item>
    <title>archer3</title>
    <description>
    <![CDATA[archer2をさらに改良。繰り返し処理も「ミニ言語」？内で行えるようにした。<br />
debug.logには、かなりお世話になった。<br />
<br />
<br />
<span style="color: #ff0000;">lib_log</span><br />

<div>LOG_FILE_NAME = "debug.log";</div>
<div></div>
<div>function log(txt)</div>
<div>&nbsp; local hFile;</div>
<div>&nbsp; if fs.exists(LOG_FILE_NAME) then</div>
<div>&nbsp; &nbsp; hFile = fs.open(LOG_FILE_NAME, "a");</div>
<div>&nbsp; else</div>
<div>&nbsp; &nbsp; hFile = fs.open(LOG_FILE_NAME, "w");</div>
<div>&nbsp; end</div>
<div>&nbsp; hFile.writeLine(txt);</div>
<div>&nbsp; hFile.close();</div>
<div>end<br />
<span style="color: #ff0000;"><br style="color: #000000;" /><br style="color: #000000;" />lib_turtle_0.2.0</span><br />

<div>
<div>dofile("lib_log");</div>
<div></div>
<div>local function myPlace(para1)</div>
<div>&nbsp; if para1 == 0 then</div>
<div>&nbsp; &nbsp; turtle.placeUp();</div>
<div>&nbsp; elseif para1 == 1 then</div>
<div>&nbsp; &nbsp; turtle.place();</div>
<div>&nbsp; elseif para1 == 2 then</div>
<div>&nbsp; &nbsp; turtle.placeDown();</div>
<div>&nbsp; end</div>
<div>end</div>
<div></div>
<div>local function myThrow(para1, para2)</div>
<div>&nbsp; if para1 == 0 then</div>
<div>&nbsp; &nbsp; turtle.dropUp(para2);</div>
<div>&nbsp; elseif para1 == 1 then</div>
<div>&nbsp; &nbsp; turtle.drop(para2);</div>
<div>&nbsp; elseif para1 == 2 then</div>
<div>&nbsp; &nbsp; turtle.dropDown(para2);</div>
<div>&nbsp; end</div>
<div>end</div>
<div></div>
<div>local function myExcavate(para1)</div>
<div>&nbsp; if para1 == 0 then</div>
<div>&nbsp; &nbsp; turtle.digUp();</div>
<div>&nbsp; elseif para1 == 1 then</div>
<div>&nbsp; &nbsp; turtle.dig();</div>
<div>&nbsp; elseif para1 == 2 then</div>
<div>&nbsp; &nbsp; turtle.digDown();</div>
<div>&nbsp; end</div>
<div>end</div>
<div></div>
<div>local function myZzz(para1)</div>
<div>&nbsp; sleep(para1 / 1000);</div>
<div>end</div>
<div></div>
<div>local function myOutput(para1, para2)</div>
<div>&nbsp; local dir = { [0] = "top", &nbsp;[1] = "front", [2] = "bottom",</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [3] = "left", [4] = "back", &nbsp;[5] = "right" };</div>
<div>&nbsp; if para2 == 1 then</div>
<div>&nbsp; &nbsp; rs.setOutput(dir[para1], true);</div>
<div>&nbsp; else</div>
<div>&nbsp; &nbsp; rs.setOutput(dir[para1], false);</div>
<div>&nbsp; end</div>
<div>end</div>
<div></div>
<div>local cmdInfo =</div>
<div>{</div>
<div>&nbsp; f = { paraCnt = 0, func = turtle.forward; &nbsp; }, -- [f]orward</div>
<div>&nbsp; b = { paraCnt = 0, func = turtle.back; &nbsp; &nbsp; &nbsp;}, -- [b]ack</div>
<div>&nbsp; l = { paraCnt = 0, func = turtle.turnLeft; &nbsp;}, -- turn [l]eft</div>
<div>&nbsp; r = { paraCnt = 0, func = turtle.turnRight; }, -- turn [r]ight</div>
<div>&nbsp; u = { paraCnt = 0, func = turtle.Up; &nbsp; &nbsp; &nbsp; &nbsp;}, -- [u]p</div>
<div>&nbsp; d = { paraCnt = 0, func = turtle.Down; &nbsp; &nbsp; &nbsp;}, -- [d]own</div>
<div>&nbsp; s = { paraCnt = 1, func = turtle.select; &nbsp; &nbsp;}, -- [s]elect</div>
<div>&nbsp; p = { paraCnt = 1, func = myPlace; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}, -- [p]lace</div>
<div>&nbsp; t = { paraCnt = 2, func = myThrow; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}, -- [t]hrow = drop</div>
<div>&nbsp; e = { paraCnt = 1, func = myExcavate; &nbsp; &nbsp; &nbsp; }, -- [e]xcavate = dig</div>
<div>&nbsp; z = { paraCnt = 1, func = myZzz; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}, -- [z]zz = sleep</div>
<div>&nbsp; o = { paraCnt = 2, func = myOutput; &nbsp; &nbsp; &nbsp; &nbsp; }, -- set [o]utput (redstone)&nbsp;</div>
<div>};</div>
<div></div>
<div>local function getParam(command, idx)</div>
<div>&nbsp; local buff = "";</div>
<div>&nbsp; local ch = "";</div>
<div></div>
<div>&nbsp; for i = idx, command:len() do</div>
<div>&nbsp; &nbsp; ch = command:sub(i, i);</div>
<div>&nbsp; &nbsp; --log("getParam i = " .. i .. " / ch =[" .. ch .. "]");</div>
<div>&nbsp; &nbsp; if ch == "," then</div>
<div>&nbsp; &nbsp; &nbsp; if buff == "" then</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; return nil, i + 1;</div>
<div>&nbsp; &nbsp; &nbsp; else</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; return tonumber(buff), i + 1;</div>
<div>&nbsp; &nbsp; &nbsp; end</div>
<div>&nbsp; &nbsp; elseif nil ~= string.find("0123456789", ch, 1, true) then</div>
<div>&nbsp; &nbsp; &nbsp; buff = buff .. ch;</div>
<div>&nbsp; &nbsp; else</div>
<div>&nbsp; &nbsp; &nbsp; if buff ~= "" then</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; return tonumber(buff), i;</div>
<div>&nbsp; &nbsp; &nbsp; end</div>
<div>&nbsp; &nbsp; end</div>
<div>&nbsp; end</div>
<div>&nbsp; if buff == "" then</div>
<div>&nbsp; &nbsp; return nil, command:len() + 1;</div>
<div>&nbsp; else</div>
<div>&nbsp; &nbsp; return tonumber(buff), command:len() + 1;</div>
<div>&nbsp; end</div>
<div>end</div>
<div></div>
<div>local function get1Cmd(command, idx)</div>
<div>&nbsp; local cmd = string.sub(command, idx, idx);</div>
<div>&nbsp; local para1, para2, nextIdx, paraCnt;</div>
<div></div>
<div>&nbsp; --log(idx .. " / " .. cmd);</div>
<div></div>
<div>&nbsp; if nil ~= cmdInfo[cmd] then</div>
<div>&nbsp; &nbsp; paraCnt = cmdInfo[cmd].paraCnt;</div>
<div>&nbsp; else</div>
<div>&nbsp; &nbsp; --log("unknown command [" .. cmd .. "]");</div>
<div>&nbsp; &nbsp; error("unknown command [" .. cmd .. "]");</div>
<div>&nbsp; end</div>
<div></div>
<div>&nbsp; if -1 == paraCnt then</div>
<div>&nbsp; &nbsp; return nil, nil, nil, idx + 1;</div>
<div>&nbsp; elseif paraCnt == 0 then</div>
<div>&nbsp; &nbsp; return cmd, nil, nil, idx + 1;</div>
<div>&nbsp; elseif paraCnt == 1 then</div>
<div>&nbsp; &nbsp; para1, nextIdx = getParam(command, idx + 1);</div>
<div>&nbsp; &nbsp; return cmd, para1, nil, nextIdx;</div>
<div>&nbsp; elseif paraCnt == 2 then</div>
<div>&nbsp; &nbsp; para1, nextIdx = getParam(command, idx + 1);</div>
<div>&nbsp; &nbsp; para2, nextIdx = getParam(command, nextIdx);</div>
<div>&nbsp; &nbsp; return cmd, para1, para2, nextIdx;</div>
<div>&nbsp; end</div>
<div>end</div>
<div></div>
<div>local function checkLoop(command)</div>
<div>&nbsp; local kBgn = {""};</div>
<div>&nbsp; local loopInfo = {};</div>
<div></div>
<div>&nbsp; local ch, repeatCnt, nextIdx, kBgnIdx;</div>
<div>&nbsp; for i = 1, command:len() do</div>
<div>&nbsp; &nbsp; ch = command:sub(i, i);</div>
<div>&nbsp; &nbsp; if "(" == ch then</div>
<div>&nbsp; &nbsp; &nbsp; table.insert(kBgn, i);</div>
<div>&nbsp; &nbsp; elseif ")" == ch then</div>
<div>&nbsp; &nbsp; &nbsp; repeatCnt, nextIdx = getParam(command, i + 1);</div>
<div>&nbsp; &nbsp; &nbsp; loopInfo[i] = { beginIdx &nbsp; = table.remove(kBgn),</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; endIdx &nbsp; &nbsp; = i,</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nextIdx &nbsp; &nbsp;= nextIdx,</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; repeatCnt &nbsp;= repeatCnt,</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentCnt = 0 };</div>
<div>&nbsp; &nbsp; &nbsp; --log("loopInfo[" .. i .. "]");</div>
<div>&nbsp; &nbsp; &nbsp; --log(" &nbsp;beginIdx &nbsp; = " .. loopInfo[i].beginIdx);</div>
<div>&nbsp; &nbsp; &nbsp; --log(" &nbsp;endIdx &nbsp; &nbsp; = " .. loopInfo[i].endIdx);</div>
<div>&nbsp; &nbsp; &nbsp; --log(" &nbsp;nextIdx &nbsp; &nbsp;= " .. loopInfo[i].nextIdx);</div>
<div>&nbsp; &nbsp; &nbsp; --log(" &nbsp;repeatCnt &nbsp;= " .. loopInfo[i].repeatCnt);</div>
<div>&nbsp; &nbsp; &nbsp; --log(" &nbsp;currentCnt = " .. loopInfo[i].currentCnt);</div>
<div>&nbsp; &nbsp; &nbsp; i = nextIdx;</div>
<div>&nbsp; &nbsp; end</div>
<div>&nbsp; end</div>
<div>&nbsp; return loopInfo;</div>
<div>end</div>
<div></div>
<div>function doCommand(command)</div>
<div><br />
&nbsp; command = command .. " ";</div>
<div>&nbsp; local loopInfo = checkLoop(command);</div>
<div>&nbsp; --for i, dat in pairs(loopInfo) do</div>
<div>&nbsp; &nbsp; --log("check loopInfo")</div>
<div>&nbsp; &nbsp; --log(" &nbsp;i = " .. i);</div>
<div>&nbsp; &nbsp; --log(" &nbsp;" .. dat.beginIdx .. " / " .. dat.endIdx .. " / " .. dat.repeatCnt);</div>
<div>&nbsp; --end</div>
<div></div>
<div>&nbsp; local cmd, para1, para2, nextIdx, ch;</div>
<div></div>
<div>&nbsp; local i = 1;</div>
<div>&nbsp; while true do</div>
<div>&nbsp; &nbsp; ch = command:sub(i, i);</div>
<div>&nbsp; &nbsp; --log("doCommand idx = " .. i .. " [" .. ch .. "]");</div>
<div>&nbsp; &nbsp; if ")" == ch then</div>
<div>&nbsp; &nbsp; &nbsp; --log("i = " .. i);</div>
<div>&nbsp; &nbsp; &nbsp; --log( &nbsp; loopInfo[i].beginIdx .. " / " .. loopInfo[i].endIdx .. " / "</div>
<div>&nbsp; &nbsp; &nbsp; -- &nbsp; &nbsp;.. loopInfo[i].nextIdx &nbsp;.. " / " .. loopInfo[i].repeatCnt);</div>
<div>&nbsp; &nbsp; &nbsp; loopInfo[i].currentCnt = loopInfo[i].currentCnt + 1;</div>
<div>&nbsp; &nbsp; &nbsp; if loopInfo[i].repeatCnt &lt;= loopInfo[i].currentCnt then</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; loopInfo[i].currentCnt = 0;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; i = loopInfo[i].nextIdx;</div>
<div>&nbsp; &nbsp; &nbsp; else</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; i = loopInfo[i].beginIdx;</div>
<div>&nbsp; &nbsp; &nbsp; end</div>
<div>&nbsp; &nbsp; elseif " " == ch then</div>
<div>&nbsp; &nbsp; &nbsp; i = i + 1;</div>
<div>&nbsp; &nbsp; elseif "\n" == ch then</div>
<div>&nbsp; &nbsp; &nbsp; i = i + 1;</div>
<div>&nbsp; &nbsp; elseif "(" == ch then</div>
<div>&nbsp; &nbsp; &nbsp; i = i + 1;</div>
<div>&nbsp; &nbsp; else</div>
<div>&nbsp; &nbsp; &nbsp; cmd, para1, para2, nextIdx = get1Cmd(command, i);</div>
<div>&nbsp; &nbsp; &nbsp; --log(" &nbsp;nextIdx = " .. nextIdx);</div>
<div>&nbsp; &nbsp; &nbsp; i = nextIdx;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; if cmd ~= nil then</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; cmdInfo[cmd].func(para1, para2);</div>
<div>&nbsp; &nbsp; &nbsp; end</div>
<div>&nbsp; &nbsp; end</div>
<div>&nbsp; &nbsp; if command:len() &lt;= i then</div>
<div>&nbsp; &nbsp; &nbsp; break;</div>
<div>&nbsp; &nbsp; end</div>
<div>&nbsp; end</div>
<div>end</div>
<br />
<br />

<div><span style="color: #ff0000;">archer3</span></div>
</div>
</div>
<div>
<div>dofile("lib_turtle_0.2.0");</div>
<div></div>
<div>local NUM_SHOT = 3;</div>
<div>local NUM_STEP = 4;</div>
<div>local SHOT_WAIT = 0.2 * 1000;</div>
<div></div>
<div>local cmd =&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp;"ll"</div>
<div>&nbsp; .. "\n("</div>
<div>&nbsp; .. "\n &nbsp;s2 p0 s3 t0," .. NUM_SHOT</div>
<div>&nbsp; .. "\n &nbsp;("</div>
<div>&nbsp; .. "\n &nbsp; &nbsp;o0,1"</div>
<div>&nbsp; .. "\n &nbsp; &nbsp;z" .. SHOT_WAIT</div>
<div>&nbsp; .. "\n &nbsp; &nbsp;o0,0"</div>
<div>&nbsp; .. "\n &nbsp; &nbsp;z" .. SHOT_WAIT</div>
<div>&nbsp; .. "\n &nbsp;)" .. NUM_SHOT</div>
<div>&nbsp; .. "\n &nbsp;s2 e0 (b)4"</div>
<div>&nbsp; .. "\n)" .. NUM_STEP;</div>
<div></div>
<div>print("cmd:" .. cmd);</div>
<div></div>
<div>doCommand(cmd);</div>
<div></div>
</div>]]>
    </description>
    <category>未選択</category>
    <link>https://cct.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/archer3</link>
    <pubDate>Thu, 01 May 2014 09:33:53 GMT</pubDate>
    <guid isPermaLink="false">cct.blog.shinobi.jp://entry/7</guid>
  </item>

    </channel>
</rss>