Advertisement
SirSheepe

Untitled

May 7th, 2023 (edited)
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.16 KB | None | 0 0
  1. -- saT1VV7K
  2.  
  3. local args = { ... }
  4.  
  5. if #args ~= 1 then
  6. error("Please provide the channel to listen on")
  7. end
  8.  
  9. local modem = peripheral.find("modem")
  10.  
  11. if modem == nil or not modem.isWireless() then
  12. error("Please connect a wireless modem to the pocket computer")
  13. end
  14.  
  15. local channel = tonumber(args[1])
  16.  
  17. modem.open(channel)
  18.  
  19. term.setPaletteColor(colors.orange, 0x2c2d30) -- discord light
  20. term.setPaletteColor(colors.magenta, 0x232427) -- discord darker
  21. term.setPaletteColor(colors.lightBlue, 0x5D5A63) -- discord lighter
  22. term.setPaletteColor(colors.yellow, 0xA09DA6) -- discord lightest
  23. term.setPaletteColor(colors.lime, 0xe5e57b) -- discord lightest
  24. term.setPaletteColor(colors.pink, 0x85818D)
  25. term.setPaletteColor(colors.gray, 0x07C8F9) -- scanning
  26. term.setPaletteColor(colors.lightGray, 0x5CB270) -- found ore
  27. term.setPaletteColor(colors.cyan, 0xf94144) -- bad
  28. term.setPaletteColor(colors.purple, 0xc77dff) -- storing
  29. term.setPaletteColor(colors.blue, 0x6A6771) --
  30. term.setPaletteColor(colors.brown, 0x7C7A81) --
  31. term.setPaletteColor(colors.green, 0x817F86) --
  32.  
  33. local signaled = false
  34. local mapsx, mapsz
  35. local mnsx, mnsy
  36.  
  37. while true do
  38. local _, _, senderChannel, _, message = os.pullEvent("modem_message")
  39.  
  40. if senderChannel == channel then
  41. local map = message[1]
  42. local pos = message[2]
  43. local dir = message[3]
  44. local aim = { x = pos.x + dir.x, z = pos.z + dir.z }
  45. local status = message[4]
  46.  
  47. local sx = #map[pos.y]
  48. local sz = #map[pos.y][0]
  49.  
  50. local msx, msy = term.getSize()
  51.  
  52. if signaled == false or mapsz ~= sz or mapsx ~= sx or mnsx ~= msx or mnsy ~= msy then
  53. signaled = true
  54. term.clear()
  55. term.setBackgroundColor(colors.magenta)
  56.  
  57. mapsx = sx
  58. mapsz = sz
  59. mnsy = msy
  60. mnsx = msx
  61. end
  62.  
  63. term.setCursorPos((msx - sx) * 0.5, (msy - sz) * 0.5)
  64.  
  65. local smap = {}
  66.  
  67. for i = 0, sz do
  68. local str = ""
  69. for j = 0, sx do
  70. if i == pos.z and j == pos.x then
  71. if status == 0 then
  72. str = str .. "5"
  73. elseif status == 1 then
  74. str = str .. "7"
  75. elseif status == 2 then
  76. str = str .. "8"
  77. elseif status == 3 then
  78. str = str .. "9"
  79. elseif status == 4 then
  80. str = str .. "a"
  81. end
  82. elseif i == aim.z and j == aim.x and map[pos.y][j][i] == 0 then
  83. str = str .. "b"
  84. elseif i == aim.z and j == aim.x then
  85. str = str .. "6"
  86. else
  87. -- c is darker mined
  88. -- 4 is lighter mined
  89. -- 1 is darker solid
  90. -- 3 is lighter solid
  91. if map[pos.y - 1] ~= nil then --
  92. if map[pos.y][j][i] == 0 then
  93. if map[pos.y - 1][j][i] == 1 then
  94. str = str .. "3"
  95. else
  96. str = str .. "1"
  97. end
  98. else
  99. if map[pos.y - 1][j][i] == 1 then
  100. str = str .. "c"
  101. else
  102. str = str .. "4"
  103. end
  104. end
  105. else
  106. if map[pos.y][j][i] == 1 then
  107. str = str .. "4"
  108. else
  109. str = str .. "3"
  110. end
  111. end
  112. end
  113. end
  114. smap[i + 1] = str
  115. end
  116.  
  117. for i = 1, #smap do
  118. term.setCursorPos((msx - sx) * 0.5 + 1, (msy - sz) * 0.5 + i)
  119. term.blit(string.rep(" ", #smap[i]), smap[i], smap[i])
  120. end
  121.  
  122. term.setCursorPos(2, #smap + 1)
  123. end
  124. end
  125.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement