From 0f2530d1e12bd90690235fdd17327b54e1df9d05 Mon Sep 17 00:00:00 2001 From: brulijam Date: Sat, 22 Jun 2024 00:39:50 +0200 Subject: [PATCH] . --- src/brulijam/lib/tutel.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/brulijam/lib/tutel.lua b/src/brulijam/lib/tutel.lua index 2445831..566249b 100644 --- a/src/brulijam/lib/tutel.lua +++ b/src/brulijam/lib/tutel.lua @@ -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