Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("right")
- local glasses = peripheral.find("neuralInterface")
- local canvas = glasses.canvas()
- function decToHex(dec)
- return string.format("%02x", dec*255)
- end
- function hex(r,g,b,a)
- local col = "0x"..decToHex(r)..decToHex(g)..decToHex(b)..decToHex(a)
- print(col)
- print(tonumber(col,16))
- return tonumber(col, 16)
- end
- function fill(group, col)
- return group.addRectangle(0,0,1000,1000,col)
- end
- function clear()
- canvas.clear()
- end
- function drawBar(group,x,y,w,h,percent,col1,col2)
- bar = {}
- bar.rect2 = group.addRectangle(x,y,w,h,col2)
- bar.rect1 = group.addRectangle(x+1,y+1,(w-2)*percent,h-2,col1)
- return bar
- end
- function w()
- return 512
- end
- function h()
- return 256
- end
- function loadScreen(progress,alpha,omitBar)
- local screen = {}
- screen.group = canvas.addGroup({0, 0})
- local dg = 0.1 --darkgray
- screen.bkg = fill(screen.group, hex(dg,dg,dg,alpha))
- if not omitBar then
- local col1 = hex(0,0,0,1)
- local col2 = hex(1,1,1,1)
- screen.bar = drawBar(screen.group, w()/2-50,h()/2-10,100,20,progress,col1,col2)
- screen.setProgress = function(progress)
- screen.bar.rect1.setSize((100-2)*progress, 20-2)
- end
- end
- return screen
- end
- function showRoomLoadScreen()
- local screen = loadScreen(0,1)
- local time = 50
- for i=0,time do
- screen.setProgress(i/time)
- os.sleep(0.05)
- end
- for i=0,10 do
- canvas.clear()
- loadScreen(1,1-i/10,true)
- os.sleep(0.05)
- end
- canvas.clear()
- end
- function doorway(side)
- print("doorway("..side..")")
- local message = {}
- message.type = "doorway"
- message.data = side
- message = textutils.serialise(message)
- rednet.broadcast(message, "player")
- end
- function introspector()
- local introspection = peripheral.wrap("back")
- local recentDoorway = 0
- while true do
- local blocks = introspection.scan()
- for k,v in pairs(blocks) do
- local block = v
- if(block.x==0 and block.z==0 and block.y==-4) then
- if(block.name=="thermalfoundation:storage")then
- if(recentDoorway<1)then
- print(block.state.type)
- local type = block.state.type
- if(type=="COPPER")then
- doorway("north")
- elseif(type=="SILVER")then
- doorway("east")
- elseif(type=="LEAD")then
- doorway("south")
- elseif(type=="TIN")then
- doorway("west")
- end
- recentDoorway = 10
- end
- else
- recentDoorway = recentDoorway-1
- end
- end
- end
- os.sleep(0.05)
- end
- end
- function listener()
- while(true)do
- local id,message = rednet.receive("toPlayer")
- message = textutils.unserialise(message)
- if(message.type=="showLoadScreen")then
- showRoomLoadScreen()
- end
- end
- end
- parallel.waitForAll(introspector, listener)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement