.
This commit is contained in:
parent
5df3417519
commit
0f2530d1e1
@ -22,8 +22,10 @@ end
|
||||
--location returning move wrapper
|
||||
--https://www.youtube.com/watch?v=bZe5J8SVCYQ
|
||||
|
||||
local pos = {}
|
||||
|
||||
local function savePos()
|
||||
basic.writeToFile("brulijam/files/pos.txt", textutils.serialize(state))
|
||||
basic.writeToFile("brulijam/files/pos.txt", textutils.serialize(pos))
|
||||
end
|
||||
|
||||
local function getPos()
|
||||
@ -41,7 +43,6 @@ local function getPos()
|
||||
r = read()
|
||||
basic.clearDisplay()
|
||||
|
||||
pos = {}
|
||||
pos["x"] = x
|
||||
pos["y"] = y
|
||||
pos["z"] = z
|
||||
@ -67,6 +68,7 @@ local function forward()
|
||||
elseif pos["r"] == 3 then
|
||||
pos["x"] = pos["x"] + 1
|
||||
end
|
||||
savePos()
|
||||
end
|
||||
end
|
||||
|
||||
@ -82,6 +84,7 @@ local function back()
|
||||
elseif pos["r"] == 3 then
|
||||
pos["x"] = pos["x"] - 1
|
||||
end
|
||||
savePos()
|
||||
end
|
||||
end
|
||||
|
||||
@ -89,6 +92,7 @@ local function up()
|
||||
sleep(1)
|
||||
if turtle.up() then
|
||||
pos["y"] = pos["y"] + 1
|
||||
savePos()
|
||||
end
|
||||
end
|
||||
|
||||
@ -96,6 +100,7 @@ local function down()
|
||||
sleep(1)
|
||||
if turtle.down() then
|
||||
pos["y"] = pos["y"] - 1
|
||||
savePos()
|
||||
end
|
||||
end
|
||||
|
||||
@ -103,6 +108,7 @@ local function left()
|
||||
sleep(1)
|
||||
if turtle.turnLeft() then
|
||||
pos["r"] = (pos["r"]-1) % 4
|
||||
savePos()
|
||||
end
|
||||
end
|
||||
|
||||
@ -110,6 +116,7 @@ local function right()
|
||||
sleep(1)
|
||||
if turtle.turnRight() then
|
||||
pos["r"] = (pos["r"]+1) % 4
|
||||
savePos()
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user