SHOW:
|
|
- or go back to the newest paste.
1 | - | --ore dumper |
1 | + | --inventory filter, ore dumping for mining |
2 | - | --proof of concept |
2 | + | |
3 | ||
4 | --Warning this script may break between versions 1.16.5 - 1.19.2 | |
5 | ||
6 | local im = peripheral.find("inventoryManager") | |
7 | local cb = peripheral.find("chatBox") | |
8 | - | if im == nil then error("im not found") end |
8 | + | |
9 | - | if cb == bil then error("cb not found") end |
9 | + | if not im then error("inventoryManager not found") end |
10 | if not cb then error("chatBox not found") end | |
11 | - | filter = false |
11 | + | |
12 | - | sendIt = {} |
12 | + | local filter, match = false, false |
13 | - | match = false |
13 | + | local tagFilter = {"forge:ores", "forge:raw_materials"} |
14 | ||
15 | local function chatListener() | |
16 | while true do | |
17 | local event = { os.pullEvent("chat") } | |
18 | - | for k,v in pairs(event) do |
18 | + | if event[3]:lower() == "ore on" then |
19 | - | print(k,v) |
19 | + | filter = true |
20 | - | end |
20 | + | cb.sendMessageToPlayer("ORE ON", event[2]) |
21 | - | if event[3] == "ore on" then |
21 | + | elseif event[3]:lower() == "ore off" then |
22 | - | filter = true |
22 | + | filter = false |
23 | - | elseif event[3] == "ore off" then |
23 | + | cb.sendMessageToPlayer("ORE OFF", event[2]) |
24 | - | filter = false |
24 | + | |
25 | - | end |
25 | + | |
26 | end | |
27 | ||
28 | local function pushItems() | |
29 | - | local function toggleOreDeposit() |
29 | + | |
30 | if filter then | |
31 | - | if msg == "ore on" then |
31 | + | myInv = im.getItems() |
32 | - | cb.sendMessageToPlayer("ORE ON", player) |
32 | + | for slot, item in pairs(myInv) do |
33 | - | elseif msg == "ore off" then |
33 | + | for _, tag in pairs(item.tags) do |
34 | - | cb.sendMessageToPlayer("ORE OFF", player) |
34 | + | for k, v in pairs(tagFilter) do |
35 | if string.find(tag, v) then | |
36 | - | print(filter) |
36 | + | match = true |
37 | - | os.sleep(10) |
37 | + | break |
38 | end | |
39 | end | |
40 | end | |
41 | if match then | |
42 | - | while true do |
42 | + | --im.removeItemFromPlayer("UP", item.count, item.slot) NO LONGER WORKS IN 1.19.2 |
43 | - | myInv = im.getItems() |
43 | + | print(item.name .. " | " .. item.count) |
44 | - | |
44 | + | im.removeItemFromPlayerNBT("top", item.count, -1, {fromSlot=item.slot, count=item.count}) |
45 | - | for k,v in pairs(myInv) do |
45 | + | match = false |
46 | - | for k,v in pairs(v.tags) do |
46 | + | end |
47 | - | --print(k,v) |
47 | + | end |
48 | - | if string.find(v, "forge:ores") then |
48 | + | |
49 | - | match = true |
49 | + | os.sleep(10) |
50 | - | break |
50 | + | |
51 | - | end |
51 | + | |
52 | - | -- print("if there is a match, doesn't run!") |
52 | + | |
53 | - | end |
53 | + | parallel.waitForAny(chatListener, pushItems) |