mirror of
https://cheapiesystems.com/git/icemachine
synced 2024-11-23 15:53:52 +01:00
Require a water supply if pipeworks is installed
This commit is contained in:
parent
24cbcff820
commit
b9dfbc00dc
2
README
2
README
@ -1,3 +1,3 @@
|
||||
This mod adds an ice machine, ice bin, and ice cubes.
|
||||
|
||||
To make the machine work, place it on top of an ice bin and turn it on. It will slowly produce ice cubes and eject them into the bin. The cubes can then be crafted (9 at a time) into ice blocks. If technic is installed, these ice blocks can then be ground into snow if desired.
|
||||
To make the machine work, place it on top of an ice bin and turn it on. If pipeworks is installed, a pipe carrying water must be within 1m of the machine. After right-clicking and turning the machine on, it will slowly produce ice cubes and eject them into the bin. The cubes can then be crafted (9 at a time) into ice blocks. If technic is installed, these ice blocks can then be ground into snow if desired.
|
||||
|
42
init.lua
42
init.lua
@ -1,10 +1,30 @@
|
||||
local function set_formspec(meta,enabled,full)
|
||||
local pipeworks_installed = minetest.get_modpath("pipeworks")
|
||||
|
||||
local function find_water_supply(pos)
|
||||
if not pipeworks_installed then return true end
|
||||
local minp = vector.add(pos,vector.new(-1,-1,-1))
|
||||
local maxp = vector.add(pos,vector.new(1,1,1))
|
||||
local nodes = minetest.find_nodes_in_area(minp,maxp,"group:pipe")
|
||||
for _,pos in pairs(nodes) do
|
||||
local node = minetest.get_node(pos)
|
||||
if string.match(node.name,"^pipeworks:.*_loaded$") then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function set_formspec(meta,enabled,full,water)
|
||||
local status
|
||||
if enabled then
|
||||
if full then
|
||||
status = "Full Bin"
|
||||
if water then
|
||||
if full then
|
||||
status = "Full Bin"
|
||||
else
|
||||
status = "Making Ice"
|
||||
end
|
||||
else
|
||||
status = "Making Ice"
|
||||
status = "Water Error"
|
||||
end
|
||||
else
|
||||
status = "Off"
|
||||
@ -23,17 +43,23 @@ local function update_status(pos,meta,ice)
|
||||
timer:stop()
|
||||
set_formspec(meta,false)
|
||||
else
|
||||
local water = find_water_supply(pos)
|
||||
local binpos = vector.add(pos,vector.new(0,-1,0))
|
||||
local binnode = minetest.get_node(binpos)
|
||||
local binmeta = minetest.get_meta(binpos)
|
||||
local bininv = binmeta:get_inventory()
|
||||
if binnode.name ~= "icemachine:bin" or not bininv:room_for_item("ice","icemachine:cube") then
|
||||
timer:stop()
|
||||
set_formspec(meta,true,true)
|
||||
set_formspec(meta,true,true,true)
|
||||
else
|
||||
if not timer:is_started() then timer:start(30) end
|
||||
if ice then bininv:add_item("ice","icemachine:cube 9") end
|
||||
set_formspec(meta,true,false)
|
||||
if water then
|
||||
if not timer:is_started() then timer:start(30) end
|
||||
if ice then bininv:add_item("ice","icemachine:cube 9") end
|
||||
set_formspec(meta,true,false,true)
|
||||
else
|
||||
timer:stop()
|
||||
set_formspec(meta,true,false,false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user