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 = 5
- 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, "lightblue", "black")
- setButton("PageUp", "-->", pageUp, (w-7), (h-3), 7, 3, "lightblue", "black")
- setButton("PageDown", "<--", pageDown, (w-15), (h-3), 7, 3, "lightblue", "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.lightBlue)
- 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] = "Wichtige Befehle" --heading_string[language][page]
- heading_string[1][2] = " "
- heading_string[1][3] = " "
- heading_string[1][4] = " "
- heading_string[1][5] = " "
- --English
- heading_string[2][1] = "Important Commands" --heading_string[language][page]
- heading_string[2][2] = " "
- heading_string[2][3] = " "
- heading_string[2][4] = " "
- heading_string[2][5] = " "
- --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 allerlei nützliche und essentielle"
- text[1][1][2] = "Befehle welche Du als Stadtbewohner benötigen wirst."
- text[1][2][1] = "/t join Fontania - Hiermit trittst Du der Stadt bei."
- text[1][2][2] = " Ausserdem sind alle anderen Befehle"
- text[1][2][3] = " erst hiernach möglich"
- text[1][2][4] = " "
- text[1][2][5] = "/t leave - Verlasse die Stadt (Bitte Hinweise dazu bei"
- text[1][2][6] = " 'Grundstücke' berücksichtigen!)"
- text[1][2][7] = " "
- text[1][2][8] = "/tc - Wechselt in den TownChat. Funktioniert identisch"
- text[1][2][9] = " zu /l oder /g"
- text[1][3][1] = "/t spawn - Teleportiere Dich zum Stadtspawn!"
- text[1][3][2] = " "
- text[1][3][3] = "/t outpost - Teleportiere Dich zum Spawn des Stadtteils"
- text[1][3][4] = " Ocean!"
- text[1][3][5] = " "
- text[1][3][6] = "/t [stadt] - Zeigt Dir Informationen zur Stadt"
- text[1][3][7] = " "
- text[1][3][8] = "/t deposit [betrag] - Spende der Stadt einen bestimmten"
- text[1][3][9] = " Betrag"
- text[1][4][1] = "/plot claim - Hiermit kauft man genau einen Chunk eines"
- text[1][4][2] = " Grundstücks, sofern dieses 'For Sale'"
- text[1][4][3] = " ist."
- text[1][4][4] = " "
- text[1][4][5] = "/resident friend add [name] - Gebe einem anderen Spieler"
- text[1][4][6] = " Rechte auf deinem GS"
- text[1][4][7] = " "
- text[1][4][8] = "/resident friend remove [name] - Entziehe einem Spieler"
- text[1][4][9] = " Rechte auf deinem GS"
- text[1][4][10] = " "
- text[1][4][11] = "/plot toggle mob - Erlaubt das Spawnen von Mobs (für"
- text[1][4][12] = " Mob-Farm erforderlich)"
- text[1][5][1] = "/seen [name] - Wie lange ist jemand schon offline?"
- text[1][5][2] = " "
- text[1][5][3] = "/t online - Wer ist derzeit aus der Stadt noch online?"
- text[1][5][4] = " "
- text[1][5][5] = "/t ranklist - Wer besitzt welchen Stadt-Rang?"
- text[1][5][6] = " "
- text[1][5][7] = "Liste aller Befehle: https://goo.gl/tEHZe7"
- text[1][5][8] = "(Die meisten davon erfordern Permissions)"
- --English
- text[2][1][1] = "Here you will find a lot of useful and essential"
- text[2][1][2] = "commands to interact in a city."
- text[2][2][1] = "/t join Fontania - Joins the city of Fontania and"
- text[2][2][2] = " enables all other commands you"
- text[2][2][3] = " find on this screen."
- text[2][2][4] = " "
- text[2][2][5] = "/t leave - Leaves the city (Please read the 'Property/"
- text[2][2][6] = " Estate'-Screen for more information)"
- text[2][2][7] = " "
- text[2][2][8] = "/tc - Switches to the TownChat. Works the same as /l"
- text[2][2][9] = " or /g"
- text[2][3][1] = "/t spawn - Warp to the spawn of Fontania"
- text[2][3][2] = " "
- text[2][3][3] = "/t outpost - Warp to the spawn of Ocean, which is our"
- text[2][3][4] = " outpost"
- text[2][3][5] = " "
- text[2][3][6] = "/t [city] - Lists information about a city"
- text[2][3][7] = " "
- text[2][3][8] = "/t deposit [amount] - Donate a certain amount of money"
- text[2][3][9] = " to the city"
- text[2][4][1] = "/plot claim - Buys one chunk of a property, if it is"
- text[2][4][2] = " marked as 'For Sale'. Always buy all chunks"
- text[2][4][3] = " of a property!"
- text[2][4][4] = " "
- text[2][4][5] = "/resident friend add [name] - Enables a player to"
- text[2][4][6] = " interact on your plots"
- text[2][4][7] = " "
- text[2][4][8] = "/resident friend remove [name] - Disables a player to"
- text[2][4][9] = " interact on your plots"
- text[2][4][10] = " "
- text[2][4][11] = "/plot toggle mob - Enables mobs to spawn in this chunk"
- text[2][4][12] = " (necessary for mob farms to work)"
- text[2][5][1] = "/seen [name] - How long has somebody been not online?"
- text[2][5][2] = " "
- text[2][5][3] = "/t online - Who else is online in Fontania atm?"
- text[2][5][4] = " "
- text[2][5][5] = "/t ranklist - Who is what in the city?"
- text[2][5][6] = " "
- text[2][5][7] = "List of all commands: https://goo.gl/tEHZe7"
- text[2][5][8] = "(Most of which require extra permissions)"
- --Highlights
- highlight = {}
- --setHighlight(id, sprache, seite, "text", xpos, ypos, "backcolor", "textcolor")
- --Deutsch
- setHighlight(1, 1, 2, "/t join Fontania", 3, 4, "black", "lightblue")
- setHighlight(2, 1, 2, "/t leave", 3, 8, "black", "lightblue")
- setHighlight(3, 1, 2, "/tc", 3, 11, "black", "lightblue")
- setHighlight(4, 1, 3, "/t spawn", 3, 4, "black", "lightblue")
- setHighlight(5, 1, 3, "/t outpost", 3, 6, "black", "lightblue")
- setHighlight(6, 1, 3, "/t [stadt]", 3, 9, "black", "lightblue")
- setHighlight(7, 1, 3, "/t deposit [betrag]", 3, 11, "black", "lightblue")
- setHighlight(8, 1, 4, "/plot claim", 3, 4, "black", "lightblue")
- setHighlight(9, 1, 4, "/resident friend add [name]", 3, 8, "black", "lightblue")
- setHighlight(10, 1, 4, "/resident friend remove [name]", 3, 11, "black", "lightblue")
- setHighlight(11, 1, 4, "/plot toggle mob", 3, 14, "black", "lightblue")
- setHighlight(12, 1, 5, "/seen [name]", 3, 4, "black", "lightblue")
- setHighlight(13, 1, 5, "/t online", 3, 6, "black", "lightblue")
- setHighlight(14, 1, 5, "/t ranklist", 3, 8, "black", "lightblue")
- --English
- setHighlight(15, 2, 2, "/t join Fontania", 3, 4, "black", "lightblue")
- setHighlight(16, 2, 2, "/t leave", 3, 8, "black", "lightblue")
- setHighlight(17, 2, 2, "/tc", 3, 11, "black", "lightblue")
- setHighlight(18, 2, 3, "/t spawn", 3, 4, "black", "lightblue")
- setHighlight(19, 2, 3, "/t outpost", 3, 6, "black", "lightblue")
- setHighlight(20, 2, 3, "/t [city]", 3, 9, "black", "lightblue")
- setHighlight(21, 2, 3, "/t deposit [amount]", 3, 11, "black", "lightblue")
- setHighlight(22, 2, 4, "/plot claim", 3, 4, "black", "lightblue")
- setHighlight(23, 2, 4, "/resident friend add [name]", 3, 8, "black", "lightblue")
- setHighlight(24, 2, 4, "/resident friend remove [name]", 3, 11, "black", "lightblue")
- setHighlight(25, 2, 4, "/plot toggle mob", 3, 14, "black", "lightblue")
- setHighlight(26, 2, 5, "/seen [name]", 3, 4, "black", "lightblue")
- setHighlight(27, 2, 5, "/t online", 3, 6, "black", "lightblue")
- setHighlight(28, 2, 5, "/t ranklist", 3, 8, "black", "lightblue")
- 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