Skip to content

Commit

Permalink
update: 溶解罐
Browse files Browse the repository at this point in the history
  • Loading branch information
4o4E committed Dec 17, 2023
1 parent 03283e0 commit 965db6e
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ rm v1.lua && wget https://gtnh-noshock.github.io/gtnh/Weather/v1.lua && ./v1.lua
```shell
rm v1.lua && wget https://gtnh-noshock.github.io/gtnh/%E7%BB%86%E8%8F%8C%E5%9F%B9%E5%85%BB%E7%BC%B8/v1.lua && ./v1.lua
```

## 溶解罐

```shell
rm v1.lua && wget https://gtnh-noshock.github.io/gtnh/%E6%BA%B6%E8%A7%A3%E7%BD%90/v1.lua && ./v1.lua
```
43 changes: 43 additions & 0 deletions 溶解罐/v1.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
component = require("component")
os = require("os")
sides = require("sides")

local all = {}
local n = 0

-- 输入 从其中抽取
local input = sides.down
-- 输出
local output = sides.up
-- 输出容器中流体的比例, 通常为0.5
local fluid_ratio = 0.5

-- 获取所有的转运器
for address, componentType in component.list() do
if (componentType == "transposer") then
print("find transposer: ", address, componentType)
all[n] = component.proxy(address)
n = n + 1
end
end

-- 无限循环,如果想新加入转运器的话直接加入转运器,随后关机再启动程序即可
while (true) do
for _, trans in all do
local current_fluids = trans.getFluidInTank(output)
if (
current_fluids ~= nil
and current_fluids[1] ~= nil
and current_fluids[1].amount > current_fluids[1].capacity * fluid_ratio
) then
local fluid_count = current_fluids[1].amount - current_fluids[1].capacity * fluid_ratio
if (trans.transferFluid(input, output, fluid_count)) then
print("transferred ", fluid_count, " mb fluid")
else
print("transfer fluid failed , address: ", trans.address)
end
end
end
-- 每次转运后延迟1t
os.sleep(0.05)
end

0 comments on commit 965db6e

Please sign in to comment.