mirror of
https://github.com/kepler155c/opus
synced 2024-12-26 00:20:26 +00:00
throttlee
This commit is contained in:
parent
c34b46699b
commit
9a0c584cba
@ -541,9 +541,7 @@ function Builder:getGenericSupplyList(blockIndex)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Builder:substituteBlocks()
|
function Builder:substituteBlocks()
|
||||||
local spinner = UI.Spinner({
|
local throttle = Util.throttle()
|
||||||
spinSymbols = { '' }
|
|
||||||
})
|
|
||||||
|
|
||||||
for _,b in pairs(schematic.blocks) do
|
for _,b in pairs(schematic.blocks) do
|
||||||
|
|
||||||
@ -560,7 +558,7 @@ function Builder:substituteBlocks()
|
|||||||
b.dmg = sub.sdmg
|
b.dmg = sub.sdmg
|
||||||
end
|
end
|
||||||
|
|
||||||
spinner:spin()
|
throttle()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -27,15 +27,24 @@ local function findObsidian()
|
|||||||
local _,b = turtle.inspectDown()
|
local _,b = turtle.inspectDown()
|
||||||
if b and (b.name == 'minecraft:lava' or b.name == 'minecraft:flowing_lava') then
|
if b and (b.name == 'minecraft:lava' or b.name == 'minecraft:flowing_lava') then
|
||||||
if turtle.selectSlot('minecraft:water_bucket') then
|
if turtle.selectSlot('minecraft:water_bucket') then
|
||||||
turtle.up()
|
while not turtle.up() do
|
||||||
|
print('stuck')
|
||||||
|
end
|
||||||
turtle.placeDown()
|
turtle.placeDown()
|
||||||
os.sleep(2)
|
os.sleep(2)
|
||||||
turtle.placeDown()
|
turtle.placeDown()
|
||||||
turtle.down()
|
turtle.down()
|
||||||
|
turtle.select(1)
|
||||||
_, b = turtle.inspectDown()
|
_, b = turtle.inspectDown()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if turtle.getCount(16) > 0 then
|
||||||
|
print('Inventory full')
|
||||||
|
print('Enter to continue...')
|
||||||
|
read()
|
||||||
|
end
|
||||||
|
|
||||||
if b and b.name == 'minecraft:obsidian' then
|
if b and b.name == 'minecraft:obsidian' then
|
||||||
turtle.digDown()
|
turtle.digDown()
|
||||||
addNode(node)
|
addNode(node)
|
||||||
@ -78,6 +87,7 @@ local s, m = turtle.run(function()
|
|||||||
os.sleep(2)
|
os.sleep(2)
|
||||||
turtle.placeDown()
|
turtle.placeDown()
|
||||||
turtle.down()
|
turtle.down()
|
||||||
|
turtle.select(1)
|
||||||
until turtle.abort
|
until turtle.abort
|
||||||
end)
|
end)
|
||||||
turtle.goto(0, 0, 0, 0)
|
turtle.goto(0, 0, 0, 0)
|
||||||
|
@ -21,13 +21,17 @@ function Util.tryTimes(attempts, f, ...)
|
|||||||
return unpack(result)
|
return unpack(result)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Util.throttle()
|
function Util.throttle(fn)
|
||||||
local ts = os.time()
|
local ts = os.time()
|
||||||
return function()
|
local timeout = .095
|
||||||
|
return function(...)
|
||||||
local nts = os.time()
|
local nts = os.time()
|
||||||
if nts ~= ts then
|
if nts > ts + timeout then
|
||||||
ts = nts
|
ts = nts
|
||||||
os.sleep(0)
|
os.sleep(0)
|
||||||
|
if fn then
|
||||||
|
fn(...)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user