Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function portal()
- local Locations = {}
- -- Replace the Zeros with the computer ID of the corresponding Turtle(s) the command to get the ID is print(os.getComputerID()) within the lua editor
- local pt1 = 0
- local pt2 = 0
- local pt3 = 0
- -- Name Your Locations Here due to screen constraints make sure the names are not longer than 11 characters:
- -- Turtle 1:
- Locations[01] = ""
- Locations[02] = ""
- Locations[03] = ""
- Locations[04] = ""
- Locations[05] = ""
- Locations[06] = ""
- Locations[07] = ""
- Locations[08] = ""
- Locations[09] = ""
- Locations[10] = ""
- Locations[11] = ""
- Locations[12] = ""
- Locations[13] = ""
- Locations[14] = ""
- Locations[15] = ""
- Locations[16] = ""
- -- Turtle 2:
- Locations[17] = ""
- Locations[18] = ""
- Locations[19] = ""
- Locations[20] = ""
- Locations[21] = ""
- Locations[22] = ""
- Locations[23] = ""
- Locations[24] = ""
- Locations[25] = ""
- Locations[26] = ""
- Locations[27] = ""
- Locations[28] = ""
- Locations[29] = ""
- Locations[30] = ""
- Locations[31] = ""
- Locations[32] = ""
- -- Turtle 3:
- Locations[33] = ""
- Locations[34] = ""
- Locations[35] = ""
- Locations[36] = ""
- Locations[37] = ""
- Locations[38] = ""
- Locations[39] = ""
- Locations[40] = ""
- Locations[41] = ""
- Locations[42] = ""
- Locations[43] = ""
- Locations[44] = ""
- Locations[45] = ""
- Locations[46] = ""
- Locations[47] = ""
- Locations[48] = ""
- -- if the portal is behaving strangely or not working at all try increasing this number:
- local wait = 1
- -- Monitor Output
- --primary monitor output:
- if peripheral.isPresent("top") then
- mon1 = peripheral.wrap("top")
- mon1.setTextScale(2)
- mon1.setCursorPos(1,1)
- mon1.clearLine(1)
- mon1.write("Destination:")
- mon1.setCursorPos(1,2)
- end
- --secondary monitor output to look properly the monitor needs to be 3 high and 5 wide:
- if peripheral.isPresent("back:green") then
- mon2 = peripheral.wrap("back:green")
- mon2.setTextScale(1)
- mon2.clear()
- mon2.setCursorPos(1,1)
- mon2.write("Destinations:")
- mon2.setCursorPos(1,2)
- -- turtle 1 destinations
- mon2.write ("01. " ..Locations[01])
- mon2.setCursorPos(1,3)
- mon2.write ("02. " ..Locations[02])
- mon2.setCursorPos(1,4)
- mon2.write ("03. " ..Locations[03])
- mon2.setCursorPos(1,5)
- mon2.write ("04. " ..Locations[04])
- mon2.setCursorPos(1,6)
- mon2.write ("05. " ..Locations[05])
- mon2.setCursorPos(1,7)
- mon2.write ("06. " ..Locations[06])
- mon2.setCursorPos(1,8)
- mon2.write ("07. " ..Locations[07])
- mon2.setCursorPos(1,9)
- mon2.write ("08. " ..Locations[08])
- mon2.setCursorPos(1,10)
- mon2.write ("09. " ..Locations[09])
- mon2.setCursorPos(1,11)
- mon2.write ("10. " ..Locations[10])
- mon2.setCursorPos(1,12)
- mon2.write ("11. " ..Locations[11])
- mon2.setCursorPos(1,13)
- mon2.write ("12. " ..Locations[12])
- mon2.setCursorPos(1,14)
- mon2.write ("13. " ..Locations[13])
- mon2.setCursorPos(1,15)
- mon2.write ("14. " ..Locations[14])
- mon2.setCursorPos(1,16)
- mon2.write ("15. " ..Locations[15])
- mon2.setCursorPos(1,17)
- mon2.write ("16. " ..Locations[16])
- -- turtle 2 destinations
- mon2.setCursorPos(18,2)
- mon2.write ("17. " ..Locations[17])
- mon2.setCursorPos(18,3)
- mon2.write ("18. " ..Locations[18])
- mon2.setCursorPos(18,4)
- mon2.write ("19. " ..Locations[19])
- mon2.setCursorPos(18,5)
- mon2.write ("20. " ..Locations[20])
- mon2.setCursorPos(18,6)
- mon2.write ("21. " ..Locations[21])
- mon2.setCursorPos(18,7)
- mon2.write ("22. " ..Locations[22])
- mon2.setCursorPos(18,8)
- mon2.write ("23. " ..Locations[23])
- mon2.setCursorPos(18,9)
- mon2.write ("24. " ..Locations[24])
- mon2.setCursorPos(18,10)
- mon2.write ("25. " ..Locations[25])
- mon2.setCursorPos(18,11)
- mon2.write ("26. " ..Locations[26])
- mon2.setCursorPos(18,12)
- mon2.write ("27. " ..Locations[27])
- mon2.setCursorPos(18,13)
- mon2.write ("28. " ..Locations[28])
- mon2.setCursorPos(18,14)
- mon2.write ("29. " ..Locations[29])
- mon2.setCursorPos(18,15)
- mon2.write ("30. " ..Locations[30])
- mon2.setCursorPos(18,16)
- mon2.write ("31. " ..Locations[31])
- mon2.setCursorPos(18,17)
- mon2.write ("32. " ..Locations[32])
- -- turtle 3 destinations
- mon2.setCursorPos(36,2)
- mon2.write ("33. " ..Locations[33])
- mon2.setCursorPos(36,3)
- mon2.write ("34. " ..Locations[34])
- mon2.setCursorPos(36,4)
- mon2.write ("35. " ..Locations[35])
- mon2.setCursorPos(36,5)
- mon2.write ("36. " ..Locations[36])
- mon2.setCursorPos(36,6)
- mon2.write ("37. " ..Locations[37])
- mon2.setCursorPos(36,7)
- mon2.write ("38. " ..Locations[38])
- mon2.setCursorPos(36,8)
- mon2.write ("39. " ..Locations[39])
- mon2.setCursorPos(36,9)
- mon2.write ("40. " ..Locations[40])
- mon2.setCursorPos(36,10)
- mon2.write ("41. " ..Locations[41])
- mon2.setCursorPos(36,11)
- mon2.write ("42. " ..Locations[42])
- mon2.setCursorPos(36,12)
- mon2.write ("43. " ..Locations[43])
- mon2.setCursorPos(36,13)
- mon2.write ("44. " ..Locations[44])
- mon2.setCursorPos(36,14)
- mon2.write ("45. " ..Locations[45])
- mon2.setCursorPos(36,15)
- mon2.write ("46. " ..Locations[46])
- mon2.setCursorPos(36,16)
- mon2.write ("47. " ..Locations[47])
- mon2.setCursorPos(36,17)
- mon2.write ("48. " ..Locations[48])
- end
- -- terminal output:
- term.clear()
- term.setCursorPos(1,1)
- print ("Valid Destination IDs are:")
- -- turtle 1 destinations
- term.setCursorPos(1,2)
- print ("01. " ..Locations[01])
- term.setCursorPos(1,3)
- print ("02. " ..Locations[02])
- term.setCursorPos(1,4)
- print ("03. " ..Locations[03])
- term.setCursorPos(1,5)
- print ("04. " ..Locations[04])
- term.setCursorPos(1,6)
- print ("05. " ..Locations[05])
- term.setCursorPos(1,7)
- print ("06. " ..Locations[06])
- term.setCursorPos(1,8)
- print ("07. " ..Locations[07])
- term.setCursorPos(1,9)
- print ("08. " ..Locations[08])
- term.setCursorPos(1,10)
- print ("09. " ..Locations[09])
- term.setCursorPos(1,11)
- print ("10. " ..Locations[10])
- term.setCursorPos(1,12)
- print ("11. " ..Locations[11])
- term.setCursorPos(1,13)
- print ("12. " ..Locations[12])
- term.setCursorPos(1,14)
- print ("13. " ..Locations[13])
- term.setCursorPos(1,15)
- print ("14. " ..Locations[14])
- term.setCursorPos(1,16)
- print ("15. " ..Locations[15])
- term.setCursorPos(1,17)
- print ("16. " ..Locations[16])
- -- turtle 2 destinations
- term.setCursorPos(18,2)
- print ("17. " ..Locations[17])
- term.setCursorPos(18,3)
- print ("18. " ..Locations[18])
- term.setCursorPos(18,4)
- print ("19. " ..Locations[19])
- term.setCursorPos(18,5)
- print ("20. " ..Locations[20])
- term.setCursorPos(18,6)
- print ("21. " ..Locations[21])
- term.setCursorPos(18,7)
- print ("22. " ..Locations[22])
- term.setCursorPos(18,8)
- print ("23. " ..Locations[23])
- term.setCursorPos(18,9)
- print ("24. " ..Locations[24])
- term.setCursorPos(18,10)
- print ("25. " ..Locations[25])
- term.setCursorPos(18,11)
- print ("26. " ..Locations[26])
- term.setCursorPos(18,12)
- print ("27. " ..Locations[27])
- term.setCursorPos(18,13)
- print ("28. " ..Locations[28])
- term.setCursorPos(18,14)
- print ("29. " ..Locations[29])
- term.setCursorPos(18,15)
- print ("30. " ..Locations[30])
- term.setCursorPos(18,16)
- print ("31. " ..Locations[31])
- term.setCursorPos(18,17)
- print ("32. " ..Locations[32])
- -- turtle 3 destinations
- term.setCursorPos(36,2)
- print ("33. " ..Locations[33])
- term.setCursorPos(36,3)
- print ("34. " ..Locations[34])
- term.setCursorPos(36,4)
- print ("35. " ..Locations[35])
- term.setCursorPos(36,5)
- print ("36. " ..Locations[36])
- term.setCursorPos(36,6)
- print ("37. " ..Locations[37])
- term.setCursorPos(36,7)
- print ("38. " ..Locations[38])
- term.setCursorPos(36,8)
- print ("39. " ..Locations[39])
- term.setCursorPos(36,9)
- print ("40. " ..Locations[40])
- term.setCursorPos(36,10)
- print ("41. " ..Locations[41])
- term.setCursorPos(36,11)
- print ("42. " ..Locations[42])
- term.setCursorPos(36,12)
- print ("43. " ..Locations[43])
- term.setCursorPos(36,13)
- print ("44. " ..Locations[44])
- term.setCursorPos(36,14)
- print ("45. " ..Locations[45])
- term.setCursorPos(36,15)
- print ("46. " ..Locations[46])
- term.setCursorPos(36,16)
- print ("47. " ..Locations[47])
- term.setCursorPos(36,17)
- print ("48. " ..Locations[48])
- -- computer output
- term.setCursorPos(1,18)
- print ("99. close Portal")
- term.setCursorPos(1,19)
- write ("Enter Destination ID: ")
- term.setCursorPos(23,19)
- -- Actual Code:
- local Num1 = ( read() )
- rednet.send(pt1,"99")
- if pt2 > 1 then
- rednet.send(pt2,"99")
- end
- if pt3 > 1 then
- rednet.send(pt3,"99")
- end
- if peripheral.isPresent("top") then
- mon1.clearLine(2)
- mon1.setCursorPos(1,2)
- if Num1 == "99" then
- mon1.write("Portal Closed")
- else
- mon1.write("Processing")
- end
- mon1.setCursorPos(1,2)
- end
- function dest()
- if peripheral.isPresent("top") then
- mon1.clearLine(2)
- mon1.write(Locations[Num1])
- end
- end
- os.sleep(wait)
- if tonumber(Num1) ~= nil then
- Num1 = tonumber(Num1)
- if (Num1>0) and (Num1<17) then
- dest()
- rednet.send(pt1,""..Num1)
- elseif (Num1>16) and (Num1<33) then
- dest()
- local Num2 = Num1 - 16
- rednet.send(pt2,""..Num2)
- elseif (Num1>32) and (Num1<49) then
- dest()
- local Num3 = Num1 - 32
- rednet.send(pt3,""..Num3)
- end
- else
- if peripheral.isPresent("top") then
- mon1.write("User Error")
- end
- end
- end
- while true do
- rednet.open("left")
- portal()
- end
Advertisement
Add Comment
Please, Sign In to add comment