Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local items = { -- множитель, название руды, забираем руду, dmg, отдаём слиток, dmg, название слитка, ore_dictionary
- {"2","Золотая руда","minecraft:gold_ore","0","minecraft:gold_ingot","0","Золотой слиток","ingotGold"},
- {"2","Железная руда","minecraft:iron_ore","0","minecraft:iron_ingot","0","Железный слиток","ingotIron"},
- {"2","IC2 Медная руда","IC2:blockOreCopper","0","IC2:itemIngot","0","Медный слиток","ingotCopper"},
- {"2","IC2 Оловянная руда","IC2:blockOreTin","0","IC2:itemIngot","1","Оловяный слиток","ingotTin"},
- {"10","Лазуритовая руда","minecraft:lapis_ore","0","minecraft:dye","4","Лазурит","dye"},
- {"5","Красная руда","minecraft:redstone_ore","0","minecraft:redstone","0","Красная пыль","dustRedstone"},
- {"4","Адская Оловянная руда","NetherOres:tile.netherores.ore.0","7","IC2:itemIngot","1","Оловянный слиток","ingotTin"},
- {"4","Адская Медная Руда","NetherOres:tile.netherores.ore.0","6","IC2:itemIngot","0","Медный слиток","ingotCopper"},
- }
- local unicode = require("unicode")
- local com = require("component")
- local interface = com.isAvailable("me_interface") and com.me_interface or error("нет ме интерфейса")
- local db = com.isAvailable("database") and com.database or error("нет базы данных")
- local pim = com.isAvailable("pim") and com.pim or error("нет пима")
- local size = pim.getInventorySize()
- local gpu = com.gpu
- local w, h = gpu.getResolution()
- local net_count,line_count = 0,0
- local event=require("event")
- local function declension(number)
- local dec = ""
- local rest = number % 10
- local str = string.sub(number,string.len(number)-1)
- if str == "11" or str == "12" or str == "13" or str == "14" then
- dec = " слитков"
- elseif rest == 1 then
- dec = " слиток"
- elseif rest == 2 or rest == 3 or rest == 4 then
- dec = " слитка"
- else
- dec = " слитков"
- end
- return number..dec
- end
- local function center(coord,text,color)
- gpu.setForeground(color)
- gpu.set(math.floor(w/2-unicode.len(text)/2),coord,text)
- end
- local function color_text(w,line,text,color)
- gpu.setForeground(color)
- gpu.set(w,line,text)
- end
- local function print_items()
- local line,size,fill = 3,0,true
- local network = interface.getItemsInNetwork()
- for ind = 1,#items do
- for net = 1,#network do
- if network[net].name == items[ind][5] then
- if network[net].damage == tonumber(items[ind][6]) then
- if network[net].size >= tonumber(items[ind][1]) then
- if #network ~= net_count then
- if fill then
- gpu.fill(1,1,w,h," ")
- fill = not fill
- end
- color_text(5,line,items[ind][2],0x00FF00)
- color_text(28,line,"1",0xFF00FF)
- color_text(30,line,"-->",0xFFFF00)
- color_text(34,line,"X "..items[ind][1],0xFF00FF)
- color_text(42,line,items[ind][7],0x00FF00)
- color_text(63,line,"доступно",0xFFFF00)
- color_text(73,line,tostring(network[net].size),0xFF00FF)
- color_text(3,line+1,string.rep("─",76),0xFFFFFF)
- size = size + network[net].size
- else
- size = size + network[net].size
- color_text(73,line,tostring(network[net].size.." "),0xFF00FF)
- end
- line = line + 2
- end
- end
- end
- end
- end
- net_count = #network
- if line == 3 or line ~= line_count then
- net_count = 0
- end
- line_count = line
- gpu.fill(1,1,w,1," ")
- if size > 0 then
- center(1,"обмен руды, всего доступно "..declension(size),0xFFFF00)
- else
- gpu.fill(1,1,w,h," ")
- center(h/2,"ВСЕ ИДИТЕ НАХУЙ, ХУЙ ВАМ А НЕ ОБМЕНИК .!. ",0xFF1493)
- end
- end
- local function pushItem(name,count,label)
- db.clear(1)
- interface.store(name,db.address,1)
- interface.setInterfaceConfiguration(1,db.address,1,64)
- local drop = 0
- while true do
- if drop == count then
- interface.setInterfaceConfiguration(1,db.address,1,0)
- net_count = 0
- break
- else
- local dropcount = interface.pushItem("UP",1,count-drop)
- drop = drop + dropcount
- if dropcount == 0 then
- gpu.fill(1,1,w,h," ")
- center(h/2,"освободите место в инвентаре",0xFF0000)
- center(h/2+2,"Ожидаю выдать "..label,0xFFFFFF)
- center(h/2+4,"всего "..count-drop,0xFFFFFF)
- os.sleep(1)
- end
- end
- end
- end
- local function exchange_ore_dict()
- gpu.fill(1,h/2+2,w,1,' ')
- center(h/2+2,"Для обмена встаньте на PIM и не сходите до окончания обмена", 0xffffff)
- local nick = nil
- e, nick, uuid, adr = event.pull(5,'player_on')
- if nick==nil then
- return
- end
- gpu.fill(1,h/2+2,w,1,' ')
- center(h/2+2,"Приветствую тебя, "..nick, 0xffffff)
- local ore_dict,item_count = "",false
- local size = pim.getInventorySize()
- local data = pim.getAllStacks(0)
- for slot =1, size do
- if data[slot] then
- for ind = 1,#items do
- if data[slot].id == items[ind][3] then
- if data[slot].dmg == tonumber(items[ind][4]) then
- ore_dict = items[ind][3]..items[ind][4]
- break
- end
- end
- end
- local network = interface.getItemsInNetwork()
- for ind2 = 1,#items do
- if ore_dict == items[ind2][3]..items[ind2][4] then
- local ore = items[ind2][5]
- local dmg = items[ind2][6]
- local ore_name = items[ind2][2]
- for net = 1,#network do
- if network[net].name == ore then
- if network[net].damage == tonumber(dmg) then
- if network[net].size >= tonumber(items[ind2][1]) then
- item_count = pim.pushItem("DOWN",slot,(network[net].size/items[ind2][1]))
- if item_count==nil then
- gpu.fill(1,1,w,1,' ')
- center(1,"Не удалось загрузить предмет, вы сошли с PIM. А вас просили не сходить...", 0xff0000)
- elseif item_count==0 then
- gpu.fill(1,1,w,1,' ')
- center(1,"Ошибка загрузки МЭ", 0xff0000)
- else
- local drop_count = item_count*items[ind2][1]
- local ingot_name = items[ind2][7]
- gpu.fill(1,1,w,1," ")
- center(1,"Меняю "..item_count.." "..ore_name.." на "..drop_count.." "..ingot_name,0xFFFFFF)
- pushItem({name = ore,damage = tonumber(dmg)},drop_count,ingot_name)
- end
- break
- end
- end
- end
- end
- if item_count then
- item_count = false
- ore_dict = ""
- break
- end
- end
- end
- end
- end
- end
- gpu.fill(1,1,w,h," ")
- gpu.setResolution(80,h)
- w,h = gpu.getResolution()
- while true do
- print_items()
- exchange_ore_dict()
- os.sleep(0.5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement