View difference between Paste ID: XfgpURwd and hnSsrTcU
SHOW: | | - or go back to the newest paste.
1
-- Revised with ChatGPT 3.5
2
-- Modified to re-add the pruned while loop
3
4-
for i=1,27 do
4+
5-
  local slot = chest.getStackInSlot(i)
5+
6-
  print(slot.name.." is in slot "..i)
6+
7-
  if slot.name=="stone" then
7+
local conversionTable = {
8-
    while chest.getStackInSlot(i)~=nil do
8+
    stone = {target = "blankSlate", sleepTime = 5},
9-
--    local slot = chest.getStackInSlot(i)
9+
    blankSlate = {target = "reinforcedSlate", sleepTime = 7},
10-
-- just don't mess with inventory when it's running
10+
    reinforcedSlate = {target = nil, sleepTime = 8}
11-
--     print(slot.name.." is in slot "..i)
11+
}
12-
--     if slot.name=="stone" then
12+
13-
      print("pushing stone from "..i)
13+
function convertTo(targetBlock, sleepTime)
14-
      chest.pushItem("down",i,1)
14+
    while true do
15-
      sleep(5)
15+
        local found = false
16
        for i = 1, 27 do
17-
--    sleep(10)
17+
            local slot = chest.getStackInSlot(i)
18-
  end
18+
            if slot and slot.name == targetBlock then
19
                print("Converting "..slot.name.." to "..targetBlock.." in slot "..i)
20
                chest.pushItem("down", i, 1)
21
                sleep(sleepTime)
22
                found = true
23
                break
24
            end
25
        end
26
        if not found then
27
            break
28
        end
29
    end
30
end
31
32
for _, conversionInfo in pairs(conversionTable) do
33
    convertTo(conversionInfo.target, conversionInfo.sleepTime)
34
end
35