Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitor = peripheral.wrap("back")
- local main_text_scale = 1
- local main_back_color = colors.black
- local main_text_color = colors.lightGray
- local w, h = monitor.getSize()
- monitor.clear()
- local button = {}
- local language = 1
- local page = 1
- local languages_amount = 2
- local pages_amount = 6
- function setupScreen()
- monitor.setTextScale(main_text_scale)
- monitor.setBackgroundColor(main_back_color)
- monitor.setTextColor(main_text_color)
- end
- --button-api start
- function convertColor(color)
- if color == "white" then
- return 1
- end
- if color == "lightgray" then
- return 256
- end
- if color == "gray" then
- return 128
- end
- if color == "black" then
- return 32768
- end
- if color == "brown" then
- return 4096
- end
- if color == "red" then
- return 16384
- end
- if color == "orange" then
- return 2
- end
- if color == "yellow" then
- return 16
- end
- if color == "lime" then
- return 32
- end
- if color == "green" then
- return 8192
- end
- if color == "blue" then
- return 2048
- end
- if color == "cyan" then
- return 512
- end
- if color == "lightblue" then
- return 8
- end
- if color == "purple" then
- return 1024
- end
- if color == "magenta" then
- return 4
- end
- if color == "pink" then
- return 64
- end
- end
- function setButton(name, caption, func, xpos, ypos, width, height, backColor, textColor)
- button[name] = {}
- button[name]["func"] = func
- button[name]["caption"] = caption
- button[name]["x"] = xpos
- button[name]["y"] = ypos
- button[name]["width"] = width
- button[name]["height"] = height
- button[name]["backColor"] = backColor
- button[name]["textColor"] = textColor
- button[name]["visible"] = false
- end
- function drawButton(title)
- for name, data in pairs(button) do
- if name == title then
- data["visible"] = true
- monitor.setBackgroundColor(convertColor(data["backColor"]))
- monitor.setTextColor(convertColor(data["textColor"]))
- local xspot = data["x"] + math.floor((data["width"] - string.len(data["caption"])) / 2 ) + 1
- local yspot = data["y"] + math.floor(data["height"] / 2) + 1
- for i = 1, data["height"] do
- for j = 1, data["width"] do
- monitor.setCursorPos(data["x"] + j, data["y"] + i)
- monitor.write(" ")
- end
- end
- monitor.setCursorPos(xspot, yspot)
- monitor.write(data["caption"])
- end
- end
- end
- function buttonHit(x, y)
- for name, data in pairs(button) do
- if data["visible"] == true then
- if math.floor(y) >= data["y"] + 1 and y <= data["y"] + data["height"] then
- if math.floor(x) >= data["x"] + 1 and x <= data["x"] + data["width"] then
- data["func"]()
- screen()
- return true
- end
- end
- end
- end
- end
- --button-api ende
- --alle button-fkt start
- function assignButtons()
- local caption = language_button_caption[language]
- setButton("Language", caption, nextLanguage, 0, (h-3), 12, 3, "red", "black")
- setButton("PageUp", "-->", pageUp, (w-7), (h-3), 7, 3, "red", "black")
- setButton("PageDown", "<--", pageDown, (w-15), (h-3), 7, 3, "red", "black")
- end
- function nextLanguage()
- language = language + 1
- if language == (languages_amount + 1) then
- language = 1
- end
- end
- function pageUp()
- page = page + 1
- if page == (pages_amount + 1) then
- page = 1
- end
- end
- function pageDown()
- page = page - 1
- if page == 0 then
- page = pages_amount
- end
- end
- function zeilenAnzahl()
- local b = 1
- while text[language][page][b] ~= nil do
- b = b + 1
- end
- return b-1
- end
- --alle Button-Fkt ende
- --alle Screen-Fkt start
- function drawButtons()
- assignButtons()
- drawButton("Language")
- drawButton("PageUp")
- drawButton("PageDown")
- end
- function drawHeading()
- local heading = heading_string[language][page]
- local string_length = string.len(heading)
- setupScreen()
- monitor.setTextColor(colors.red)
- monitor.setCursorPos((w - string_length) / 2 + 1, 2)
- monitor.write(heading)
- end
- function drawLines()
- setupScreen()
- for c = 1, zeilenAnzahl() do
- monitor.setCursorPos(3 , c + 3)
- monitor.write(text[language][page][c])
- end
- end
- function drawHighlights()
- for name, data in pairs(highlight) do
- if data["lang"] == language then
- if data["page"] == page then
- monitor.setBackgroundColor(convertColor(data["backColor"]))
- monitor.setTextColor(convertColor(data["textColor"]))
- local xspot = data["x"]
- local yspot = data["y"]
- monitor.setCursorPos(xspot, yspot)
- monitor.write(data["text"])
- end
- end
- end
- end
- function drawPageNumber()
- setupScreen()
- monitor.setCursorPos(w-2,1)
- monitor.write(string.gsub(page, ".0", ""))
- monitor.write("/")
- monitor.write(string.gsub(pages_amount, ".0", ""))
- end
- function screen()
- setupScreen()
- monitor.clear()
- drawButtons()
- drawHeading()
- drawLines()
- drawHighlights()
- drawPageNumber()
- end
- --alle Screen-Fkt ende
- function main()
- local event, button, x, y = os.pullEvent( "monitor_touch" )
- --if event == "mouse_click" then
- buttonHit(x, y)
- --end
- end
- function textZuweisen()
- --Change Language - Button
- language_button_caption = {}
- language_button_caption[1] = "English"
- language_button_caption[2] = "Deutsch"
- --Headings
- heading_string = {}
- for a = 1, languages_amount do
- heading_string[a] = {}
- end
- --Deutsch
- heading_string[1][1] = "Stadtregeln" --heading_string[language][page]
- heading_string[1][2] = "Grundstücksbezogene Regeln (Teil 1)"
- heading_string[1][3] = "Grundstücksbezogene Regeln (Teil 2)"
- heading_string[1][4] = "Grundstücksbezogene Regeln (Teil 3)"
- heading_string[1][5] = "Verbotene bzw. eingeschränkte Maschinen (Teil 1)"
- heading_string[1][6] = "Verbotene bzw. eingeschränkte Maschinen (Teil 2)"
- --English
- heading_string[2][1] = "City rules" --heading_string[language][page]
- heading_string[2][2] = "Rules for plots (Part 1)"
- heading_string[2][3] = "Rules for plots (Part 2)"
- heading_string[2][4] = "Rules for plots (Part 3)"
- heading_string[2][5] = "Banned or restricted devices (Part 1)"
- heading_string[2][6] = "Banned or restricted devices (Part 2)"
- --Lines
- text = {}
- for d = 1, languages_amount do
- text[d] = {}
- for e = 1, pages_amount do
- text[d][e] = {}
- end
- end
- --Deutsch
- text[1][1][1] = "Hier findest Du alle Regeln die Du beachten solltest wenn"
- text[1][1][2] = "Du Stadtmitglied bist oder ein Grundstück besitzt. Bitte"
- text[1][1][3] = "vollständig lesen, Unwissenheit schützt vor Strafe nicht!"
- text[1][1][4] = " "
- text[1][1][5] = "Die Serverregeln gelten hier insbesondere!"
- text[1][2][1] = "-> KEIN Weiterverkauf oder -mietung von Grundstücken!"
- text[1][2][2] = " "
- text[1][2][3] = "-> Unvollständig geclaimte Grundstücke werden komplett"
- text[1][2][4] = " gelöscht und es gibt keinen Schadensersatz!"
- text[1][2][5] = " "
- text[1][2][6] = "-> Maximal 1 Grundstück pro Spieler"
- text[1][2][7] = " "
- text[1][2][8] = "-> Die Glasdecke der Schnee-Grundstücke darf nicht"
- text[1][2][9] = " abgebaut oder verändert werden."
- text[1][3][1] = "-> Die maximale Bauhöhe beträgt y=100. Ausnahmen gelten"
- text[1][3][2] = " für die Wald-Grundstücke auf dem Plateau. Da diese"
- text[1][3][3] = " höher liegen darf auch etwas (10 Blöcke) höher gebaut"
- text[1][3][4] = " werden wenn das finale Bauwerk:"
- text[1][3][5] = " A) nicht überflüssig hoch / unfunktional ist und"
- text[1][3][6] = " B) nicht nicht gut aussieht"
- text[1][3][7] = " "
- text[1][3][8] = "-> Nach einem Perm-Ban wird ein GS entfernt, auch falls"
- text[1][3][9] = " dieser rückgängig gemacht werden sollte."
- text[1][4][1] = "-> Quickie-Häuser, auch bekannt als '10-Minuten-Häuser'"
- text[1][4][2] = " sind ungerne gesehen und werden nach missachteten"
- text[1][4][3] = " Hinweisen vom Stadtteam abgerissen."
- text[1][4][4] = " "
- text[1][4][5] = "-> Auch das allseits beliebte 'Ich pflanze nur Rubber "
- text[1][4][6] = " Trees'-Grundstück ist zu meiden, versucht schnellst-"
- text[1][4][7] = " möglich ein akzeptables Haus zu bauen."
- text[1][4][8] = " "
- text[1][4][9] = "-> Leerstehende Grundstücke können nach Hinweis von der"
- text[1][4][10] = " Stadt zurückgekauft werden."
- text[1][5][1] = "-> Alarme (Howler & Industrial Alarm) sind ausnahmslos "
- text[1][5][2] = " verboten!"
- text[1][5][3] = " "
- text[1][5][4] = "-> Dauerhafte Geräuschquellen (Noteblocks, Jukebox,"
- text[1][5][5] = " Maschinen mit zu wenig Strom) sind zu vermeiden!"
- text[1][5][6] = " "
- text[1][5][7] = "-> Harvester sind so zu verwenden dass die die "
- text[1][5][8] = " Bepflanzung der Stadtwege nicht abbauen - wir raten"
- text[1][5][9] = " zu unterirdischen Baumfarmen!"
- text[1][6][1] = "-> Reaktoren sind nur erlaubt wenn:"
- text[1][6][2] = " - von ihnen keine Gefahr ausgeht wenn der Besitzer "
- text[1][6][3] = " offline ist"
- text[1][6][4] = " - sie unterirdisch und in mindestens 1 Schicht von"
- text[1][6][5] = " Reinforced Stone eingebaut sind"
- text[1][6][6] = " - sie stabil ihre Temperatur halten"
- text[1][6][7] = " - keine Effekte in ihrer Umgebung verursachen (Fire,"
- text[1][6][8] = " Evaporation, Poison etc.)"
- --English
- text[2][1][1] = "Here you will find all the rules to obey if you are a"
- text[2][1][2] = "member of the city or own a plot. Please read all of"
- text[2][1][3] = "them, because 'ignorance is no excuse in law'!"
- text[2][1][4] = " "
- text[2][1][5] = "The server rules apply especially here!"
- text[2][2][1] = "-> NO reselling or rental of plots!"
- text[2][2][2] = " "
- text[2][2][3] = "-> Plots which aren't claimed fully will be deleted, and"
- text[2][2][4] = " there will be no compensation or payback!"
- text[2][2][5] = " "
- text[2][2][6] = "-> At most 1 plot (2x2) per player is allowed."
- text[2][2][7] = " "
- text[2][2][8] = "-> Don't change or break the glass roof on top of the"
- text[2][2][9] = " Taiga plots."
- text[2][3][1] = "-> You must not build any higher than y=100. Exceptions"
- text[2][3][2] = " are made for the forest plots on the plateau, because"
- text[2][3][3] = " their entrance is located higher. There you may build"
- text[2][3][4] = " up to 10 blocks higher if your building:"
- text[2][3][5] = " A) isn't unnecessarily high / not functional and"
- text[2][3][6] = " B) doesn't look hideous"
- text[2][3][7] = " "
- text[2][3][8] = "-> A plot gets deleted if the owner receives a permanent"
- text[2][3][9] = " ban, even if it gets reversed."
- text[2][4][1] = "-> Quick-Houses aka 'Dirt Blocks' etc. are not desired"
- text[2][4][2] = " and will be demolished after several allusions by"
- text[2][4][3] = " members of the city staff."
- text[2][4][4] = " "
- text[2][4][5] = "-> Also don't just plant some rubber trees and leave"
- text[2][4][6] = " (like most users do). Please try to set up a fine"
- text[2][4][7] = " building as soon as possible."
- text[2][4][8] = " "
- text[2][4][9] = "-> Plots which remain empty after obtaining can be bought"
- text[2][4][10] = " back by the town."
- text[2][5][1] = "-> Any alarms (Howler & Industrial Alarm) are completely"
- text[2][5][2] = " forbidden!"
- text[2][5][3] = " "
- text[2][5][4] = "-> Continuous noise sources (Noteblocks, Jukebox,"
- text[2][5][5] = " Maschines with not enough power) are also undesirable!"
- text[2][5][6] = " "
- text[2][5][7] = "-> Harvesters have to be used in a way not to interfere"
- text[2][5][8] = " with other plots or the trees on the paths. We"
- text[2][5][9] = " recommend to build tree farms below ground!"
- text[2][6][1] = "-> Nuclear Reactors are only allowed if:"
- text[2][6][2] = " - there is zero damage potential if their owner is"
- text[2][6][3] = " not online."
- text[2][6][4] = " - they were build below ground inside at least 1 layer"
- text[2][6][5] = " of Reinforced Stone."
- text[2][6][6] = " - they are able to remain a constant temperature."
- text[2][6][7] = " - there are no negative effects to other players (Fire,"
- text[2][6][8] = " Evaporation, Poison etc.) by e.g. a breeder reactor."
- --Highlights
- highlight = {}
- --setHighlight(id, sprache, seite, "text", xpos, ypos, "backcolor", "textcolor")
- --Deutsch
- setHighlight(1, 1, 1, "Die Serverregeln gelten hier insbesondere!", 3, 8, "black", "red")
- setHighlight(2, 1, 2, "Kein Weiterverkauf", 6, 4, "black", "red")
- setHighlight(3, 1, 2, "1", 14, 9, "black", "red")
- setHighlight(4, 1, 3, "y=100", 35, 4, "black", "red")
- setHighlight(5, 1, 5, "Alarme", 6, 4, "black", "red")
- setHighlight(6, 1, 6, "nur erlaubt", 21, 4, "black", "red")
- --English
- setHighlight(7, 2, 1, "The server rules apply especially here!", 3, 8, "black", "red")
- setHighlight(8, 2, 2, "NO reselling", 6, 4, "black", "red")
- setHighlight(9, 2, 2, "1", 14, 9, "black", "red")
- setHighlight(10, 2, 3, "y=100", 41, 4, "black", "red")
- setHighlight(11, 2, 5, "Any alarms", 6, 4, "black", "red")
- setHighlight(12, 2, 6, "only allowed", 27, 4, "black", "red")
- end
- function setHighlight(id, sprache, seite, text, xpos, ypos, backColor, textColor)
- highlight[id] = {}
- highlight[id]["lang"] = sprache
- highlight[id]["page"] = seite
- highlight[id]["text"] = text
- highlight[id]["x"] = xpos
- highlight[id]["y"] = ypos
- highlight[id]["backColor"] = backColor
- highlight[id]["textColor"] = textColor
- end
- textZuweisen()
- screen()
- while true do
- main()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement