SHOW:
|
|
- or go back to the newest paste.
1 | - | local items = { -- множитель, название руды, забираем руду, dmg, отдаём слиток, dmg, название слитка, ore_dictionary |
1 | + | local items = { -- множитель, название руды, забираем руду, dmg, отдаём слиток, dmg, название слитка, ore_dictionary |
2 | - | {"2","Золотая руда","minecraft:gold_ore","0","minecraft:gold_ingot","0","Золотой слиток","ingotGold"}, |
2 | + | {"2","Золотая руда","minecraft:gold_ore","0","minecraft:gold_ingot","0","Золотой слиток","ingotGold"}, |
3 | - | {"2","Железная руда","minecraft:iron_ore","0","minecraft:iron_ingot","0","Железный слиток","ingotIron"}, |
3 | + | {"2","Железная руда","minecraft:iron_ore","0","minecraft:iron_ingot","0","Железный слиток","ingotIron"}, |
4 | - | {"2","IC2 Медная руда","IC2:blockOreCopper","0","IC2:itemIngot","0","Медный слиток","ingotCopper"}, |
4 | + | {"2","IC2 Медная руда","IC2:blockOreCopper","0","IC2:itemIngot","0","Медный слиток","ingotCopper"}, |
5 | - | {"2","IC2 Оловянная руда","IC2:blockOreTin","0","IC2:itemIngot","1","Оловяный слиток","ingotTin"}, |
5 | + | {"2","IC2 Оловянная руда","IC2:blockOreTin","0","IC2:itemIngot","1","Оловяный слиток","ingotTin"}, |
6 | - | {"10","Лазуритовая руда","minecraft:lapis_ore","0","minecraft:dye","4","Лазурит","dye"}, |
6 | + | {"10","Лазуритовая руда","minecraft:lapis_ore","0","minecraft:dye","4","Лазурит","dye"}, |
7 | - | {"5","Красная руда","minecraft:redstone_ore","0","minecraft:redstone","0","Красная пыль","dustRedstone"}, |
7 | + | {"5","Красная руда","minecraft:redstone_ore","0","minecraft:redstone","0","Красная пыль","dustRedstone"}, |
8 | - | {"4","Адская Оловянная руда","NetherOres:tile.netherores.ore.0","7","IC2:itemIngot","1","Оловянный слиток","ingotTin"}, |
8 | + | {"4","Адская Оловянная руда","NetherOres:tile.netherores.ore.0","7","IC2:itemIngot","1","Оловянный слиток","ingotTin"}, |
9 | - | {"4","Адская Медная Руда","NetherOres:tile.netherores.ore.0","6","IC2:itemIngot","0","Медный слиток","ingotCopper"}, |
9 | + | {"4","Адская Медная Руда","NetherOres:tile.netherores.ore.0","6","IC2:itemIngot","0","Медный слиток","ingotCopper"}, |
10 | - | {"3","Дракониевая руда","DraconicEvolution:draconiumOre","0","DraconicEvolution:draconiumIngot","0","Дракониевый слиток","БЛа-бла"}, |
10 | + | {"3","Дракониевая руда","DraconicEvolution:draconiumOre","0","DraconicEvolution:draconiumIngot","0","Дракониевый слиток","БЛа-бла"}, |
11 | - | } |
11 | + | } |
12 | - | |
12 | + | |
13 | - | local unicode = require("unicode") |
13 | + | local unicode = require("unicode") |
14 | - | local com = require("component") |
14 | + | local com = require("component") |
15 | - | local interface = com.isAvailable("me_interface") and com.me_interface or error("нет ме интерфейса") |
15 | + | local interface = com.isAvailable("me_interface") and com.me_interface or error("нет ме интерфейса") |
16 | - | local db = com.isAvailable("database") and com.database or error("нет базы данных") |
16 | + | local db = com.isAvailable("database") and com.database or error("нет базы данных") |
17 | - | local pim = com.isAvailable("pim") and com.pim or error("нет пима") |
17 | + | local pim = com.isAvailable("pim") and com.pim or error("нет пима") |
18 | - | local size = pim.getInventorySize() |
18 | + | local size = pim.getInventorySize() |
19 | - | local gpu = com.gpu |
19 | + | local gpu = com.gpu |
20 | - | local w, h = gpu.getResolution() |
20 | + | local w, h = gpu.getResolution() |
21 | - | |
21 | + | |
22 | - | gpu.setResolution(80,h) |
22 | + | gpu.setResolution(80,h) |
23 | - | w=80 |
23 | + | w=80 |
24 | - | |
24 | + | |
25 | - | local net_count,line_count = 0,0 |
25 | + | local net_count,line_count = 0,0 |
26 | - | local event=require("event") |
26 | + | local event=require("event") |
27 | - | local function declension(number) |
27 | + | local function declension(number) |
28 | - | local dec = "" |
28 | + | local dec = "" |
29 | - | local rest = number % 10 |
29 | + | local rest = number % 10 |
30 | - | local str = string.sub(number,string.len(number)-1) |
30 | + | local str = string.sub(number,string.len(number)-1) |
31 | - | if str == "11" or str == "12" or str == "13" or str == "14" then |
31 | + | if str == "11" or str == "12" or str == "13" or str == "14" then |
32 | - | dec = " слитков" |
32 | + | dec = " слитков" |
33 | - | elseif rest == 1 then |
33 | + | elseif rest == 1 then |
34 | - | dec = " слиток" |
34 | + | dec = " слиток" |
35 | - | elseif rest == 2 or rest == 3 or rest == 4 then |
35 | + | elseif rest == 2 or rest == 3 or rest == 4 then |
36 | - | dec = " слитка" |
36 | + | dec = " слитка" |
37 | - | else |
37 | + | else |
38 | - | dec = " слитков" |
38 | + | dec = " слитков" |
39 | - | end |
39 | + | end |
40 | - | return number..dec |
40 | + | return number..dec |
41 | end | |
42 | - | |
42 | + | |
43 | - | local function center(coord,text,color) |
43 | + | local function center(coord,text,color) |
44 | - | gpu.setForeground(color) |
44 | + | gpu.setForeground(color) |
45 | - | gpu.set(math.floor(w/2-unicode.len(text)/2),coord,text) |
45 | + | gpu.set(math.floor(w/2-unicode.len(text)/2),coord,text) |
46 | end | |
47 | - | |
47 | + | |
48 | - | local function color_text(w,line,text,color) |
48 | + | local function color_text(w,line,text,color) |
49 | - | gpu.setForeground(color) |
49 | + | gpu.setForeground(color) |
50 | - | gpu.set(w,line,text) |
50 | + | gpu.set(w,line,text) |
51 | end | |
52 | - | |
52 | + | |
53 | - | local function print_items() |
53 | + | local function print_items() |
54 | - | local line,size,fill = 3,0,true |
54 | + | local line,size,fill = 3,0,true |
55 | - | local network = interface.getItemsInNetwork() |
55 | + | local network = interface.getItemsInNetwork() |
56 | - | for ind = 1,#items do |
56 | + | for ind = 1,#items do |
57 | - | for net = 1,#network do |
57 | + | for net = 1,#network do |
58 | - | if network[net].name == items[ind][5] then |
58 | + | if network[net].name == items[ind][5] then |
59 | - | if network[net].damage == tonumber(items[ind][6]) then |
59 | + | if network[net].damage == tonumber(items[ind][6]) then |
60 | - | if network[net].size >= tonumber(items[ind][1]) then |
60 | + | if network[net].size >= tonumber(items[ind][1]) then |
61 | - | if #network ~= net_count then |
61 | + | if #network ~= net_count then |
62 | - | if fill then |
62 | + | if fill then |
63 | - | gpu.fill(1,1,w,h," ") |
63 | + | gpu.fill(1,1,w,h," ") |
64 | - | fill = not fill |
64 | + | fill = not fill |
65 | - | end |
65 | + | end |
66 | - | color_text(5,line,items[ind][2],0x00FF00) |
66 | + | color_text(5,line,items[ind][2],0x00FF00) |
67 | - | color_text(28,line,"1",0xFF00FF) |
67 | + | color_text(28,line,"1",0xFF00FF) |
68 | - | color_text(30,line,"-->",0xFFFF00) |
68 | + | color_text(30,line,"-->",0xFFFF00) |
69 | - | color_text(34,line,"X "..items[ind][1],0xFF00FF) |
69 | + | color_text(34,line,"X "..items[ind][1],0xFF00FF) |
70 | - | color_text(42,line,items[ind][7],0x00FF00) |
70 | + | color_text(42,line,items[ind][7],0x00FF00) |
71 | - | color_text(63,line,"доступно",0xFFFF00) |
71 | + | color_text(63,line,"доступно",0xFFFF00) |
72 | - | color_text(73,line,tostring(network[net].size),0xFF00FF) |
72 | + | color_text(73,line,tostring(network[net].size),0xFF00FF) |
73 | - | color_text(3,line+1,string.rep("─",76),0xFFFFFF) |
73 | + | color_text(3,line+1,string.rep("─",76),0xFFFFFF) |
74 | - | size = size + network[net].size |
74 | + | size = size + network[net].size |
75 | - | else |
75 | + | else |
76 | - | size = size + network[net].size |
76 | + | size = size + network[net].size |
77 | - | color_text(73,line,tostring(network[net].size.." "),0xFF00FF) |
77 | + | color_text(73,line,tostring(network[net].size.." "),0xFF00FF) |
78 | - | end |
78 | + | end |
79 | - | line = line + 2 |
79 | + | line = line + 2 |
80 | - | end |
80 | + | end |
81 | - | end |
81 | + | end |
82 | - | end |
82 | + | end |
83 | - | end |
83 | + | end |
84 | - | end |
84 | + | end |
85 | - | net_count = #network |
85 | + | net_count = #network |
86 | - | if line == 3 or line ~= line_count then |
86 | + | if line == 3 or line ~= line_count then |
87 | - | net_count = 0 |
87 | + | net_count = 0 |
88 | - | end |
88 | + | end |
89 | - | line_count = line |
89 | + | line_count = line |
90 | - | gpu.fill(1,1,w,1," ") |
90 | + | gpu.fill(1,1,w,1," ") |
91 | - | if size > 0 then |
91 | + | if size > 0 then |
92 | - | center(1,"обмен руды, всего доступно "..declension(size),0xFFFF00) |
92 | + | center(1,"обмен руды, всего доступно "..declension(size),0xFFFF00) |
93 | - | else |
93 | + | else |
94 | - | gpu.fill(1,1,w,h," ") |
94 | + | gpu.fill(1,1,w,h," ") |
95 | - | center(h/2,"ВСЕ ИДИТЕ НАХУЙ, ХУЙ ВАМ А НЕ ОБМЕНИК .!. ",0xFF1493) |
95 | + | center(h/2,"ВСЕ ИДИТЕ НАХУЙ, ХУЙ ВАМ А НЕ ОБМЕНИК .!. ",0xFF1493) |
96 | - | end |
96 | + | end |
97 | end | |
98 | - | |
98 | + | |
99 | - | local function pushItem(name,count,label) |
99 | + | local function pushItem(name,count,label) |
100 | - | db.clear(1) |
100 | + | db.clear(1) |
101 | - | interface.store(name,db.address,1) |
101 | + | interface.store(name,db.address,1) |
102 | - | interface.setInterfaceConfiguration(1,db.address,1,64) |
102 | + | interface.setInterfaceConfiguration(1,db.address,1,64) |
103 | - | local drop = 0 |
103 | + | local drop = 0 |
104 | - | while true do |
104 | + | while true do |
105 | - | if drop == count then |
105 | + | if drop == count then |
106 | - | interface.setInterfaceConfiguration(1,db.address,1,0) |
106 | + | interface.setInterfaceConfiguration(1,db.address,1,0) |
107 | - | net_count = 0 |
107 | + | net_count = 0 |
108 | - | break |
108 | + | break |
109 | - | else |
109 | + | else |
110 | - | local dropcount = interface.pushItem("UP",1,count-drop) |
110 | + | local dropcount = interface.pushItem("UP",1,count-drop) |
111 | - | drop = drop + dropcount |
111 | + | drop = drop + dropcount |
112 | - | if dropcount == 0 then |
112 | + | if dropcount == 0 then |
113 | - | gpu.fill(1,1,w,h," ") |
113 | + | gpu.fill(1,1,w,h," ") |
114 | - | center(h/2,"освободите место в инвентаре",0xFF0000) |
114 | + | center(h/2,"освободите место в инвентаре",0xFF0000) |
115 | - | center(h/2+2,"Ожидаю выдать "..label,0xFFFFFF) |
115 | + | center(h/2+2,"Ожидаю выдать "..label,0xFFFFFF) |
116 | - | center(h/2+4,"всего "..count-drop,0xFFFFFF) |
116 | + | center(h/2+4,"всего "..count-drop,0xFFFFFF) |
117 | - | os.sleep(1) |
117 | + | os.sleep(1) |
118 | - | end |
118 | + | end |
119 | - | end |
119 | + | end |
120 | - | end |
120 | + | end |
121 | end | |
122 | - | |
122 | + | |
123 | - | local function exchange_ore_dict() |
123 | + | local function exchange_ore_dict() |
124 | - | gpu.fill(1,h/2+2,w,1,' ') |
124 | + | gpu.fill(1,h/2+2,w,1,' ') |
125 | - | center(h/2+2,"Для обмена встаньте на PIM и не сходите до окончания обмена", 0xffffff) |
125 | + | center(h/2+2,"Для обмена встаньте на PIM и не сходите до окончания обмена", 0xffffff) |
126 | - | local nick = nil |
126 | + | local nick = nil |
127 | - | e, nick, uuid, adr = event.pull(5,'player_on') |
127 | + | e, nick, uuid, adr = event.pull(5,'player_on') |
128 | - | if nick==nil then |
128 | + | if nick==nil then |
129 | - | return |
129 | + | return |
130 | - | end |
130 | + | end |
131 | - | |
131 | + | |
132 | - | gpu.fill(1,h/2+2,w,1,' ') |
132 | + | gpu.fill(1,h/2+2,w,1,' ') |
133 | - | center(h/2+2,"Приветствую тебя, "..nick, 0xffffff) |
133 | + | center(h/2+2,"Приветствую тебя, "..nick, 0xffffff) |
134 | - | local ore_dict,item_count = "",false |
134 | + | local ore_dict,item_count = "",false |
135 | - | local size = pim.getInventorySize() |
135 | + | local size = pim.getInventorySize() |
136 | - | local data = pim.getAllStacks(0) |
136 | + | local data = pim.getAllStacks(0) |
137 | - | for slot =1, size do |
137 | + | for slot =1, size do |
138 | - | if data[slot] then |
138 | + | if data[slot] then |
139 | - | for ind = 1,#items do |
139 | + | for ind = 1,#items do |
140 | - | if data[slot].id == items[ind][3] then |
140 | + | if data[slot].id == items[ind][3] then |
141 | - | if data[slot].dmg == tonumber(items[ind][4]) then |
141 | + | if data[slot].dmg == tonumber(items[ind][4]) then |
142 | - | ore_dict = items[ind][3]..items[ind][4] |
142 | + | ore_dict = items[ind][3]..items[ind][4] |
143 | - | break |
143 | + | break |
144 | - | end |
144 | + | end |
145 | - | end |
145 | + | end |
146 | - | end |
146 | + | end |
147 | - | |
147 | + | |
148 | - | local network = interface.getItemsInNetwork() |
148 | + | local network = interface.getItemsInNetwork() |
149 | - | for ind2 = 1,#items do |
149 | + | for ind2 = 1,#items do |
150 | - | if ore_dict == items[ind2][3]..items[ind2][4] then |
150 | + | if ore_dict == items[ind2][3]..items[ind2][4] then |
151 | - | |
151 | + | |
152 | - | local ore = items[ind2][5] |
152 | + | local ore = items[ind2][5] |
153 | - | local dmg = items[ind2][6] |
153 | + | local dmg = items[ind2][6] |
154 | - | local ore_name = items[ind2][2] |
154 | + | local ore_name = items[ind2][2] |
155 | - | for net = 1,#network do |
155 | + | for net = 1,#network do |
156 | - | if network[net].name == ore then |
156 | + | if network[net].name == ore then |
157 | - | if network[net].damage == tonumber(dmg) then |
157 | + | if network[net].damage == tonumber(dmg) then |
158 | - | if network[net].size >= tonumber(items[ind2][1]) then |
158 | + | if network[net].size >= tonumber(items[ind2][1]) then |
159 | - | item_count = pim.pushItem("DOWN",slot,(network[net].size/items[ind2][1])) |
159 | + | item_count = pim.pushItem("DOWN",slot,(network[net].size/items[ind2][1])) |
160 | - | |
160 | + | |
161 | - | if item_count==nil then |
161 | + | if item_count==nil then |
162 | - | gpu.fill(1,1,w,1,' ') |
162 | + | gpu.fill(1,1,w,1,' ') |
163 | - | center(1,"Не удалось загрузить предмет, вы сошли с PIM. А вас просили не сходить...", 0xff0000) |
163 | + | center(1,"Не удалось загрузить предмет, вы сошли с PIM. А вас просили не сходить...", 0xff0000) |
164 | - | elseif item_count==0 then |
164 | + | elseif item_count==0 then |
165 | - | gpu.fill(1,1,w,1,' ') |
165 | + | gpu.fill(1,1,w,1,' ') |
166 | - | center(1,"Ошибка загрузки МЭ", 0xff0000) |
166 | + | center(1,"Ошибка загрузки МЭ", 0xff0000) |
167 | - | else |
167 | + | else |
168 | - | |
168 | + | |
169 | - | local drop_count = item_count*items[ind2][1] |
169 | + | local drop_count = item_count*items[ind2][1] |
170 | - | local ingot_name = items[ind2][7] |
170 | + | local ingot_name = items[ind2][7] |
171 | - | gpu.fill(1,1,w,1," ") |
171 | + | gpu.fill(1,1,w,1," ") |
172 | - | center(1,"Меняю "..item_count.." "..ore_name.." на "..drop_count.." "..ingot_name,0xFFFFFF) |
172 | + | center(1,"Меняю "..item_count.." "..ore_name.." на "..drop_count.." "..ingot_name,0xFFFFFF) |
173 | - | pushItem({name = ore,damage = tonumber(dmg)},drop_count,ingot_name) |
173 | + | pushItem({name = ore,damage = tonumber(dmg)},drop_count,ingot_name) |
174 | - | end |
174 | + | end |
175 | - | |
175 | + | |
176 | - | break |
176 | + | break |
177 | - | end |
177 | + | end |
178 | - | end |
178 | + | end |
179 | - | end |
179 | + | end |
180 | - | end |
180 | + | end |
181 | - | |
181 | + | |
182 | - | |
182 | + | |
183 | - | if item_count then |
183 | + | if item_count then |
184 | - | item_count = false |
184 | + | item_count = false |
185 | - | ore_dict = "" |
185 | + | ore_dict = "" |
186 | - | break |
186 | + | break |
187 | - | end |
187 | + | end |
188 | - | end |
188 | + | end |
189 | - | end |
189 | + | end |
190 | - | end |
190 | + | end |
191 | - | |
191 | + | |
192 | - | end |
192 | + | end |
193 | - | |
193 | + | |
194 | - | |
194 | + | |
195 | end | |
196 | - | |
196 | + | |
197 | - | |
197 | + | |
198 | - | function draw_img(img,x,y,fore,back) |
198 | + | function draw_img(img,x,y,fore,back) |
199 | - | fore =fore or 0xffffff |
199 | + | fore =fore or 0xffffff |
200 | - | back = back or 0x0 |
200 | + | back = back or 0x0 |
201 | - | oldFG = gpu.getForeground() |
201 | + | oldFG = gpu.getForeground() |
202 | - | gpu.setForeground(fore) |
202 | + | gpu.setForeground(fore) |
203 | - | local i=0 |
203 | + | local i=0 |
204 | - | for line in img:gmatch("([^\n]*)\n?") do |
204 | + | for line in img:gmatch("([^\n]*)\n?") do |
205 | - | gpu.set(x,y+i,line) |
205 | + | gpu.set(x,y+i,line) |
206 | - | i=i+1 |
206 | + | i=i+1 |
207 | - | end |
207 | + | end |
208 | - | |
208 | + | |
209 | - | gpu.setForeground(oldFG) |
209 | + | gpu.setForeground(oldFG) |
210 | end | |
211 | - | |
211 | + | |
212 | - | local img = require('mcskill_img2') |
212 | + | local img = require('mcskill_img2') |
213 | - | local cl = require('copyleft') |
213 | + | local cl = require('copyleft') |
214 | - | gpu.fill(1,1,w,h," ") |
214 | + | gpu.fill(1,1,w,h," ") |
215 | - | while true do |
215 | + | while true do |
216 | - | print_items() |
216 | + | print_items() |
217 | - | draw_img(img,1,h-13,0x00a400) |
217 | + | draw_img(img,1,h-13,0x00a400) |
218 | - | cl() |
218 | + | cl() |
219 | - | exchange_ore_dict() |
219 | + | exchange_ore_dict() |
220 | - | os.sleep(0.5) |
220 | + | os.sleep(0.5) |
221 | end |