summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeija <norrepli@gmail.com>2013-06-19 14:23:29 +0200
committerJeija <norrepli@gmail.com>2013-06-19 14:23:29 +0200
commit1711cbcbd83c7ed4d59827f24da941b4c4d42741 (patch)
tree7c53273c191a2db24fa5932917993e1c13ed4854
parent6efe579f68eff1deaa08cf34e44d0c0411f8c498 (diff)
Add dispenserorigin/dispenser
-rw-r--r--mesecons_dispenser/depends.txt1
-rw-r--r--mesecons_dispenser/init.lua57
-rw-r--r--mesecons_textures/textures/mesecons_dispenser_bottom.pngbin0 -> 731 bytes
-rw-r--r--mesecons_textures/textures/mesecons_dispenser_front.pngbin0 -> 827 bytes
-rw-r--r--mesecons_textures/textures/mesecons_dispenser_side.pngbin0 -> 731 bytes
-rw-r--r--mesecons_textures/textures/mesecons_dispenser_top.pngbin0 -> 731 bytes
6 files changed, 58 insertions, 0 deletions
diff --git a/mesecons_dispenser/depends.txt b/mesecons_dispenser/depends.txt
new file mode 100644
index 0000000..4ad96d5
--- /dev/null
+++ b/mesecons_dispenser/depends.txt
@@ -0,0 +1 @@
+default
diff --git a/mesecons_dispenser/init.lua b/mesecons_dispenser/init.lua
new file mode 100644
index 0000000..f974b4a
--- /dev/null
+++ b/mesecons_dispenser/init.lua
@@ -0,0 +1,57 @@
+minetest.register_node("mesecons_dispenser:dispenser", {
+ description = "Dispenser",
+ tiles = {"mesecons_dispenser_top.png" , "mesecons_dispenser_bottom.png",
+ "mesecons_dispenser_side.png", "mesecons_dispenser_side.png" ,
+ "mesecons_dispenser_side.png", "mesecons_dispenser_front.png"},
+ paramtype2 = "facedir",
+ groups = {cracky=2},
+ sounds = default.node_sound_stone_defaults(),
+ on_construct = function(pos)
+ local meta = minetest.env:get_meta(pos)
+ meta:set_string("formspec",
+ "size[8,7]"..
+ "list[current_name;main;2.5,0;3,3;]"..
+ "list[current_player;main;0,3;8,4;]")
+ local inv = meta:get_inventory()
+ inv:set_size("main", 3*3)
+ end,
+ mesecons = {effector={
+ action_on = function (pos, node)
+ local dir = {{x=1, y=0, z=0}}
+ for _ = 0, node.param2 do
+ dir = mesecon:rotate_rules_left(dir)
+ end
+ dir = dir[1]
+ local objpos = mesecon:addPosRule(pos, {x=dir.x/2, y=dir.y/2, z=dir.z/2})
+ --minetest.env:add_node(mesecon:addPosRule(pos, dir[1]), {name="default:wood"})
+ local inv = minetest.env:get_meta(pos):get_inventory()
+ local stacks = {}
+ for j = 1, 9 do
+ local ts = inv:get_stack("main", j)
+ if not ts:is_empty() then
+ table.insert(stacks, {stack = ts, id = j})
+ end
+ end
+ print(dump(stacks))
+ if #stacks > 0 then
+ local sn = math.random(1, #stacks)
+ local takenitem = stacks[sn].stack:take_item()
+ inv:set_stack("main", stacks[sn].id, stacks[sn].stack)
+ print(dump(takenitem:to_table()))
+ local obj = minetest.env:add_item(objpos, takenitem:to_table())
+ obj:setvelocity({ x=dir.x*5+math.random(1, 100)/50-0.5,
+ y=dir.y*5+math.random(1, 100)/50-0.5,
+ z=dir.z*5+math.random(1, 100)/50-0.5})
+ end
+ end
+ }},
+})
+
+minetest.register_craft({
+ output = 'mesecons_dispenser:dispenser',
+ recipe = {
+ {"default:cobble", "default:cobble", "default:cobble"},
+ {"default:cobble", "mesecons_materials:fiber", "default:cobble"},
+ {"default:cobble", "group:mesecon_conductor_craftable", "default:cobble"},
+ }
+})
diff --git a/mesecons_textures/textures/mesecons_dispenser_bottom.png b/mesecons_textures/textures/mesecons_dispenser_bottom.png
new file mode 100644
index 0000000..c86782a
--- /dev/null
+++ b/mesecons_textures/textures/mesecons_dispenser_bottom.png
Binary files differ
diff --git a/mesecons_textures/textures/mesecons_dispenser_front.png b/mesecons_textures/textures/mesecons_dispenser_front.png
new file mode 100644
index 0000000..ea07ed1
--- /dev/null
+++ b/mesecons_textures/textures/mesecons_dispenser_front.png
Binary files differ
diff --git a/mesecons_textures/textures/mesecons_dispenser_side.png b/mesecons_textures/textures/mesecons_dispenser_side.png
new file mode 100644
index 0000000..c86782a
--- /dev/null
+++ b/mesecons_textures/textures/mesecons_dispenser_side.png
Binary files differ
diff --git a/mesecons_textures/textures/mesecons_dispenser_top.png b/mesecons_textures/textures/mesecons_dispenser_top.png
new file mode 100644
index 0000000..c86782a
--- /dev/null
+++ b/mesecons_textures/textures/mesecons_dispenser_top.png
Binary files differ