Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Database for Mods under construction
- -- for mc 1.7.x and 1.8.x
- shell.run("delete caAPI")
- shell.run("pastebin get EDLdR1nF caAPI")
- os.loadAPI("caAPI")
- local me_number = caAPI.get_hardware("meBridge")
- if me_number == "meBridge_off" then
- shell.run("clear")
- else
- net = peripheral.wrap(me_number)
- end
- shell.run("delete database/IdNameENG.db")
- shell.run("pastebin get hTJaBiJA database/IdNameENG.db")
- local IDlist = caAPI.loadFile("database/IdNameENG.db")
- local page = 1
- local maxPage = 40
- local maxEntries = 23
- --set monitor
- function set_monitor()
- local monitor_number = caAPI.get_hardware("monitor")
- local found = fs.exists("config/monitor.cfg")
- if found == true then
- file = fs.open("config/monitor.cfg","r")
- local fileData = {}
- local line = file.readLine()
- repeat
- table.insert(fileData,line)
- line = file.readLine()
- until line == nil
- file.close()
- monitor_number = fileData[1]
- end
- mon = peripheral.wrap(monitor_number)
- end
- --draw screen
- function draw_screen(page)
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.white)
- mon.clear()
- mon.setBackgroundColor(colors.black)
- mon.setCursorPos(2,1)
- mon.setTextColor(colors.blue)
- mon.write("ME Bridge Port:"..me_number)
- mon.setCursorPos(50,1)
- mon.setBackgroundColor(colors.red)
- mon.setTextColor(colors.black)
- mon.write("X")
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.green)
- mon.setCursorPos(2,2)
- local items = net.listAll()
- mon.write(#items.." kinds of items found.")
- mon.setTextColor(colors.yellow)
- mon.setCursorPos(34,1)
- mon.write("Page:"..tostring(page))
- mon.setCursorPos(34,2)
- mon.write("Back Next Refresh")
- mon.setTextColor(colors.white)
- mon.setCursorPos(2,3)
- mon.write("Mod")
- mon.setCursorPos(17,3)
- mon.write("Slot")
- mon.setCursorPos(25,3)
- mon.write("Name")
- y = 4
- max = page * maxEntries
- min = max - maxEntries
- for num, itemID in pairs(items) do
- if itemID~=nil then
- if num > (min -1) and num < (max + 1) then
- data = caAPI.split(itemID,":")
- mon.setCursorPos(2,y)
- mon.write(data[1])
- dataC = caAPI.split(data[2]," ")
- if dataC[2] == "0" then
- name = dataC[1]
- else
- name = dataC[1]..":"..dataC[2]
- end
- mon.setCursorPos(18,y)
- mon.write(num)
- mon.setCursorPos(25,y)
- mon.write(caAPI.AtoB(name,IDlist))
- y = y + 1
- end
- end
- end
- touch()
- end
- --touch
- function touch()
- local ix = true
- while ix == true do
- event, side, x, y = os.pullEvent()
- if event == "monitor_touch" then
- if x == 50 and y == 1 then
- ix = false
- shell.run("clear")
- end
- if y == 2 and x > 33 and x < 38 then
- ix = false
- if page ~= 1 then
- page = page - 1
- sleep(1)
- end
- draw_screen(page)
- end
- if y == 2 and x > 38 and x < 43 then
- ix = false
- page = page + 1
- sleep(1)
- if page > maxPage then
- page = maxPage
- sleep(1)
- end
- draw_screen(page)
- end
- if y == 2 and x > 43 and x < 50 then
- ix = false
- page = 1
- sleep(1)
- draw_screen(page)
- end
- end
- end
- end
- --start program
- set_monitor()
- draw_screen(page)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement