http://www.computercraft.info/wiki/index.php?title=Turtlemove_(Custom_API)&feed=atom&action=historyTurtlemove (Custom API) - Revision history2024-03-28T17:35:58ZRevision history for this page on the wikiMediaWiki 1.24.1http://www.computercraft.info/wiki/index.php?title=Turtlemove_(Custom_API)&diff=3895&oldid=prevAfterLifeLochie: Moved to CAT:UnofficialAPIs2012-11-28T16:04:30Z<p>Moved to CAT:UnofficialAPIs</p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 16:04, 28 November 2012</td>
</tr><tr><td colspan="2" class="diff-lineno">Line 93:</td>
<td colspan="2" class="diff-lineno">Line 93:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>end</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>end</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div></pre></div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div></pre></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">[[Category:Unofficial_APIs]]</ins></div></td></tr>
</table>AfterLifeLochiehttp://www.computercraft.info/wiki/index.php?title=Turtlemove_(Custom_API)&diff=3320&oldid=prevThesbros at 18:30, 6 October 20122012-10-06T18:30:55Z<p></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 18:30, 6 October 2012</td>
</tr><tr><td colspan="2" class="diff-lineno">Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>The turtlemove API is an <b>unofficial API</b>. This means that you must install it manually.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>The turtlemove API is an <b>unofficial API</b>. This means that you must install it manually.</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"><br /></ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>The turtlemove api will be an API to facilitate programming your turtle's movement. It is in development.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>The turtlemove api will be an API to facilitate programming your turtle's movement. It is in development.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
</table>Thesbroshttp://www.computercraft.info/wiki/index.php?title=Turtlemove_(Custom_API)&diff=3319&oldid=prevThesbros: Created page with "The turtlemove API is an <b>unofficial API</b>. This means that you must install it manually. The turtlemove api will be an API to facilitate programming your turtle's movemen..."2012-10-06T18:30:39Z<p>Created page with "The turtlemove API is an <b>unofficial API</b>. This means that you must install it manually. The turtlemove api will be an API to facilitate programming your turtle's movemen..."</p>
<p><b>New page</b></p><div>The turtlemove API is an <b>unofficial API</b>. This means that you must install it manually.<br />
The turtlemove api will be an API to facilitate programming your turtle's movement. It is in development.<br />
<br />
==doString==<br />
'''doString(str="", checkFuel=10, refuel=true, fuelRetLocation={x,y,z})'''<br />
<br />
doString takes as an argument a commandstr and some options. The commandstr is defined below.<br />
If the recorder is not on, Store and Goto require a wireless modem (for GPS).<br />
If any unsupported operation is attempted, the function will cause an error().<br />
<br />
===checkFuel===<br />
* -2: The turtle will attempt to return to fuelRetLocation if it has exactly that much fuel left after refueling attempts.<br />
* -1: The turtle will make no attempt to examine fuel levels.<br />
* n>=0: The API call will halt with a return of the string position if less than this much fuel is left AND refueling attempts fail.<br />
===refuel===<br />
* true: The turtle will try all slots, starting with 1, in an attempt to refuel.<br />
* false: The turtle will never attempt refueling,<br />
===commandstr===<br />
<pre><br />
commandstr := {command}*<br />
command := {direction} | {repeat} | {store} | {goto} | {mine} | {place} | {whitespace}<br />
whitespace := Anything not defined here<br />
direction := 'f' | 'b' | 'u' | 'd' | 'l' | 'r'<br />
repeat := 'X{number}['{commandstr}']'<br />
store := 'S<'{identifier}'>'<br />
goto := 'G<'{identifier}'>'<br />
identifier := [a-zA-Z0-9_ ]+<br />
number := [0-9]+<br />
</pre><br />
<br />
==Code==<br />
<pre><br />
turtlemove = {}<br />
<br />
local ALLCMDS=fbudlrxsg<br />
function turtlemove.doString(str, checkFuel, refuel, fuelRetLocation)<br />
local function fuelCheck()<br />
--TODO<br />
end<br />
local pos=0<br />
local str = string.lower(str)<br />
while pos <= string.len(str) do<br />
pos = pos+1<br />
fuelCheck()<br />
local c = string.sub(str,pos,pos)<br />
if string.find(ALLCMDS,c,1,true) then<br />
if string.find("fbudlr",c,1,true) then<br />
if c=="f" then<br />
while not turtle.forward() do os.sleep(0.01) end<br />
elseif c=="b" then<br />
while not turtle.back() do os.sleep(0.01) end<br />
elseif c=="u" then<br />
while not turtle.up() do os.sleep(0.01) end<br />
elseif c=="d" then<br />
while not turtle.down() do os.sleep(0.01) end<br />
elseif c=="l" then<br />
while not turtle.turnLeft() do os.sleep(0.01) end<br />
elseif c=="r" then<br />
while not turtle.turnRight() do os.sleep(0.01) end<br />
end<br />
elseif c=="x" then<br />
local numstr = ""<br />
while pos <= string.len(str) do<br />
pos = pos + 1<br />
c2 = string.sub(str,pos,pos)<br />
-- break check<br />
if c2 == "[" then break end<br />
-- errorcheck<br />
if not string.find("0123456789",c2,1,true) then error("Unexpected character "..c2.." at position "..pos.." in repetition count") end<br />
numstr = numstr .. c2<br />
end<br />
local pos_b = pos<br />
local reps = tonumber(numstr)<br />
if reps == nil then error("Repeated section at postition "..pos.." has no repetition count") end<br />
while true do<br />
pos=pos+1<br />
c3=string.sub(str,pos,pos)<br />
if c3=="]" then break end<br />
if pos > string.len(str) then error("Repeated section not closed by position "..pos) end<br />
end<br />
local cmdstr = string.sub(str,pos_b,pos)<br />
for i=1, reps do<br />
turtlemove.doString(cmdstr)<br />
end<br />
else<br />
error("Unimplemented character "..string.sub(str,pos,pos).." at position "..pos)<br />
end<br />
else<br />
error("Unexpected character "..string.sub(str,pos,pos).." at position "..pos)<br />
end<br />
end<br />
end<br />
</pre></div>Thesbros