Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local p = peripheral.wrap("top")
- local mon = peripheral.wrap("front")
- os.loadAPI("Draw")
- function getHTTP()
- return http.get("https://raw.github.com/AlienMC/AlienMC-FTBSubreddit-Public-Server/master/Server%20Rules.md")
- end
- function deepcopy(orig)
- local orig_type = type(orig)
- local copy
- if orig_type == 'table' then
- copy = {}
- for orig_key, orig_value in next, orig, nil do
- copy[deepcopy(orig_key)] = deepcopy(orig_value)
- end
- setmetatable(copy, deepcopy(getmetatable(orig)))
- else -- number, string, boolean, etc
- copy = orig
- end
- return copy
- end
- function getAndParseRules()
- local xmax,ymax = mon.getSize()
- local rules = getHTTP()
- local tt = {}
- local line = ""
- while line ~= nil do
- line = rules.readLine()
- if line ~= nil then
- line = string.gsub(line,"<b>","&"..Draw.getHexOf(colors.red))
- line = string.gsub(line,"</b>"," &"..Draw.getHexOf(colors.lime))
- line = string.gsub(line,"<li>","")
- line = string.gsub(line,"<%S+>","")
- line = string.gsub(line,"<a %S+>","")
- line = string.match(line,"%s+(.+)")
- if #line > xmax then
- local str = ""
- for word in string.gsub(line,"%S+") do
- if string.len(str.." "..word) < xmax then
- str = str.." "..word
- else
- table.insert(str)
- str = " "..word
- end
- end
- end
- table.insert(tt,line)
- end
- end
- return deepcopy(tt)
- end
- function looking()
- mon.setTextScale(2)
- local xmax,ymax = mon.getSize()
- local tc = Draw.emptyScreen(mon,xmax,ymax)
- Draw.tc(tc,1,1,colors.black,xmax,ymax)
- Draw.draw(mon,tc,1,1,colors.black,tt2)
- end
- local tt2 = getAndParseRules()
- while true do
- looking()
- sleep(15)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement