Advertisement
bobmarley12345

ShopDirectory_EAST

Feb 25th, 2022 (edited)
953
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.62 KB | None | 0 0
  1. Shop_L1 = { x = -1545, y = 30, z = -8 }
  2. Shop_L2 = { x = -1562, y = 30, z = -8 }
  3. Shop_L3 = { x = -1580, y = 30, z = -8 }
  4. Shop_L4 = { x = -1598, y = 30, z = -8 }
  5. Shop_L5 = { x = -1616, y = 30, z = -8 }
  6. Shop_R1 = { x = -1545, y = 30, z = 30 }
  7. Shop_R2 = { x = -1562, y = 30, z = 30 }
  8. Shop_R3 = { x = -1580, y = 30, z = 30 }
  9. Shop_R4 = { x = -1598, y = 30, z = 30 }
  10. Shop_R5 = { x = -1616, y = 30, z = 30 }
  11. Shop_H1 = { x = -1545, y = 38, z = 13 }
  12. Shop_L1 = { x = -1545, y = 30, z = 13 }
  13.  
  14. direction = "bottom"
  15. const_rent = "FOR RENT"
  16.  
  17. function getText(sign)
  18.     -- use sign.x, etc
  19.     return adminapi.getSignText("PlayerShop", sign.x, sign.y, sign.z, 0)
  20. end
  21.  
  22. function string.jsub(str, startIndex, endIndex)
  23.     if (endIndex == nil) then
  24.         endIndex = string.len(str) + 1
  25.     end
  26.    
  27.     return string.sub(str, startIndex, endIndex - 1)
  28. end
  29.  
  30. function cpos(x, y)
  31.     monitor.setCursorPos(x, y)
  32. end
  33. function writeText(x, y, text)
  34.     cpos(x, y)
  35.     monitor.write(text)
  36. end
  37.  
  38. function writeTextColour(x, y, text, brush)
  39.     cpos(x, y)
  40.     monitor.setTextColour(brush)
  41.     monitor.write(text)
  42.     monitor.setTextColour(colours.white)
  43. end
  44.  
  45. function writeCentered(x1, x2, y, text)
  46.     local len = string.len(text)
  47.     local mid = math.ceil(x1 + ((x2 - x1) / 2))
  48.     local startX = mid - (len / 2)
  49.     writeText(startX, y, text)
  50. end
  51.  
  52. function writeCenteredColour(x1, x2, y, text, brush)
  53.     local len = string.len(text)
  54.     local mid = math.ceil(x1 + ((x2 - x1) / 2))
  55.     local startX = mid - (len / 2)
  56.     writeTextColour(startX, y, text, brush)
  57. end
  58.  
  59. function drawLineV(x, y, height, brush)
  60.     for i = y, height, 1 do
  61.         writeTextColour(x, i, "|", brush)
  62.     end
  63. end
  64.  
  65. function drawLineH(x, y, width, brush)
  66.     for i = x, width, 1 do
  67.         writeTextColour(i, y, "-", brush)
  68.     end
  69. end
  70.  
  71. function writeSignBack(sign, x1, x2, y, isTop)
  72.     local text = getText(sign)
  73.     local brush = colours.orange
  74.     if (text == const_rent) then
  75.         brush = colours.green
  76.     end
  77.    
  78.     if (isTop) then
  79.         text = (text .. "(HIGH)")
  80.     else
  81.         text = (text .. "(LOW)")
  82.     end
  83.  
  84.     writeCenteredColour(x1, x2, y, text, brush)
  85. end
  86.  
  87. function writeSignLeft(sign, y, w, h)
  88.     local text = getText(sign)
  89.     local brush = colours.orange
  90.     if (text == const_rent) then
  91.         brush = colours.green
  92.     end
  93.    
  94.     writeTextColour(2, y, text, brush)
  95. end
  96.  
  97. function writeSignRight(sign, y, w, h)
  98.     local text = getText(sign);
  99.     local len = string.len(text)
  100.     local brush = colours.orange
  101.     if (text == const_rent) then
  102.         brush = colours.green
  103.     end
  104.     writeTextColour(w - len, y, text, brush)
  105. end
  106.  
  107. function main()
  108.     monitor = peripheral.wrap(direction)
  109.     cpos(1,1)
  110.     monitor.clear()
  111.     local w,h = monitor.getSize()
  112.  
  113.     monWidth = w
  114.     monHeight = h
  115.  
  116.     yOff = 2
  117.     mid = (w / 2)
  118.     gap = 2
  119.  
  120.     while (true) do
  121.         local i = 0
  122.         drawLineV(mid, 1, h, colours.red)
  123.         drawLineH(1, 4, w, colours.red)
  124.         writeSignBack(Shop_H1, 2, mid - 2, 2, true)
  125.         writeSignBack(Shop_L1, mid + 2, w - 2, 2, false)
  126.         writeSignLeft(Shop_L1, yOff + 4, w, h)
  127.         writeSignLeft(Shop_L2, yOff + 8, w, h)
  128.         writeSignLeft(Shop_L3, yOff + 12, w, h)
  129.         writeSignLeft(Shop_L4, yOff + 16, w, h)
  130.         writeSignLeft(Shop_L5, yOff + 20, w, h)
  131.         writeSignRight(Shop_R1, yOff + 4, w, h)
  132.         writeSignRight(Shop_R2, yOff + 8, w, h)
  133.         writeSignRight(Shop_R3, yOff + 12, w, h)
  134.         writeSignRight(Shop_R4, yOff + 16, w, h)
  135.         writeSignRight(Shop_R5, yOff + 20, w, h)
  136.         os.sleep(10)
  137.     end
  138. end
  139.  
  140. main()
  141.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement