From 37bd17f26a1576b62e52d29ce0f5171fac242bd0 Mon Sep 17 00:00:00 2001 From: MayaTheShy Date: Fri, 20 Feb 2026 02:36:39 -0500 Subject: [PATCH] feat: Add equip left, equip right, rename, and sort buttons for turtle management --- pocketremote.lua | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/pocketremote.lua b/pocketremote.lua index 02e54cd..3f66a78 100644 --- a/pocketremote.lua +++ b/pocketremote.lua @@ -272,6 +272,44 @@ local function drawDetail() sendCommand(turtle.turtleID, "setHome") end, colors.blue) + btnY = h - 7 + addButton(1, btnY, 8, 2, "EQUIP L", function() + -- Send eval to equip left + modem.transmit(CHANNEL_SEND, CHANNEL_RECEIVE, { + type = "eval", + uuid = tostring(math.random(100000, 999999)), + code = "return turtle.equipLeft()", + target = turtle.turtleID + }) + end, colors.purple) + + addButton(10, btnY, 8, 2, "EQUIP R", function() + modem.transmit(CHANNEL_SEND, CHANNEL_RECEIVE, { + type = "eval", + uuid = tostring(math.random(100000, 999999)), + code = "return turtle.equipRight()", + target = turtle.turtleID + }) + end, colors.purple) + + addButton(19, btnY, 7, 2, "RENAME", function() + term.setBackgroundColor(colors.black) + term.clear() + term.setCursorPos(1, 1) + term.setTextColor(colors.yellow) + print("Enter new name:") + term.setTextColor(colors.white) + local name = read() + if name and #name > 0 then + modem.transmit(CHANNEL_SEND, CHANNEL_RECEIVE, { + type = "rename", + name = name, + target = turtle.turtleID + }) + end + draw() + end, colors.lightBlue) + addButton(1, h - 1, 12, 2, "< BACK", function() viewMode = "overview" end, colors.gray) @@ -363,6 +401,38 @@ local function drawManual() sendCommand(turtle.turtleID, "refuel") end, colors.lime) + addButton(19, h - 3, 7, 2, "SORT", function() + modem.transmit(CHANNEL_SEND, CHANNEL_RECEIVE, { + type = "eval", + uuid = tostring(math.random(100000, 999999)), + code = [[ + local moved = 0 + for slot = 1, 16 do + local item = turtle.getItemDetail(slot) + if item then + for target = 1, slot - 1 do + local ti = turtle.getItemDetail(target) + if not ti then + turtle.select(slot) + turtle.transferTo(target) + moved = moved + 1 + break + elseif ti.name == item.name and ti.count < 64 then + turtle.select(slot) + turtle.transferTo(target) + moved = moved + 1 + if turtle.getItemCount(slot) == 0 then break end + end + end + end + end + turtle.select(1) + return moved + ]], + target = turtle.turtleID + }) + end, colors.cyan) + addButton(19, h - 3, 7, 2, "INFO", function() sendCommand(turtle.turtleID, "status") end, colors.lightBlue)