Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function check()
- if turtle.getFuelLevel() < 5 then
- turtle.select(16)
- turtle.refuel(1)
- turtle.select(1)
- end
- end
- local function RoxSlave()
- local run = 1
- while run == 1 do
- local scrap, message = rednet.receive()
- ----- Dav's addtions ---
- local splitData = {}
- local index = 1
- for data in string.gmatch(message, "[^,]+") do
- splitData[index] = data;
- index = index + 1
- end
- print(message)
- if type(splitData[2]) == "string" then
- print("splitData 2 is a string")
- splitData[2]= tonumber(splitData[2])
- end
- --------- Above takes rednet recieve data and makes it split the value into 2 values in the table 'splitData'
- if splitData[1] == "MoveForward" then
- check()
- turtle.forward()
- elseif splitData[1] == "MoveBack" then
- check()
- turtle.back()
- elseif splitData[1] == "MoveLeft" then
- turtle.turnLeft()
- elseif splitData[1] == "MoveRight" then
- turtle.turnRight()
- elseif splitData[1] == "MoveUp" then
- check()
- turtle.up()
- elseif splitData[1] == "MoveDown" then
- check()
- turtle.down()
- elseif splitData[1] == "DigForward" then
- turtle.dig()
- elseif splitData[1] == "DigUp" then
- turtle.digUp()
- elseif splitData[1] == "DigDown" then
- turtle.digDown()
- -------- Dav's addtions
- elseif splitData[1] == "Select" then
- turtle.select(splitData[2])
- elseif splitData[1] == "SuckForward" then
- turtle.suck()
- elseif splitData[1] == "SuckUp" then
- turtle.suckUp()
- elseif splitData[1] == "SuckDown" then
- turtle.suckDown()
- elseif splitData[1] == "DropForward" then
- turtle.drop()
- elseif splitData[1] == "DropUp" then
- turtle.dropUp()
- elseif splitData[1] == "DropDown" then
- turtle.dropDown()
- elseif splitData[1] == "PlaceForward" then
- turtle.place()
- elseif splitData[1] == "PlaceUp" then
- turtle.placeUp()
- elseif splitData[1] == "PlaceDown" then
- turtle.placeDown()
- -----------
- elseif splitData[1] == "EndTurtle" then
- run = 0
- rednet.close("right")
- textutils.slowPrint("Console ended program.")
- elseif splitData[1] == "EndBoth" then
- run = 0
- rednet.close("right")
- textutils.slowPrint("Console ended program.")
- end
- end
- end
- rednet.open("right")
- term.clear()
- textutils.slowPrint("Rox Remote Control Turtle \(RoxRCT\)")
- print("---------------------------------------")
- print("Receiver ready. Awaiting command from")
- print("the console.")
- print("Fuel is used from slot 16.")
- print("---------------------------------------")
- RoxSlave()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement