summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LICENSE24
-rw-r--r--README3
-rw-r--r--depends.txt2
-rw-r--r--init.lua150
-rw-r--r--textures/icemachine_bin_front.pngbin0 -> 255 bytes
-rw-r--r--textures/icemachine_cube.pngbin0 -> 251 bytes
-rw-r--r--textures/icemachine_machine_front.pngbin0 -> 215 bytes
-rw-r--r--textures/icemachine_machine_sides.pngbin0 -> 220 bytes
8 files changed, 179 insertions, 0 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..68a49da
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,24 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to <http://unlicense.org/>
diff --git a/README b/README
new file mode 100644
index 0000000..c3814a4
--- /dev/null
+++ b/README
@@ -0,0 +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.
diff --git a/depends.txt b/depends.txt
new file mode 100644
index 0000000..fa37cc0
--- /dev/null
+++ b/depends.txt
@@ -0,0 +1,2 @@
+default
+technic?
diff --git a/init.lua b/init.lua
new file mode 100644
index 0000000..43d0c35
--- /dev/null
+++ b/init.lua
@@ -0,0 +1,150 @@
+local function set_formspec(meta,enabled,full)
+ local status
+ if enabled then
+ if full then
+ status = "Full Bin"
+ else
+ status = "Making Ice"
+ end
+ else
+ status = "Off"
+ end
+ local fs = "size[3,2]"..
+ "box[-0.15,0;3,1.5;#0000FF]"..
+ "label[0.2,0.3;"..status.."]"..
+ "button[0.5,1.5;2,1;power;Power]"
+ meta:set_string("formspec",fs)
+end
+
+local function update_status(pos,meta,ice)
+ local timer = minetest.get_node_timer(pos)
+ local enabled = meta:get_int("enabled")==1
+ if not enabled then
+ timer:stop()
+ set_formspec(meta,false)
+ else
+ 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)
+ 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)
+ end
+ end
+end
+
+minetest.register_node("icemachine:machine",{
+ description = "Ice Machine",
+ paramtype2 = "facedir",
+ groups = {cracky=3},
+ tiles = {
+ "default_steel_block.png",
+ "default_steel_block.png",
+ "default_steel_block.png^icemachine_machine_sides.png",
+ "default_steel_block.png^icemachine_machine_sides.png",
+ "default_steel_block.png",
+ "default_steel_block.png^icemachine_machine_front.png",
+ },
+ on_construct = function(pos)
+ local meta = minetest.get_meta(pos)
+ update_status(pos,meta)
+ end,
+ on_receive_fields = function(pos,_,fields)
+ local meta = minetest.get_meta(pos)
+ if fields.power then
+ meta:set_int("enabled",math.abs(meta:get_int("enabled")-1))
+ update_status(pos,meta)
+ end
+ end,
+ on_timer = function(pos)
+ local meta = minetest.get_meta(pos)
+ update_status(pos,meta,true)
+ end,
+})
+
+minetest.register_node("icemachine:bin",{
+ description = "Ice Bin",
+ paramtype2 = "facedir",
+ groups = {cracky=3},
+ tiles = {
+ "default_steel_block.png",
+ "default_steel_block.png",
+ "default_steel_block.png",
+ "default_steel_block.png",
+ "default_steel_block.png",
+ "default_steel_block.png^icemachine_bin_front.png",
+ },
+ tube = {input_inventory="ice"},
+ on_construct = function(pos)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ inv:set_size("ice",8*3)
+ meta:set_string("formspec",
+ "size[8,9]"..
+ "list[context;ice;0,0;8,4;]"..
+ "list[current_player;main;0,5;8,4;]"..
+ "listring[]")
+ end,
+ allow_metadata_inventory_put = function(_,_,_,stack)
+ if stack:get_name() == "icemachine:cube" then
+ return(stack:get_count())
+ else
+ return(0)
+ end
+ end,
+ on_metadata_inventory_take = function(pos)
+ local machinepos = vector.add(pos,vector.new(0,1,0))
+ local machinemeta = minetest.get_meta(machinepos)
+ update_status(machinepos,machinemeta)
+ end,
+ can_dig = function(pos)
+ return(minetest.get_meta(pos):get_inventory():is_empty("ice"))
+ end,
+})
+
+minetest.register_craftitem("icemachine:cube",{
+ description = "Ice Cube",
+ inventory_image = "icemachine_cube.png",
+})
+
+minetest.register_craft({
+ output = "icemachine:machine",
+ recipe = {
+ {"default:steel_ingot", "bucket:bucket_water", "default:steel_ingot"},
+ {"default:steel_ingot", "homedecor:fence_chainlink", "homedecor:motor"},
+ {"default:steel_ingot", "bucket:bucket_empty", "homedecor:ic"},
+ },
+})
+
+minetest.register_craft({
+ output = "icemachine:bin",
+ recipe = {
+ {"homedecor:plastic_sheeting", "", "homedecor:plastic_sheeting"},
+ {"homedecor:plastic_sheeting", "", "homedecor:plastic_sheeting"},
+ {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
+ },
+})
+
+minetest.register_craft({
+ output = "default:ice",
+ recipe = {
+ {"icemachine:cube", "icemachine:cube", "icemachine:cube"},
+ {"icemachine:cube", "icemachine:cube", "icemachine:cube"},
+ {"icemachine:cube", "icemachine:cube", "icemachine:cube"},
+ },
+})
+
+minetest.register_craft({
+ type = "shapeless",
+ output = "icemachine:cube 9",
+ recipe = {"default:ice"},
+})
+
+if minetest.get_modpath("technic") then
+ technic.register_grinder_recipe({input={"default:ice 1"},output="default:snowblock 1"})
+end
diff --git a/textures/icemachine_bin_front.png b/textures/icemachine_bin_front.png
new file mode 100644
index 0000000..ef0991b
--- /dev/null
+++ b/textures/icemachine_bin_front.png
Binary files differ
diff --git a/textures/icemachine_cube.png b/textures/icemachine_cube.png
new file mode 100644
index 0000000..53a08c5
--- /dev/null
+++ b/textures/icemachine_cube.png
Binary files differ
diff --git a/textures/icemachine_machine_front.png b/textures/icemachine_machine_front.png
new file mode 100644
index 0000000..82bb19d
--- /dev/null
+++ b/textures/icemachine_machine_front.png
Binary files differ
diff --git a/textures/icemachine_machine_sides.png b/textures/icemachine_machine_sides.png
new file mode 100644
index 0000000..2c9a763
--- /dev/null
+++ b/textures/icemachine_machine_sides.png
Binary files differ