Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shop_L1 = { x = -1726, y = 30, z = 30 }
- Shop_L2 = { x = -1710, y = 30, z = 30 }
- Shop_L3 = { x = -1692, y = 30, z = 30 }
- Shop_L4 = { x = -1674, y = 30, z = 30 }
- Shop_L5 = { x = -1656, y = 30, z = 30 }
- Shop_R1 = { x = -1726, y = 30, z = -8 }
- Shop_R2 = { x = -1710, y = 30, z = -8 }
- Shop_R3 = { x = -1692, y = 30, z = -8 }
- Shop_R4 = { x = -1674, y = 30, z = -8 }
- Shop_R5 = { x = -1656, y = 30, z = -8 }
- Shop_H1 = { x = -1731, y = 38, z = 18 }
- Shop_H2 = { x = -1731, y = 38, z = 4 }
- direction = "bottom"
- const_rent = "FOR RENT"
- function getText(sign, line)
- if (line == nil) then
- line = 0
- end
- -- use sign.x, etc
- return adminapi.getSignLine("PlayerShop", sign.x, sign.y, sign.z, line)
- end
- function string.jsub(str, startIndex, endIndex)
- if (endIndex == nil) then
- endIndex = string.len(str) + 1
- end
- return string.sub(str, startIndex, endIndex - 1)
- end
- function cpos(x, y)
- monitor.setCursorPos(x, y)
- end
- function writeText(x, y, text)
- cpos(x, y)
- monitor.write(text)
- end
- function writeTextColour(x, y, text, brush)
- cpos(x, y)
- monitor.setTextColour(brush)
- monitor.write(text)
- monitor.setTextColour(colours.white)
- end
- function writeCentered(x1, x2, y, text)
- local len = string.len(text)
- local mid = math.ceil(x1 + ((x2 - x1) / 2))
- local startX = mid - (len / 2)
- writeText(startX, y, text)
- end
- function writeCenteredColour(x1, x2, y, text, brush)
- local len = string.len(text)
- local mid = math.ceil(x1 + ((x2 - x1) / 2))
- local startX = mid - (len / 2)
- writeTextColour(startX, y, text, brush)
- end
- function drawLineV(x, y, height, brush)
- for i = y, height, 1 do
- writeTextColour(x, i, "|", brush)
- end
- end
- function drawLineH(x, y, width, brush)
- for i = x, width, 1 do
- writeTextColour(i, y, "-", brush)
- end
- end
- function writeSignTop(sign, x1, x2, y)
- local text = string.jsub(getText(sign), 3)
- local brush = colours.orange
- if (text == const_rent) then
- brush = colours.green
- else
- text = string.jsub(getText(sign, 3), 3)
- end
- writeCenteredColour(x1, x2, y, text, brush)
- end
- function writeSignLeft(sign, y, w, h)
- local text = string.jsub(getText(sign), 3)
- local brush = colours.orange
- if (text == const_rent) then
- brush = colours.green
- else
- text = string.jsub(getText(sign, 3), 3)
- end
- writeTextColour(2, y, text, brush)
- end
- function writeSignRight(sign, y, w, h)
- local text = string.jsub(getText(sign), 3)
- local len = string.len(text)
- local brush = colours.orange
- if (text == const_rent) then
- brush = colours.green
- else
- text = string.jsub(getText(sign, 3), 3)
- end
- writeTextColour(w - len, y, text, brush)
- end
- function main()
- monitor = peripheral.wrap(direction)
- cpos(1,1)
- monitor.clear()
- local w,h = monitor.getSize()
- monWidth = w
- monHeight = h
- yOff = 2
- mid = (w / 2)
- gap = 2
- while (true) do
- local i = 0
- drawLineV(mid, 1, h, colours.red)
- drawLineH(1, 4, w, colours.red)
- writeSignTop(Shop_H1, 2, mid - 2, 2)
- writeSignTop(Shop_H2, mid + 2, w - 2, 2)
- writeSignLeft(Shop_L1, yOff + 4, w, h)
- writeSignLeft(Shop_L2, yOff + 8, w, h)
- writeSignLeft(Shop_L3, yOff + 12, w, h)
- writeSignLeft(Shop_L4, yOff + 16, w, h)
- writeSignLeft(Shop_L5, yOff + 20, w, h)
- writeSignRight(Shop_R1, yOff + 4, w, h)
- writeSignRight(Shop_R2, yOff + 8, w, h)
- writeSignRight(Shop_R3, yOff + 12, w, h)
- writeSignRight(Shop_R4, yOff + 16, w, h)
- writeSignRight(Shop_R5, yOff + 20, w, h)
- os.sleep(10)
- end
- end
- main()
Add Comment
Please, Sign In to add comment