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 = 7
- 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, "green", "black")
- setButton("PageUp", "-->", pageUp, (w-7), (h-3), 7, 3, "green", "black")
- setButton("PageDown", "<--", pageDown, (w-15), (h-3), 7, 3, "green", "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.green)
- 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] = "Leistungen der Stadt" --heading_string[language][page]
- heading_string[1][2] = "Stadtstrom (Teil 1)"
- heading_string[1][3] = "Stadtstrom (Teil 2)"
- heading_string[1][4] = "Kostenlose Maschinen"
- heading_string[1][5] = "Sehenswürdigkeiten"
- heading_string[1][6] = "Sonstiges"
- heading_string[1][7] = "Drucker"
- --English
- heading_string[2][1] = "Advantages of Fontania" --heading_string[language][page]
- heading_string[2][2] = "City current (Part 1)"
- heading_string[2][3] = "City current (Part 2)"
- heading_string[2][4] = "Free machines"
- heading_string[2][5] = "Sights"
- heading_string[2][6] = "Other"
- heading_string[2][7] = "Prnter"
- --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] = "Diese Tafel gibt Dir einen Überblick und weitere"
- text[1][1][2] = "Informationen zu allen Leistungen der Stadt die"
- text[1][1][3] = "Du nutzen kannst, wenn du der Stadt beitrittst!"
- text[1][2][1] = "Jedes Grundstück hat im Preis enthalten einen Strom-"
- text[1][2][2] = "Anschluss, genannt Stadtstrom, welcher durch ein "
- text[1][2][3] = "HV-Solar-Array an einer MFSU versorgt wird. Daher "
- text[1][2][4] = "ist zu beachten:"
- text[1][2][5] = "-> Der ausgegebene Strom hat HV-Stärke! Die meisten"
- text[1][2][6] = " Maschinen explodieren ohne entsprechende Trans-"
- text[1][2][7] = " formatoren, welche wir aber bereitstellen und "
- text[1][2][8] = " benutzt werden dürfen."
- text[1][2][9] = "-> Für durch fehlerhafte Anwendung des HV-Stroms "
- text[1][2][10] = " zerstörte Maschinen übernehmen wir keine Haftung!"
- text[1][3][1] = "-> Der Anschluss ist keine unendliche Stromquelle!"
- text[1][3][2] = " Wenn Du mehr Strom aus der MFSU ziehst als das"
- text[1][3][3] = " HV-Solar nachliefert hast du über Nacht KEINEN"
- text[1][3][4] = " Strom! Dies ist insbesondere der Fall wenn ein"
- text[1][3][5] = " Mass Fabricator direkt durch Stadtstrom betrieben"
- text[1][3][6] = " wird."
- text[1][3][7] = "-> BatBox sowie Transformatoren dürfen auch verlegt,"
- text[1][3][8] = " abgebaut oder behalten werden - sie sind im Preis "
- text[1][3][9] = " inklusive."
- text[1][3][10] = "-> Dies gilt NICHT für das HV Solar und die MFSU!!"
- text[1][4][1] = "Am Stadtspawn finden sich allerlei Maschinen und"
- text[1][4][2] = "Apparate, welche durch Stadtbewohner nutzbar sind."
- text[1][4][3] = "Dazu zählen:"
- text[1][4][4] = "-> Electric Furnace, Macerator, Extractor und"
- text[1][4][5] = " Compressor"
- text[1][4][6] = "-> Pulverizer, Induction Smelter, Magma Crucible"
- text[1][4][7] = " und Liquid Transposer"
- text[1][4][8] = "-> Assembly Table mit 36 Lasern"
- text[1][4][9] = "-> Enchanting Table mit Anvils"
- text[1][4][10] = "-> Der schnellste Universal Charger auf dem Server"
- text[1][5][1] = "-> Stadtteil Ocean - für das Grundstück mit See-Blick!"
- text[1][5][2] = " Auch befindet sich hier der Stadt-Tauschshop."
- text[1][5][3] = " "
- text[1][5][4] = "-> U-Bahn-System verbindet Fontania, Ocean und Babulmia"
- text[1][5][5] = " "
- text[1][5][6] = "-> Stausee, Hobbit-Höhle, Gartenverein - von Usern"
- text[1][5][7] = " errichtete Sehenswürdigkeiten"
- text[1][5][8] = " "
- text[1][5][9] = "-> Stammi-Haus - Mustergültiges Grundstück zum"
- text[1][5][10] = " Selbstvergleich vor der eigenen Stammi-Bewerbung"
- text[1][6][1] = "-> Für jeden nutzbare XP-Farm links am Stadtspawn"
- text[1][6][2] = " "
- text[1][6][3] = "-> Jeder neue Spieler erhält nach einmaliger Anfrage ein"
- text[1][6][4] = " gratis Jetpack!"
- text[1][6][5] = " "
- text[1][6][6] = "-> Auf Grundstücken im Schnee-Biom fällt kein Schnee!"
- text[1][6][7] = " "
- text[1][6][8] = "-> Wir haben einen eigenen TeamSpeak-Channel auf dem"
- text[1][6][9] = " Lycodon-TeamSpeak-Server (server.lycodon.com)"
- text[1][6][10] = " "
- text[1][6][11] = "-> Alle Erlöse aus MagmaLP's Shop gehen an die Stadt"
- text[1][7][1] = "Wenn Du zu fau.. ähhm beschäftigt bist alle Regeln"
- text[1][7][2] = "durchzulesen hast Du hier die Möglichkeit eine"
- text[1][7][3] = "Kurzfassung der Stadtregeln kostenlos auszudrucken"
- text[1][7][4] = "und mitzunehmen!"
- text[1][7][5] = " "
- text[1][7][6] = " [Demnächst verfügbar!]"
- --English
- text[2][1][1] = "This screen shows you everything our city has to"
- text[2][1][2] = "offer. All of the following things are usable for"
- text[2][1][3] = "free if you are a member of Fontania!"
- text[2][2][1] = "Every plot has a High Voltage current, called 'City"
- text[2][2][2] = "current', which can be used by all people living on "
- text[2][2][3] = "this plot. Its powered by an HV Solar connected to"
- text[2][2][4] = "a MFSU, therefore keep in mind:"
- text[2][2][5] = "-> The current has a strength of 512eu/t, so most"
- text[2][2][6] = " machines will explode without the usage of trans-"
- text[2][2][7] = " formers. However, we provide fitting transformers"
- text[2][2][8] = " to be used by the plot owners."
- text[2][2][9] = "-> We don't provide replacements for things destroyed"
- text[2][2][10] = " due to wrong usage of the city current!"
- text[2][3][1] = "-> The city current is not an infinite power source."
- text[2][3][2] = " If you suck more power out of the MFSU than the"
- text[2][3][3] = " Solar Array can produce you won't have power at"
- text[2][3][4] = " night time! This will happen especially if you power"
- text[2][3][5] = " a Mass Fabricator off the city current, which is"
- text[2][3][6] = " why we highly recommend against it."
- text[2][3][7] = "-> You can move, break or keep the BatBox as well as"
- text[2][3][8] = " the transformers, because they are fully included"
- text[2][3][9] = " in the plot's price."
- text[2][3][10] = "-> This does NOT apply to the HV Solar or the MFSU!!"
- text[2][4][1] = "Located at the city spawn you can find a lot of"
- text[2][4][2] = "useful machines, to be used by members of the city."
- text[2][4][3] = "These are:"
- text[2][4][4] = "-> Electric Furnace, Macerator, Extractor and"
- text[2][4][5] = " Compressor"
- text[2][4][6] = "-> Pulverizer, Induction Smelter, Magma Crucible"
- text[2][4][7] = " and Liquid Transposer"
- text[2][4][8] = "-> Assembly Table powered by 36 Lasers"
- text[2][4][9] = "-> Enchanting Table with Anvils"
- text[2][4][10] = "-> The fastest Universal Charger on the server"
- text[2][5][1] = "-> Outpost Ocean - for a plot with a view on the"
- text[2][5][2] = " ocean! You also find the exchange shop here."
- text[2][5][3] = " "
- text[2][5][4] = "-> Underground railway system to connect city parts"
- text[2][5][5] = " "
- text[2][5][6] = "-> Stausee, Hobbit-Höhle, Gartenverein - build by"
- text[2][5][7] = " city members!"
- text[2][5][8] = " "
- text[2][5][9] = "-> 'Stammi'-House - this is a demo plot to compare"
- text[2][5][10] = " with your own plot before applying for Stammi."
- text[2][6][1] = "-> XP-Farm at the spawn is usable for everyone."
- text[2][6][2] = " "
- text[2][6][3] = "-> Every new member gets a free Jetpack once, but"
- text[2][6][4] = " you may ask us for that."
- text[2][6][5] = " "
- text[2][6][6] = "-> No annoying snowfall on Tundra biome plots!"
- text[2][6][7] = " "
- text[2][6][8] = "-> We do have an own TeamSpeak-Channel on the server"
- text[2][6][9] = " provided by Lycodon (server.lycodon.com)!"
- text[2][6][10] = " "
- text[2][6][11] = "-> All revenue of MagmaLP's Shop will help the city"
- text[2][7][1] = "If you were to laz... ehhm busy to read all of the"
- text[2][7][2] = "rules you have the chance to print them here instead"
- text[2][7][3] = "for free! They are a lot shorter and you can take them"
- text[2][7][4] = "anywhere you want!"
- text[2][7][5] = " "
- text[2][7][6] = " [Available very soon!]"
- --Highlights
- highlight = {}
- --setHighlight(id, sprache, seite, "text", xpos, ypos, "backcolor", "textcolor")
- --Deutsch
- setHighlight(1, 1, 2, "Stadtstrom", 22, 5, "black", "green")
- setHighlight(2, 1, 4, "durch Stadtbewohner nutzbar", 20, 5, "black", "green")
- setHighlight(3, 1, 5, "Stadtteil Ocean", 6, 4, "black", "green")
- setHighlight(4, 1, 6, "gratis Jetpack", 6, 7, "black", "green")
- setHighlight(5, 1, 6, "TeamSpeak-Channel", 30, 11, "black", "green")
- setHighlight(6, 1, 7, "kostenlos auszudrucken", 31, 6, "black", "green")
- --English
- setHighlight(7, 2, 2, "'City", 49, 4, "black", "green")
- setHighlight(8, 2, 2, "current'", 3, 5, "black", "green")
- setHighlight(9, 2, 4, "used by members of the city", 26, 5, "black", "green")
- setHighlight(10, 2, 5, "Outpost Ocean", 6, 4, "black", "green")
- setHighlight(11, 2, 6, "free Jetpack", 30, 6, "black", "green")
- setHighlight(12, 2, 6, "TeamSpeak-Channel", 24, 11, "black", "green")
- setHighlight(13, 2, 7, "for free", 3, 6, "black", "green")
- 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