Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI('usr/mobController/Prison.lua')
- os.loadAPI('usr/getPeripheral.lua')
- textScale=0.5
- screen = term.current()
- chest = getPeripheral.findByName('copper')
- function p2Update(panel)
- t= term.current()
- term.redirect(panel)
- term.clear()
- term.setCursorPos(1,1)
- print(' Mobs ')
- for k, v in pairs(prisons) do
- if string.find(v.meta.displayName, 'blizz') then
- displayName = 'Blizz'
- else
- displayName = v.meta.displayName:gsub('Mob Imprisonment Tool ', '')
- displayName = displayName:gsub('[()]', '')
- end
- print(displayName)
- end
- p2x, p2y = term.getSize()
- term.setCursorPos(p2x/2-3, p2y-#hdr)
- print('reset')
- term.redirect(t)
- end
- function p2touch(periph, x,y)
- t = term.current()
- term.redirect(panel3)
- prison = prisons[y-(#hdr+1)]
- if not prison then
- print('No prison selected')
- else
- term.clear()
- term.setCursorPos(1,1)
- Prison.pullPrison(chest)
- scs, put_prison = Prison.putPrison(chest, prison)
- if scs then
- print(prison.meta.displayName)
- print(prison.slot)
- end
- end
- term.redirect(t)
- end
- hdr={
- [[ _____ _ __ __ ]],
- [[/ ___( ) / _|/ _|]],
- [[\ `--.|/ _ __ _ _| |_| |_ ]],
- [[ `--. \ | '_ \| | | | _| _|]],
- [[/\__/ / | | | | |_| | | | | ]],
- [[\____/ |_| |_|\__,_|_| |_| ]],
- }
- --------initialize windows---------
- --wrap monitor
- mon = peripheral.wrap('top')
- mon.setTextScale(textScale)
- --define windows based on monitor size
- monX, monY = mon.getSize()
- panel1 = window.create(mon, 1, 1, monX, #hdr)
- panel2 = window.create(mon, 1, #hdr+1, monX*0.3333, monY)
- panel3 = window.create(mon, monX*0.3333+1, #hdr+1, monX, monY)
- panels={panel1, panel2, panel3}
- --define css properties for each window
- panel_props = {
- {panel=panel1, background = colors.lightGray, textColor=colors.blue},
- {panel=panel2, background = colors.blue, textColor=colors.white},
- {panel=panel3, background = colors.gray, textColor=colors.white},
- }
- --draw windows
- term.redirect(panel1)
- term.setBackgroundColor(panel_props[1].background)
- term.setTextColor(panel_props[1].textColor)
- term.clear()
- for k,v in pairs(hdr) do
- print(v)
- end
- for k,v in pairs(panels) do
- for a,b in pairs(panel_props) do
- if b.panel == v and v~=panel1 then
- term.redirect(v)
- term.setBackgroundColor(b.background)
- term.setTextColor(b.textColor)
- term.setCursorPos(1,1)
- term.clear()
- end
- end
- end
- mon.setCursorPos(1,1)
- ----------MAIN LOOP----------
- while true do
- scs, prisons = Prison.getPrisons()
- if not scs then
- scs, prisons = Prison.readChest(chest)
- end
- t = term.current()
- p2Update(panel2)
- event, periph, x, y = os.pullEvent('monitor_touch')
- if event then
- if x<monX*0.33 and y>#hdr+1 and y<=#hdr+1+#prisons then
- p2touch(chest, x,y)
- elseif x<monX*0.33 and y==monY then
- Prison.resetPrisons(chest)
- end
- elseif event == 'key' then
- if periph == keys.q then
- term.redirect(screen)
- print('quitting')
- break
- end
- end
- end
Add Comment
Please, Sign In to add comment