Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Fern Core is the base api of all Fern enterprises.
- -- Network Funtions
- function nodelisten(side, channel)
- local modem = peripheral.wrap(side)
- modem.open(channel)
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- return message
- end
- function repeat_node(side, route_ch)
- local modem = peripheral.wrap(side)
- modem.open(route_ch)
- while true do
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- if senderChannel == route_ch then
- local repeat_channel = message
- modem.open(repeatchannel)
- while true do
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- if senderChannel == repeat_channel then
- modem.transmit(repeat_channel, repeat_channel, message)
- modem.close(repeat_channel)
- break
- end
- end
- end
- end
- end
- -- Misc Functions
- function cls()
- term.clear()
- term.setCursorPos(1,1)
- end
- -- Turtle Functions
- function walk(direction, distance, endingdir)
- if direction == "forward" or "f" then
- for i = 1,distance,1 do
- if turtle.detect() == false then
- turtle.forward()
- end
- end
- if endingdir == "right" or "r" then
- turtle.turnRight()
- elseif endingdir == "back" or "b" then
- turtle.turnRight()
- turtle.turnRight()
- elseif endingdir == "left" or "l" then
- turtle.turnLeft()
- end
- elseif direction == "right" or "r" then
- turtle.turnRight()
- for i = 1,distance,1 do
- if turtle.detect() == false then
- turtle.forward()
- end
- end
- if endingdir == "forward" or "f" then
- turtle.turnLeft()
- elseif endingdir == "back" or "b" then
- turtle.turnRight()
- elseif endingdir == "left" or "l" then
- turtle.turnRight()
- turtle.turnRight()
- end
- elseif direction == "back" or "b" then
- turtle.turnRight()
- turtle.turnRight()
- for i = 1,distance,1 do
- if turtle.detect() == false then
- while true do
- if pcall(turtle.forward()) == true then
- break
- end
- end
- end
- end
- if endingdir == "forward" or "f" then
- turtle.turnRight()
- turtle.turnRight()
- elseif endingdir == "right" or "r" then
- turtle.turnLeft()
- elseif endingdir == "left" or "l" then
- turtle.turnLeft()
- turtle.turnLeft()
- end
- elseif direction == "left" or "l" then
- turtle.turnLeft()
- for i = 1,distance,1 do
- if turtle.detect() == false then
- turtle.forward()
- end
- end
- if endingdir == "forward" or "f" then
- turtle.turnRight()
- elseif endingdir == "right" or "r" then
- turtle.turnRight()
- turtle.turnRight()
- elseif endingdir == "back" or "b" then
- turtle.turnLeft()
- end
- elseif direction == "up" or "u" then
- for i = 1,distance,1 do
- if turtle.detectUp() == false then
- turtle.up()
- end
- end
- if endingdir == "right" or "r" then
- turtle.turnRight()
- end
- elseif direction == "down" or "d" then
- else
- print("walk pass error")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment