Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Remote
- --zootsuitman 1/19/16
- local settings ={}
- local place ="Front"
- local current
- local selectedInv =1
- local loop =true
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- function split(pString, pPattern)
- local Table = {}
- local fpat = "(.-)" .. pPattern
- local last_end = 1
- local s, e, cap = pString:find(fpat, 1)
- while s do
- if s ~= 1 or cap ~= "" then
- table.insert(Table,cap)
- end
- last_end = e+1
- s, e, cap = pString:find(fpat, last_end)
- end
- if last_end <= #pString then
- cap = pString:sub(last_end)
- table.insert(Table, cap)
- end
- return Table
- end
- function screen1()
- clear()
- current =1
- clear()
- print("Welcome to " .. settings.name .. " net.")
- print("Move Forward: w\nMove Backwards: s")
- print("Turn Left: a\nTurn Right: d")
- print("Go Up: e\nGo Down: q")
- print("Mine/Attack: space\nPlace: tab")
- print("Pick up: lshift")
- print("Use Fuel: f")
- print("Inventory Slot: 1-9")
- print("Over 9 press rshift + num")
- print("Placement Mode: NUM 1,2,3")
- print("View Inventory: enter")
- write("Exit: backspace")
- term.setCursorPos(1,18)
- print("Fuel: " .. settings.fuel)
- print("Inventory Slot: " .. selectedInv)
- write("Placement Selection: " .. place)
- end
- function screen2()
- clear()
- current =2
- rednet.send(settings.id, "getInv", settings.name)
- local senderId, get, protocol =rednet.receive()
- local inv =textutils.unserialize(get)
- for i=1,16 do
- term.setCursorPos(1,i)
- write(i)
- if inv[i] then
- term.setCursorPos(4,i)
- local cut =split(inv[i].name,":")
- write(cut[2])
- term.setCursorPos(24,i)
- write("-" .. inv[i].count)
- end
- end
- term.setCursorPos(1,selectedInv)
- write("> ")
- term.setCursorPos(1,20)
- write("Control Screen: enter")
- end
- function move()
- if settings.fuel ~= "unlimited" then
- settings.fuel = settings.fuel -1
- if current == 1 then
- term.setCursorPos(7,18)
- write(settings.fuel .. " ")
- end
- end
- end
- --Start Program--
- rednet.open("back")
- clear()
- write("What is the turtles name?\n> ")
- settings.name =read()
- clear()
- write("Is it an attack turtle? (y/n)\n> ")
- local input =read()
- if input == "y" or input == "Y" then
- settings.attack =true
- end
- if settings.attack then
- rednet.broadcast("connect2", settings.name)
- else
- rednet.broadcast("connect", settings.name)
- end
- local senderId, msg, protocol =rednet.receive()
- settings.id =senderId
- settings.fuel =msg
- screen1()
- while loop do
- while true do
- function resetInv()
- if current ==2 then
- sleep(1)
- screen2()
- end
- end
- function fuel()
- local id, newFuel, probTrash =rednet.receive()
- settings.fuel =newFuel
- if current == 1 then
- term.setCursorPos(7,18)
- write(settings.fuel .. " ")
- else
- resetInv()
- end
- end
- local event, key = os.pullEvent("key")
- --Movement--
- if key == 17 then rednet.send(settings.id, "f", settings.name) move() break end
- if key == 31 then rednet.send(settings.id, "b", settings.name) move() break end
- if key == 32 then rednet.send(settings.id, "r", settings.name) break end
- if key == 30 then rednet.send(settings.id, "l", settings.name) break end
- if key == 16 then rednet.send(settings.id, "d", settings.name) move() break end
- if key == 18 then rednet.send(settings.id, "u", settings.name) move() break end
- --Actions--
- if key == 57 then rednet.send(settings.id, "m", settings.name) resetInv() break end
- if key == 15 then rednet.send(settings.id, "place", settings.name) resetInv() break end
- if key == 42 then rednet.send(settings.id, "pickup", settings.name) resetInv() break end
- if key == 33 then rednet.send(settings.id, "fuel", settings.name) fuel() break end
- --Inventory--
- function changeCursor(num)
- term.setCursorPos(1,selectedInv)
- write(selectedInv)
- term.setCursorPos(1,num)
- write("> ")
- end
- function changeSelec(num)
- term.setCursorPos(17,19)
- write(num .. " ")
- end
- function changeInv(num, plus)
- if num == 11 then num =1 end
- if plus then num = num+10 end
- rednet.send(settings.id, num-1, settings.name)
- if current == 2 then
- changeCursor(num-1)
- else
- changeSelec(num-1)
- end
- selectedInv = num-1
- end
- if key == 2 then changeInv(key,false) break end
- if key == 3 then changeInv(key,false) break end
- if key == 4 then changeInv(key,false) break end
- if key == 5 then changeInv(key,false) break end
- if key == 6 then changeInv(key,false) break end
- if key == 7 then changeInv(key,false) break end
- if key == 8 then changeInv(key,false) break end
- if key == 9 then changeInv(key,false) break end
- if key == 10 then changeInv(key,false) break end
- if key == 54 then
- event, key = os.pullEvent("key")
- if key < 8 then
- changeInv(key,true)
- else
- break
- end
- end
- --Directions--
- if key == 79 then
- rednet.send(settings.id, "mf", settings.name)
- term.setCursorPos(22,20)
- if current == 1 then write("Front ") end
- break
- end
- if key == 80 then
- rednet.send(settings.id, "mu", settings.name)
- term.setCursorPos(22,20)
- if current == 1 then write("Up ") end
- break
- end
- if key == 81 then
- rednet.send(settings.id, "md", settings.name)
- term.setCursorPos(22,20)
- if current == 1 then write("Down ") end
- break
- end
- --Screens--
- if key == 28 then
- if current == 1 then
- screen2()
- else
- screen1()
- end
- break
- end
- if key == 14 then
- loop =false
- rednet.send(settings.id, "reset", settings.name)
- os.reboot()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment