feat: Add equip left, equip right, rename, and sort buttons for turtle management
This commit is contained in:
@@ -272,6 +272,44 @@ local function drawDetail()
|
|||||||
sendCommand(turtle.turtleID, "setHome")
|
sendCommand(turtle.turtleID, "setHome")
|
||||||
end, colors.blue)
|
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()
|
addButton(1, h - 1, 12, 2, "< BACK", function()
|
||||||
viewMode = "overview"
|
viewMode = "overview"
|
||||||
end, colors.gray)
|
end, colors.gray)
|
||||||
@@ -363,6 +401,38 @@ local function drawManual()
|
|||||||
sendCommand(turtle.turtleID, "refuel")
|
sendCommand(turtle.turtleID, "refuel")
|
||||||
end, colors.lime)
|
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()
|
addButton(19, h - 3, 7, 2, "INFO", function()
|
||||||
sendCommand(turtle.turtleID, "status")
|
sendCommand(turtle.turtleID, "status")
|
||||||
end, colors.lightBlue)
|
end, colors.lightBlue)
|
||||||
|
|||||||
Reference in New Issue
Block a user