Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Advanced Computer Program for controlling the Mining Turtle with Remote Console Control and ID Prompt
- local computerID
- local modem = peripheral.wrap("top") -- Replace "top" with the side where the modem is attached
- -- Function to send commands to the turtle
- local function sendCommand(command)
- modem.transmit(computerID, computerID, command) -- Send command to turtle using its ID
- end
- -- Function to execute a console command on the turtle
- local function executeConsoleCommand(command)
- modem.transmit(computerID, computerID, command) -- Send command to turtle using its ID
- local _, _, senderID, message = os.pullEvent("modem_message")
- if senderID == computerID then
- print("Turtle console output:")
- print(message)
- else
- print("Unexpected response received")
- end
- end
- -- Function to prompt user for turtle ID
- local function promptForTurtleID()
- term.clear()
- term.setCursorPos(1, 1)
- print("Enter Turtle ID:")
- return tonumber(read()) -- Read user input and convert to number (assuming turtle ID is numeric)
- end
- -- Main function to run the program
- local function main()
- computerID = promptForTurtleID()
- if not computerID then
- print("Invalid Turtle ID entered. Exiting program.")
- return
- end
- while true do
- term.clear()
- term.setCursorPos(1, 1)
- print("=== Mining Turtle Remote Control Panel ===")
- print("[1] Mine Chunk")
- print("[2] Return")
- print("[3] Inventory")
- print("[4] Refuel All")
- print("[5] Shutdown Turtle")
- print("[Q] Quit")
- local _, key = os.pullEvent("key")
- if key == keys.one then
- sendCommand("mine_chunk")
- elseif key == keys.two then
- sendCommand("return")
- elseif key == keys.three then
- sendCommand("inventory")
- elseif key == keys.four then
- executeConsoleCommand("refuel all")
- elseif key == keys.five then
- sendCommand("shutdown")
- break
- elseif key == keys.q or key == keys.Q then
- break -- Quit the program
- end
- end
- end
- -- Run the main function
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement