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