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 getxy(x,y,ang)
- ang = ang*0.0174532925
- local l = (1-x)/math.sin(ang)
- return (x+l*math.sin(ang)),(y+l*math.cos(ang)),l
- 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 notLooking()
- mon.setTextScale(5)
- local xmax,ymax = mon.getSize()
- local tc,tt = Draw.emptyScreen(mon,xmax,ymax)
- Draw.tc(tc,1,1,colors.black,xmax,ymax)
- Draw.tt(tt,1,3," READ THE",colors.red)
- Draw.tt(tt,1,4," DAMN RULES",colors.red)
- Draw.draw(mon,tc,1,1,colors.black,tt)
- end
- function getAndParseRules()
- 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+>","")
- table.insert(tt,line)
- end
- end
- return deepcopy(tt)
- end
- function looking()
- mon.setTextScale(1)
- 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
- function parse(v)
- tab = p.getPlayerData(v)
- local x,y,l = getxy(-1*tab.position.x,tab.position.z,tab.yaw)
- if math.ceil(y) >1 or math.floor(y) < -7 then --or tab.position.x<1 then
- notLooking()
- else
- looking()
- end
- end
- tt2 = getAndParseRules()
- while true do
- sleep(0.2)
- local iter = 1
- for k,v in pairs(p.getPlayerNames()) do
- iter = iter+1
- parse(v)
- end
- if iter==1 then sleep(1) print("sleep") end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement