Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MonitorSide = "left"
- Monitor = peripheral.wrap(MonitorSide)
- function GetMonSize()
- if ((Monitor == nil) == false) then
- return Monitor.getSize()
- else
- return 0,0
- end
- end
- function DrawText(xPos, yPos, text, textColour, backgroundColour)
- Monitor.setBackgroundColor(backgroundColour)
- Monitor.setTextColor(textColour)
- Monitor.setCursorPos(xPos,yPos)
- Monitor.write(text)
- end
- function DrawCenteredHorizontal(xPos, yPos, width, text, textColour, backgroundColour)
- -- width could be the size of your monitor, or anything else. this means it
- -- doesn't have to stretch your entire monitor's if you want. imagine
- -- it as a rectangle and the text is in the center.
- local textLength = string.len(text)
- local centerX = (width / 2) - (textLength / 2)
- DrawText(xPos + centerX, yPos, text, textColour, backgroundColour)
- end
- function DrawSquare(xPos, yPos, nWidth, nHeight, backgroundColour)
- Monitor.setBackgroundColor(backgroundColour)
- Monitor.setTextColor(backgroundColour)
- for i = 1, math.ceil(nHeight), 1 do
- Monitor.setCursorPos(xPos, yPos + (i - 1))
- Monitor.write(string.rep(" ", nWidth))
- end
- end
- ParticlePos = {}
- ParticleColour = colours.white
- ParticleColourBorder = colours.black
- ParticleSizeX = 5
- ParticleSizeY = 3
- ParticleSpeed = 1
- Direction = { left = 1, up = 2, right = 3, down = 4}
- ParticleDirection = Direction.right
- GeneratorStatusDirection = "bottom"
- function IsGeneratorOn()
- return redstone.getInput(GeneratorStatusDirection)
- end
- function Main()
- local PAStartX = 4
- local PAStartY = 4
- ParticlePos.x = PAStartX
- ParticlePos.y = PAStartY
- while true do
- local w, h = GetMonSize()
- local centerY = math.floor(h / 2) + 1
- local PAWidth = w - PAStartX - 2
- local PAHeight = h - PAStartY - 1
- local PAEndX = PAWidth-- + math.floor(ParticleSizeX / 2)
- local PAEndY = PAHeight + math.floor(ParticleSizeY / 2)
- if (ParticleDirection == Direction.right) then
- ParticlePos.x = ParticlePos.x + ParticleSpeed
- end
- if (ParticleDirection == Direction.down) then
- ParticlePos.y = ParticlePos.y + ParticleSpeed
- end
- if (ParticleDirection == Direction.left) then
- ParticlePos.x = ParticlePos.x - ParticleSpeed
- end
- if (ParticleDirection == Direction.up) then
- ParticlePos.y = ParticlePos.y - ParticleSpeed
- end
- if ((ParticleDirection ~= Direction.left) and (ParticlePos.x >= PAEndX)) then
- ParticleDirection = Direction.down
- end
- if ((ParticleDirection ~= Direction.up) and (ParticlePos.y >= PAEndY)) then
- ParticleDirection = Direction.left
- end
- if ((ParticleDirection == Direction.left) and (ParticlePos.x == PAStartX)) then
- ParticleDirection = Direction.up
- end
- if ((ParticleDirection == Direction.up) and ((ParticlePos.x == PAStartX) and (ParticlePos.y == PAStartY))) then
- ParticleDirection = Direction.right
- end
- local bgColour
- local genOn
- if (IsGeneratorOn()) then
- bgColour = colours.green
- genOn = true
- else
- bgColour = colours.red
- genOn = false
- end
- Monitor.setBackgroundColor(bgColour)
- Monitor.setTextColor(bgColour)
- Monitor.clear()
- --DrawSquare(ParticlePos.x - 2, ParticlePos.y - 1, ParticleSizeX + 4, ParticleSizeY + 2, ParticleColourBorder)
- DrawSquare(PAStartX + 2, PAStartY + 1, PAWidth - 3, PAHeight - 2, colours.orange)
- DrawSquare(PAStartX + 3, PAStartY + 2, PAWidth - 5, PAHeight - 4, bgColour)
- DrawSquare(ParticlePos.x, ParticlePos.y, ParticleSizeX, ParticleSizeY, ParticleColour)
- Monitor.setTextColor(colours.white)
- if (genOn) then
- DrawCenteredHorizontal(1, centerY - 1, w, "Dark Matter Generator", colours.white, colours.green)
- DrawCenteredHorizontal(1, centerY, w, "ONLINE", colours.white, colours.green)
- else
- DrawCenteredHorizontal(1, centerY - 1, w, "Dark Matter Generator", colours.white, colours.red)
- DrawCenteredHorizontal(1, centerY, w, "OFFLINE", colours.white, colours.red)
- end
- sleep(0.1)
- end
- end
- Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement