Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = {...}
- local pdat,tvnt,cnslID,pdamtd = {ln = 0,icn = 1,scrn = {},pda = {},},{},os.computerID()
- for i,v in pairs(rs.getSides()) do
- if peripheral.getType(v) == "receiver" then
- pdamtd = peripheral.wrap(v) break
- end end
- local wrtpdln = function(txtln)
- print(txtln)
- if pdamtd.connected() > 0 then
- for i = 1,math.ceil(#txtln/27) do pdat.ln = pdat.ln+1
- pdat.scrn[pdat.ln] = txtln:sub((i-1)*27+1,i*27)
- end
- local ndx = pdat.ln-19
- for i = 1,20 do
- if pdat.scrn[ndx] then
- for k,v in pairs(pdat.pda) do pdamtd.setText(i,pdat.scrn[ndx],k) end
- end
- ndx = ndx+1
- end
- for i,v in pairs(pdat.pda) do pdamtd.setIcon(3,i) pdamtd.setTitle("Text Update",i) end
- end
- end
- local rdpdln = function()
- local txtln = ""
- if pdamtd.connected() > 0 then
- write("input from PDA")
- for i,v in pairs(pdat.pda) do pdamtd.setIcon(5,i) pdamtd.setTitle("Enter Text",i) end
- repeat tvnt = {os.pullEvent()}
- if tvnt[1] == "pda_char" then txtln = txtln..tvnt[3]
- elseif tvnt[1] == "pda_key" and tvnt[3] == 14 then
- txtln = txtln:sub(1,#txtln-1)
- end
- for i = 0,math.floor(#txtln/27) do
- pdamtd.setText(i,txtln:sub(i*27+1,(i+1)*27),tvnt[2])
- end
- until tvnt[1] == "pda_key" and tvnt[3] == 28
- for i,v in pairs(pdat.pda) do pdamtd.setIcon(7,i) pdamtd.setTitle("...",i) end
- pdamtd.setTitle("Entered",tvnt[2]) pdamtd.setIcon(6,tvnt[2])
- else write("input>") txtln = read() end
- return txtln
- end
- local function opnmdm()
- for i,v in pairs(rs.getSides()) do
- if peripheral.getType(v) == "modem" then
- if not rednet.isOpen(v) then rednet.open(v) end
- return true end
- end
- return false end
- if pdamtd then
- if tArgs[1] then pdat.chnl = tArgs[1]
- else print("Enter Channel") pdat.chnl = read() end
- local strtfl = fs.open("startup","w")
- strtfl.writeLine("shell.run(\"rcpda\",\""..pdat.chnl.."\")") strtfl.close()
- pdamtd.setChannel(pdat.chnl)
- print([[Test loop activated, use pda
- on receiver to connect, press
- keys on pda to register pda,
- \"X\" on pda to exit]])
- else print("No pda receiver present") end
- repeat
- tvnt = {os.pullEvent()}
- if tvnt[1] == "pda_connected" then
- pdamtd.setIcon(8,tvnt[2]) pdamtd.setTitle("Connected to terminal"..cnslID,tvnt[2])
- pdamtd.setText(0,"Welcome to C-Provider",tvnt[2])
- elseif tvnt[1] == "pda_key" then pdat.pda[tvnt[2]] = true
- wrtpdln("Key: "..tvnt[3].." pressed on PDA "..tvnt[2]) pdamtd.setIcon(4,tvnt[2])
- pdamtd.alert("Connected to terminal"..cnslID,tvnt[2]) end
- until tvnt[1] == "pda_char" and tvnt[3] == "X"
- local rcmdlst = {
- [0] = "bmb",[79] = "place",[80] = "back",[81] = "ddn",[75] = "turnLeft",[76] = "tnl",
- [77] = "turnRight",[71] = "placeUp",[72] = "dfd",[73] = "dup",[82] = "placeDown",
- [83] = "drop8",[74] = "rfl",[78] = "slct",[181] = "gpshst",[55] = "gpslct",[28] = "pckup",
- [210] = "place",[211] = "dig",[199] = "dropUp8",[207] = "dropDown8",[201] = "up",[209] = "down",
- [200] = "forward",[208] = "back",[203] = "turnLeft",[205] = "turnRight",[26] = "digUp",
- [27] = "digDown",[51] = "suckUp",[52] = "suckDown",[29] = "trmn8RC",
- }
- local function setID() wrtpdln("Enter receiver ID") return tonumber(rdpdln()) end
- shell.run('clear')
- if not opnmdm() then wrtpdln("Modem Access Error") return false end
- local rcID = nil
- repeat rcID = setID() until rcID
- wrtpdln("Receiver ID set to "..rcID)
- wrtpdln("Press \"h\" for help")
- for i,v in pairs(pdat.pda) do pdamtd.setIcon(4,i) end
- repeat
- tvnt = {os.pullEvent()}
- if tvnt[1] == "pda_key" and rcmdlst[tvnt[3]] then rednet.send(rcID,rcmdlst[tvnt[3]])
- pdamtd.setTitle("Sent \""..rcmdlst[tvnt[3]].."\" to "..rcID,tvnt[2])
- if tvnt[3] == 29 then rcID = setID() end
- elseif tvnt[1] == "rednet_message" then wrtpdln(tvnt[2]..": "..tvnt[3])
- for i,v in pairs(pdat.pda) do pdamtd.setIcon(2,i) pdamtd.setTitle("Message from "..tvnt[2],i) end
- if tvnt[3]:find("^send") then rednet.send(tvnt[2],rdpdln()) end
- elseif tvnt[3] == "S" then rednet.send(rcID,rdpdln())
- pdamtd.setIcon(1,tvnt[2]) pdamtd.setTitle("Rednet Sent",tvnt[2])
- elseif tvnt[3] == "R" then rcID = setID() pdamtd.setIcon(8,tvnt[2])
- elseif tvnt[3] == "h" or tvnt[3] == "H" then
- wrtpdln("Use \"R\" change receiver Use \"S\" to send text")
- wrtpdln("Change receiver to nil to exit rcpda")
- wrtpdln("Use numberpad to control turtles: 284693 to digmove 5 to tunnel, 170 to place '.' Home End, to drop")
- wrtpdln("Enter, <, >, to suck Del, [, ] to dig")
- wrtpdln("Direction Keys and PgUp/Dn to move")
- end
- until not rcID
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement