Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if not fs.exists("API") then
- shell.run("pastebin", "get", "EzkfU5ZM", "API")
- end
- if not fs.exists("basalt.lua") then
- shell.run("wget", "run", "http://basalt.madefor.cc/install.lua", "packed")
- -- wget run https://basalt.madefor.cc/install.lua release latest.lua
- -- shell.run("pastebin", "run", "ESs1mg7P")
- -- wget run http://basalt.madefor.cc/install.lua packed
- -- pastebin run ESs1mg7P
- end
- basalt = require("basalt")
- shaka = require("API")
- term.setCursorBlink(false)
- startLocation = true
- local value
- local index
- local turtleSides = {"Front", "Back", "Top", "Bottom", "Left", "Right"}
- turtleID = 43 -- remove this !!!!!!!!!!!
- local function findTransporter()
- shaka.clearScreen()
- local main = basalt.createFrame()
- shaka.changeColors(colors.black, colors.yellow)
- print("Waiting for connection..")
- local id, msg = rednet.receive("transporterPing")
- if id then
- turtleID = id
- rednet.send(id, "you're not alone", "transporterAnswer")
- end
- end
- -- Function to send movement orders via Rednet
- local function sendMovementOrder(orderName)
- rednet.send(turtleID, orderName, "recordRemote") -- Send the order via Rednet
- end
- local function recordInventory()
- local direction = nil
- local dropDirection = nil
- local turtleCommand = nil
- local selectedItem = nil
- local itemSelection = 0
- local amount = nil
- shaka.changeColors(colors.black, colors.white)
- term.clear()
- term.setCursorPos(1, 1)
- shaka.changeColors(colors.gray, colors.yellow)
- term.clearLine()
- shaka.centerText("Drop or take items?", 1)
- shaka.changeColors(colors.black, colors.white)
- shaka.nextLine()
- shaka.nextLine()
- local savedX, savedY = term.getCursorPos()
- print("1. Drop")
- print("2. Take")
- while true do
- local event, answer = os.pullEvent("key")
- os.pullEvent("key_up")
- if answer == keys.one then
- term.setCursorPos(1, 1)
- shaka.changeColors(colors.gray, colors.yellow)
- term.clearLine()
- shaka.centerText("Choose drop mode")
- shaka.changeColors(colors.black, colors.white)
- term.setCursorPos(savedX, savedY)
- term.clearLine()
- print("1. Drop all items")
- print("2. Filter dropped items")
- while true do
- local event, dropAnswer = os.pullEvent("key")
- os.pullEvent("key_up")
- if dropAnswer == keys.one then
- direction = "drop"
- break
- elseif dropAnswer == keys.two then
- direction = "dropFiltered"
- break
- end
- end
- shaka.clearScreen()
- shaka.changeColors(colors.gray, colors.yellow)
- term.clearLine()
- shaka.centerText("Drop items where?")
- shaka.changeColors(colors.black, colors.white)
- term.setCursorPos(savedX, savedY)
- break
- elseif answer == keys.two then
- shaka.clearScreen()
- shaka.changeColors(colors.gray, colors.yellow)
- term.clearLine()
- shaka.centerText("Take from where?")
- shaka.nextLine()
- shaka.nextLine()
- shaka.changeColors(colors.black, colors.white)
- direction = "suck"
- break
- end
- end
- local _, frontY = term.getCursorPos()
- print("1. Front")
- local _, upY = term.getCursorPos()
- print("2. Up")
- local _, downY = term.getCursorPos()
- print("3. Down")
- while true do
- local event, dropDirection, isHeld = os.pullEvent("key")
- os.pullEvent("key_up")
- if dropDirection == keys.one then
- turtleCommand = "front"
- local x, y = term.getCursorPos()
- term.setCursorPos(1, frontY)
- term.clearLine()
- shaka.changeColors(colors.green, colors.black)
- print("1. Front")
- term.setCursorPos(x, y)
- break
- elseif dropDirection == keys.two then
- turtleCommand = "up"
- local x, y = term.getCursorPos()
- term.setCursorPos(1, upY)
- term.clearLine()
- shaka.changeColors(colors.green, colors.black)
- print("2. Up")
- term.setCursorPos(x, y)
- break
- elseif dropDirection == keys.three then
- turtleCommand = "down"
- local x, y = term.getCursorPos()
- term.setCursorPos(1, downY)
- term.clearLine()
- shaka.changeColors(colors.green, colors.black)
- print("3. Down")
- term.setCursorPos(x, y)
- break
- end
- end
- if direction == "dropFiltered" then
- repeat
- shaka.clearScreen()
- shaka.changeColors(colors.gray, colors.yellow)
- term.clearLine()
- shaka.centerText("Which item?")
- shaka.nextLine()
- shaka.nextLine()
- shaka.changeColors(colors.black, colors.white)
- sendMovementOrder("showAvailable")
- sender, msg = rednet.receive("showAvailableItems", 2)
- if msg then
- msg = textutils.unserialize(msg)
- if msg[1] ~= nil then
- for k, v in pairs(msg) do
- print(k..". "..v)
- end
- else
- print("Place item into turtle inventory and hit enter.")
- end
- else
- shaka.changeColors(colors.red, colors.black)
- print("Lost connection! Restarting.")
- sleep(2)
- os.reboot()
- end
- shaka.nextLine()
- local x, y = term.getCursorPos()
- local maxX, maxY = term.getSize()
- term.setCursorPos(1, maxY - 3)
- shaka.changeColors(colors.black, colors.gray)
- print("Enter without entry to refresh turtle inventory")
- term.setCursorPos(x, y)
- shaka.changeColors(colors.black, colors.white)
- itemSelection = tonumber(read())
- until itemSelection ~= nil
- for k, v in pairs(msg) do
- if itemSelection == k then
- selectedItem = v
- end
- end
- end
- if direction ~= "drop" then
- shaka.changeColors(colors.gray, colors.yellow)
- shaka.nextLine()
- term.clearLine()
- shaka.centerText("Amount?")
- shaka.nextLine()
- shaka.changeColors(colors.black, colors.white)
- print("No entry for as many as possible\n")
- amount = read()
- end
- if amount == nil or amount == "" then
- amount = "all"
- end
- if selectedItem == nil then
- selectedItem = "nada"
- end
- if turtleCommand then
- shaka.changeColors(colors.gray, colors.green)
- print("\nSaved!")
- sleep(1)
- end
- sendMovementOrder(direction.." "..turtleCommand.." "..amount.." "..selectedItem)
- end
- local function switchRedstone()
- local dir = nil
- local state = nil
- local pulseTime = 0
- term.clear()
- term.setCursorPos(1,1)
- shaka.changeColors(colors.gray, colors.yellow)
- term.clearLine()
- shaka.centerText("Change rs on which side?")
- shaka.changeColors(colors.black, colors.white)
- shaka.nextLine()
- shaka.nextLine()
- print(" ^ Front - W")
- print("< > Left/Right - A/D")
- print(" v Back - S\n")
- print("Space: Top")
- print("Shift: Bottom\n")
- while true do
- local event, selection = os.pullEvent("key")
- os.pullEvent("key_up")
- if selection == keys.space then
- dir = "top"
- break
- elseif selection == keys.leftShift then
- dir = "bottom"
- break
- elseif selection == keys.a then
- dir = "left"
- break
- elseif selection == keys.d then
- dir = "right"
- break
- elseif selection == keys.w then
- dir = "front"
- break
- elseif selection == keys.s then
- dir = "back"
- break
- end
- end
- shaka.changeColors(colors.black, colors.green)
- print("Selected:", dir)
- shaka.nextLine()
- shaka.changeColors(colors.gray, colors.yellow)
- term.clearLine()
- print("Operation?\n")
- shaka.changeColors(colors.black, colors.white)
- local x, y = term.getCursorPos()
- print("1. On")
- print("2. Off")
- print("3. Pulse on -> off")
- shaka.changeColors(colors.black, colors.yellow)
- while true do
- local event, selection = os.pullEvent("key")
- os.pullEvent("key_up")
- if selection == keys.one then
- state = "on"
- break
- elseif selection == keys.two then
- state = "off"
- break
- elseif selection == keys.three then
- state = "pulse"
- for i = 0, 3 do
- term.setCursorPos(x, y + i)
- term.clearLine()
- end
- term.setCursorPos(x, y)
- shaka.changeColors(colors.black, colors.white)
- print("Pulse for how long?\n")
- pulseTime = read()
- break
- end
- end
- print("Selected:", state)
- sendMovementOrder("redstone " ..dir.. " " ..state.." "..pulseTime)
- sleep(1)
- end
- local function addSleep()
- shaka.clearScreen()
- shaka.changeColors(colors.black, colors.yellow)
- print("How many seconds?\n")
- sleep(0.3)
- local sleepTime = read()
- sendMovementOrder("sleep " ..sleepTime)
- print("\nSuccess!")
- sleep(1)
- end
- local function genericMenu(title, optionsTable, listBoolean, keepScreenBoolean)
- local selection = nil
- local dir = nil
- if keepScreenBoolean ~= true then
- shaka.clearScreen()
- else
- shaka.nextLine()
- shaka.nextLine()
- end
- shaka.changeColors(colors.gray, colors.yellow)
- term.clearLine()
- shaka.centerText(title)
- local xPos, yPos = term.getCursorPos()
- term.setCursorPos(1, yPos + 2)
- if listBoolean then
- shaka.changeColors(colors.black, colors.white)
- for i = 1, #optionsTable do
- print(i..") "..optionsTable[i])
- end
- while true do
- local event, choice = os.pullEvent("key")
- os.pullEvent("key_up")
- if choice == keys.one then
- selection = 1
- break
- elseif choice == keys.two then
- selection = 2
- break
- elseif choice == keys.three then
- selection = 3
- break
- elseif choice == keys.four then
- selection = 4
- break
- elseif choice == keys.five then
- selection = 5
- break
- elseif choice == keys.six then
- selection = 6
- break
- end
- end
- term.setCursorPos(1, selection + yPos + 1)
- shaka.changeColors(colors.green, colors.yellow)
- if optionsTable[selection] then
- print(selection..") " ..optionsTable[selection])
- end
- else
- shaka.changeColors(colors.black, colors.white)
- print(" ^ Front - W")
- print("< > Left/Right - A/D")
- print(" v Back - S\n")
- print("Space: Top")
- print("Shift: Bottom\n")
- while true do
- event, selection = os.pullEvent("key")
- os.pullEvent("key_up")
- if selection == keys.space then
- selection = "top"
- break
- elseif selection == keys.leftShift then
- selection = "bottom"
- break
- elseif selection == keys.a then
- selection = "left"
- break
- elseif selection == keys.d then
- selection = "right"
- break
- elseif selection == keys.w then
- selection = "front"
- break
- elseif selection == keys.s then
- selection = "back"
- break
- end
- end
- shaka.changeColors(colors.black, colors.green)
- print("Selected:", selection)
- end
- sleep(0.5)
- return selection or nil
- end
- local function redstoneTrigger()
- local chosenSide = genericMenu("Wait for RS on which side?", turtleSides)
- local state = genericMenu("Trigger when on or off?", {"on", "off"}, true)
- sendMovementOrder("redstoneTrigger "..chosenSide.." "..state) --side string, state number[1=on, 2=off]
- -- print("redstoneTrigger "..chosenSide.." "..state)
- -- sleep(3)
- end
- local function createBasaltMenu(tableName, title)
- local main = basalt.createFrame()
- local x, y = main:getSize()
- local itemList = main:addList()
- local button = main:addButton()
- :setBackground(colors.lightGray)
- local label = main:addLabel()
- :setSize(x, 2)
- :setText(title)
- :setTextAlign("center")
- :setBackground(colors.lightGray)
- local function stopMenu()
- value = itemList:getValue()
- index = itemList:getItemIndex()
- basalt.stop()
- end
- for k, v in pairs(tableName) do
- itemList:addItem(v)
- end
- local function buttonLabel()
- value = itemList:getValue()
- button:setText(value.text)
- end
- local function keyControl(self, event, key)
- key = keys.getName(key)
- buttonLabel()
- local pos = itemList:getItemIndex()
- if key == "up" then
- if pos == 1 then
- return false
- else
- itemList:selectItem(pos - 1)
- buttonLabel()
- end
- elseif key == "down" then
- if pos == itemList:getItemCount() then
- return
- else
- itemList:selectItem(pos + 1)
- buttonLabel()
- end
- elseif key == "enter" then
- stopMenu()
- end
- end
- button
- :setPosition(1, y)
- :setSize(x, 1)
- :setText("Click or use arrows")
- :onClick(stopMenu)
- itemList
- :setSize(x, y - 3)
- :setBackground(colors.gray)
- :setPosition(1, 3)
- :setFocus()
- :onClickUp(buttonLabel)
- :setScrollable(true)
- :onKey(keyControl)
- :setSelectionColor(colors.black, colors.lime)
- basalt.autoUpdate()
- end
- local function blockTrigger()
- local sideTable = {"front", "up", "down"}
- local chosenSide = genericMenu("Block on which side?", sideTable, true)
- chosenSide = sideTable[chosenSide]
- sendMovementOrder("blockInformation "..chosenSide)
- local sender, msg = rednet.receive("blockAnswer")
- createBasaltMenu(msg, "Please choose data:")
- if value then
- sendMovementOrder("blockTrigger " ..chosenSide.." ".. value.text)
- else
- -- print("nope")
- -- sleep(3)
- end
- end
- function getLimiter(bool)
- local aboveOrBelow = nil
- if bool then
- aboveOrBelow = genericMenu("Trigger above or below?", {"Above", "Below"}, true, false)
- else
- aboveOrBelow = genericMenu("Trigger above or below?", {"Above", "Below"}, true, true)
- end
- if aboveOrBelow == 1 then
- aboveOrBelow = "above"
- elseif aboveOrBelow == 2 then
- aboveOrBelow = "below"
- end
- return aboveOrBelow
- end
- local function basaltInvMenu()
- local itemIndex
- local upDownChoice = nil
- local itemNumber
- local ready = false
- local inputSize = 7
- local itemTable = {}
- local prettyTable = {}
- local count = -1
- local main = basalt.createFrame()
- :setBackground(colors.gray)
- local itemList = main:addDropdown()
- :setPosition(8, 1)
- :setDropdownSize(26 - 8, 15)
- :setBackground(colors.lightGray)
- :setSize(26 - 7, 1)
- :setZIndex(100)
- local itemCount = main:addInput()
- :setInputType("number")
- :setSize(inputSize, 1)
- :setInputLimit(inputSize - 1)
- :setPosition(2, 8)
- :setBackground(colors.black)
- :setForeground(colors.white)
- :setDefaultText("Enter #")
- :setFocus()
- local confirmButton = main:addButton()
- :setSize(7, 3)
- :setPosition(19, 6)
- :setBackground(colors.red)
- :setText("Confirm")
- local inputX = itemCount:getX()
- local inputY = itemCount:getY()
- local aboveOrBelowWindow = main:addFrame()
- :setSize(inputSize, 2)
- :setPosition(inputX, inputY - 2)
- :setTransparency(false)
- :setBackground(colors.gray)
- local upArrow = aboveOrBelowWindow:addButton()
- :setSize(inputSize, 1)
- :setPosition(1, 1)
- :setText("above")
- :setBackground(colors.lightGray)
- local downArrow = aboveOrBelowWindow:addButton()
- :setSize(inputSize, 1)
- :setPosition(1, 2)
- :setText("below")
- :setBackground(colors.lightGray)
- local function clickUp()
- upArrow:setBackground(colors.green)
- downArrow:setBackground(colors.lightGray)
- upDownChoice = "above"
- end
- local function clickDown()
- upArrow:setBackground(colors.lightGray)
- downArrow:setBackground(colors.green)
- upDownChoice = "below"
- end
- local function keyBoardSelection(self, event, key)
- if key == keys.up then
- clickUp()
- elseif key == keys.down then
- clickDown()
- end
- end
- local dirList = main:addDropdown()
- :setPosition(1, 1)
- :setSize(7, 1)
- :setBackground(colors.white)
- :setZIndex(101)
- -- local chosenSide = genericMenu("Inventory on which side?")
- -- local inventoryAction = genericMenu("Which inventory trigger?", {"Count of specific item", "Total fill percentage"}, true, true)
- -- sendMovementOrder("displayExternal")
- -- rednet.send(turtleID, "front", "sideAnswer") --- change to chosenSide !!!!! -----------------------------------
- local directions = {"front", "top", "bottom"}
- for k, v in pairs(directions) do
- dirList:addItem(v)
- end
- local function stopMenu()
- local itemIndex = itemList:getItemIndex()
- local itemNumber = itemCount:getValue()
- local dirIndex = dirList:getItemIndex()
- -- local zTest = aboveOrBelowWindow:getZIndex()
- -- basalt.debug(zTest)
- if itemIndex and itemNumber and dirIndex then
- sendMovementOrder("inventoryTrigger " ..directions[dirIndex].. " " ..itemTable[itemIndex].." "..upDownChoice.." "..itemNumber)
- end
- basalt.stop()
- end
- local function changeButton(self)
- count = itemCount:getValue()
- basalt.debug(count)
- if count >= 0 then
- if upDownChoice ~= nil then
- confirmButton:setBackground(colors.green)
- ready = true
- end
- else
- confirmButton:setBackground(colors.red)
- end
- end
- local function showItems(self)
- prettyTable = {}
- itemList:clear()
- local selectedIndex = dirList:getItemIndex()
- sendMovementOrder("displayExternal")
- local sender = rednet.receive("sideQuestion")
- rednet.send(turtleID, directions[selectedIndex], "sideAnswer")
- sender, itemTable = rednet.receive("items_Available")
- itemTable = textutils.unserialize(itemTable)
- local function compareSubstring(a, b)
- local substringA = string.sub(a, string.find(a, ":") + 1)
- local substringB = string.sub(b, string.find(b, ":") + 1)
- return substringA < substringB
- end
- table.sort(itemTable, compareSubstring)
- for k, v in pairs(itemTable) do
- prettyTable[k] = shaka.prettyName(itemTable[k])
- end
- for k, v in pairs(prettyTable) do
- itemList:addItem(v)
- end
- end
- showItems()
- upArrow:onClick(clickUp)
- -- :onLoseFocus(changeButton)
- :onClick(changeButton)
- downArrow:onClick(clickDown)
- -- :onLoseFocus(changeButton)
- :onClick(changeButton)
- itemCount
- :onKey(keyBoardSelection)
- :onLoseFocus(changeButton)
- confirmButton
- :onClick(stopMenu)
- dirList
- :onChange(showItems)
- basalt.autoUpdate()
- end
- local function inventoryTrigger()
- local chosenSide = genericMenu("Inventory on which side?")
- local inventoryAction = genericMenu("Which inventory trigger?", {"Count of specific item", "Total fill percentage"}, true, true)
- sendMovementOrder("displayExternal")
- local sender = rednet.receive("sideQuestion")
- rednet.send(sender, chosenSide, "sideAnswer")
- if tonumber(inventoryAction) == 1 then
- local sender, itemTable = rednet.receive("items_Available")
- itemTable = textutils.unserialize(itemTable)
- local prettyTable = {}
- local function compareSubstring(a, b)
- local substringA = string.sub(a, string.find(a, ":") + 1)
- local substringB = string.sub(b, string.find(b, ":") + 1)
- return substringA < substringB
- end
- table.sort(itemTable, compareSubstring)
- for k, v in pairs(itemTable) do
- prettyTable[k] = shaka.prettyName(itemTable[k])
- end
- shaka.clearScreen()
- createBasaltMenu(prettyTable, "Which item?")
- limiter = getLimiter()
- shaka.nextLine()
- shaka.changeColors(colors.gray, colors.yellow)
- term.clearLine()
- print("Item count to trigger on?")
- shaka.changeColors(colors.black, colors.white)
- shaka.nextLine()
- local countAnswer = tonumber(read())
- shaka.clearScreen()
- shaka.changeColors(colors.black, colors.green)
- print("Success!")
- shaka.changeColors(colors.black, colors.white)
- print("\nSide:", chosenSide)
- print("\nItem:", prettyTable[index])
- print("\nTrigger: "..limiter.." "..countAnswer)
- sendMovementOrder("inventoryTrigger " ..chosenSide.. " " ..itemTable[index].." "..limiter.." "..countAnswer)
- shaka.changeColors(colors.black, colors.gray)
- print("\nPress any key to continue..")
- os.pullEvent("key")
- else
- shaka.clearScreen()
- limiter = getLimiter(true)
- shaka.nextLine()
- shaka.nextLine()
- shaka.changeColors(colors.gray, colors.yellow)
- term.clearLine()
- print("Which percentage?")
- local percentage = read()
- print("inventoryTrigger " ..chosenSide.. " fillPercent "..limiter.." "..percentage)
- sendMovementOrder("inventoryTrigger " ..chosenSide.. " fillPercent "..limiter.." "..percentage)
- end
- end
- local function triggerMenu()
- shaka.clearScreen()
- local options = {"Redstone", "Block", "Inventory"}
- shaka.changeColors(colors.gray, colors.yellow)
- term.clearLine()
- shaka.centerText("Trigger on which event?\n")
- term.setCursorPos(1, 3)
- local startY = 3
- shaka.changeColors(colors.black, colors.white)
- -- display the menu options
- for i=1,#options do
- print(i..") "..options[i])
- end
- shaka.nextLine()
- -- get user input
- local a, b = term.getCursorPos()
- term.write("Select an option")
- while true do
- local event, choice = os.pullEvent("key")
- os.pullEvent("key_up")
- if choice == keys.one then
- term.setCursorPos(1, startY)
- shaka.changeColors(colors.green, colors.yellow)
- term.clearLine()
- print("1) " ..options[1])
- term.setCursorPos(a, b)
- shaka.changeColors(colors.black, colors.green)
- term.clearLine()
- print("Selected "..options[1])
- sleep(1)
- redstoneTrigger()
- return choice
- elseif choice == keys.two then
- term.setCursorPos(1, startY + 1)
- shaka.changeColors(colors.green, colors.yellow)
- term.clearLine()
- print("2) " ..options[2])
- term.setCursorPos(a, b)
- shaka.changeColors(colors.black, colors.green)
- term.clearLine()
- print("Selected "..options[2])
- sleep(1)
- blockTrigger()
- return choice
- elseif choice == keys.three then
- term.setCursorPos(1, startY + 2)
- shaka.changeColors(colors.green, colors.yellow)
- term.clearLine()
- print("3) " ..options[3])
- term.setCursorPos(a, b)
- shaka.changeColors(colors.black, colors.green)
- term.clearLine()
- print("Selected "..options[3])
- sleep(1)
- inventoryTrigger()
- return choice
- end
- term.setCursorPos(a, b + 2)
- term.write("Invalid option. Try again.")
- sleep(1)
- term.clearLine()
- end
- end
- local function main()
- shaka.clearScreen()
- -- Display movement options
- shaka.changeColors(colors.gray, colors.black)
- term.clearLine()
- -- Display title
- print("Turtle Movement Options:\n")
- shaka.changeColors(colors.black, colors.green)
- -- Display movement options with arrows
- print(" ^ Forward - W")
- print("< > Left/Right - A/D")
- print(" v Backward - S\n")
- print("Space: Up")
- print("Shift: Down\n")
- -- Display other options
- shaka.changeColors(colors.black, colors.yellow)
- print("I Inventory Action")
- print("R Redstone Action")
- print("F Sleep Action")
- print("T Wait for Trigger\n")
- term.setTextColor(colors.orange)
- print("Q Undo last move")
- _, XLoc = term.getCursorPos()
- term.clearLine()
- print("X Finish recording\n")
- while true do
- -- Get user input
- local event, key = os.pullEvent("key")
- if key == keys.w then
- sendMovementOrder("forward")
- elseif key == keys.a then
- sendMovementOrder("left")
- elseif key == keys.s then
- sendMovementOrder("back")
- elseif key == keys.d then
- sendMovementOrder("right")
- elseif key == keys.space then
- sendMovementOrder("up")
- elseif key == keys.leftShift then
- sendMovementOrder("down")
- elseif key == keys.i then
- recordInventory()
- main()
- break
- elseif key == keys.x then
- sendMovementOrder("allDone")
- local sender, msg = rednet.receive("remoteEnd")
- if msg == "yep" then
- shaka.clearScreen()
- textutils.slowPrint("Finished recording..")
- sleep(1)
- break
- elseif msg == "nope" then
- rednet.send(sender, "y", "remoteEnd")
- local turtle_id, reply = rednet.receive("arrivedAtStart")
- local x, y = term.getCursorPos()
- term.setCursorPos(1, XLoc)
- term.clearLine()
- shaka.changeColors(colors.black, colors.orange)
- print("X Finish recording\n")
- term.setCursorPos(x, y)
- end
- elseif key == keys.q then
- sendMovementOrder("delete")
- sender, msg = rednet.receive("instructionDeleteConfirm", 2)
- shaka.changeColors(colors.black, colors.red)
- if msg then
- local x, y = term.getCursorPos()
- local _, maxY = term.getSize()
- term.setCursorPos(1, maxY - 1)
- term.clearLine()
- if msg == "start" then
- term.write("Back at start")
- else
- term.write("Deleted: "..msg)
- end
- sleep(1)
- term.clearLine()
- term.setCursorPos(x, y)
- else
- print("Failure")
- end
- elseif key == keys.r then
- switchRedstone()
- main()
- break
- elseif key == keys.f then
- addSleep()
- main()
- break
- elseif key == keys.t then
- triggerMenu()
- main()
- break
- end
- end
- end
- local function positionUpdate()
- while true do
- local sender, msg = rednet.receive("positionUpdate")
- if msg == "start" then
- local x, y = term.getCursorPos()
- term.setCursorPos(1, XLoc)
- term.clearLine()
- shaka.changeColors(colors.black, colors.orange)
- print("X Finish recording\n")
- term.setCursorPos(x, y)
- else
- local x, y = term.getCursorPos()
- term.setCursorPos(1, XLoc)
- term.clearLine()
- shaka.changeColors(colors.black, colors.orange)
- print("X Go to start\n")
- term.setCursorPos(x, y)
- end
- end
- end
- -- local function turtleControls()
- -- local normalBG = colors.green
- -- local clickedBG = colors.yellow
- -- local main = basalt.createFrame()
- -- local joypad = main:addFrame()
- -- :setBackground(colors.black)
- -- :setSize(5, 3)
- -- :setPosition(4, 3)
- -- :setFocus()
- -- :setBorder(colors.blue)
- -- local arrows = {buttonForward, buttonBack, buttonLeft, buttonRight}
- -- local function forward()
- -- sendMovementOrder("forward")
- -- end
- -- local function back()
- -- sendMovementOrder("back")
- -- end
- -- local arrowButtons = {
- -- joypad:addButton():setText("^")
- -- :setPosition(3, 1)
- -- :onClick(forward)
- -- :onKey(keyColorPressed)
- -- :onKeyUp(keyColorNormal)
- -- ,
- -- joypad:addButton():setText("v")
- -- :setPosition(3, 3)
- -- :onClick(back)
- -- ,
- -- joypad:addButton():setText("<")
- -- :setPosition(1, 2)
- -- ,
- -- joypad:addButton():setText(">")
- -- :setPosition(5, 2)
- -- }
- -- local function keyColorNormal(self, event, key)
- -- basalt.debug("up")
- -- for k, v in pairs(arrowButtons) do
- -- v:setBackground(normalBG)
- -- end
- -- arrowButtons[1]:setBackground(normalBG)
- -- end
- -- local function keyColorPressed(self, event, key)
- -- if (key == keys.w) then
- -- basalt.debug("yo")
- -- arrowButtons[1]:setBackground(clickedBG)
- -- elseif key == keys.a then
- -- arrowButtons[3]:setBackground(clickedBG)
- -- elseif key == keys.s then
- -- arrowButtons[2]:setBackground(clickedBG)
- -- elseif key == keys.d then
- -- arrowButtons[4]:setBackground(clickedBG)
- -- end
- -- end
- -- joypad
- -- :onKey(keyColorPressed)
- -- :onKeyUp(keyColorNormal)
- -- for k, v in pairs(arrowButtons) do
- -- local function normalColor()
- -- v:setBackground(normalBG)
- -- end
- -- normalColor()
- -- local function clickColor()
- -- v:setBackground(clickedBG)
- -- basalt.debug("Button "..k)
- -- end
- -- v:setSize(1,1)
- -- v:onClick(clickColor)
- -- v:onRelease(normalColor)
- -- end
- -- end
- -- turtleControls()
- local function test()
- local main = basalt.createFrame()
- local inputField = main:addInput()
- local function changedInput()
- local value = inputField:getValue()
- basalt.debug(value)
- end
- inputField:onChange(changedInput)
- basalt.autoUpdate()
- end
- local args = { ... }
- if args[1] == "1" then
- -- blockTrigger()
- inventoryTrigger()
- elseif args[1] == "2" then
- basaltInvMenu()
- -- test()
- else
- findTransporter()
- -- while true do
- parallel.waitForAny(main, positionUpdate)
- end
- -- end
- -- main()
- -- print(triggerMenu())
- -- os.reboot()
- -- basalt.autoUpdate()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement