Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local holoAPI = {}
- local holow
- local holoh
- local h = {}
- local component = require("component")
- local term = require("term")
- function holoAPI.setHolo(hn, hwidth)
- h = {}
- for _, addr in ipairs(hn) do
- local realAddr = component.get(addr)
- table.insert(h, component.proxy(realAddr))
- end
- holow = hwidth
- holoh = (#hn)/holow
- end
- function holoAPI.holoClean()
- for i = 1 , #h do
- h[i].clear()
- end
- end
- function holoAPI.holoSetPat(pat)
- for i = 1, #h do
- for j = 1, 3 do
- h[i].setPaletteColor(j, pat[j])
- end
- term.clear()
- term.setCursor(12,1)
- term.write('processing..' .. math.floor(#h/i)*100 .. '%')
- os.sleep()
- end
- end
- function holoAPI.holoCleanWithPat(pat)
- for i = 1, #h do
- h[i].clear()
- for j = 1, 3 do
- h[i].setPaletteColor(j, pat[j])
- end
- os.sleep()
- end
- end
- function holoAPI.draw( x, y, z, c)
- local modx = 48-math.fmod(x-1,48)
- local mody = 32-math.fmod(y-1,32)
- local hx = math.floor((x-1)/48)+1
- local hy = math.floor((y-1)/32)
- h[hy*holow+hx].set(modx, mody, z, c)
- end
- function holoAPI.showpic(fileName)
- local img = require( fileName )
- os.sleep()
- holoAPI.holoCleanWithPat( img.pat )
- term.clear()
- local offx = math.floor((holow*48-img.x)/2)
- local offy = math.floor((holoh*32-img.y)/2)
- for y=1, img.y do
- for x=1,img.x do
- holoAPI.draw(x+offx,y+offy,1,img.img[((y-1)*img.x+x)])
- end
- end
- local sx = math.floor((50-#img.subtitle/3*2)/2) + 1
- term.clear()
- term.setCursor(sx, 1)
- term.write(img.subtitle)
- end
- return holoAPI
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement