diff --git a/mods/craftingpack/crafting/textures/crafting_inventory_9_slots.png b/mods/craftingpack/crafting/textures/crafting_inventory_9_slots.png new file mode 100644 index 0000000000..99c86b8698 Binary files /dev/null and b/mods/craftingpack/crafting/textures/crafting_inventory_9_slots.png differ diff --git a/mods/redstone/mcl_dropper/depends.txt b/mods/redstone/mcl_dropper/depends.txt new file mode 100644 index 0000000000..acaa924122 --- /dev/null +++ b/mods/redstone/mcl_dropper/depends.txt @@ -0,0 +1 @@ +mesecons diff --git a/mods/redstone/mcl_dropper/init.lua b/mods/redstone/mcl_dropper/init.lua new file mode 100644 index 0000000000..54a8cddeb1 --- /dev/null +++ b/mods/redstone/mcl_dropper/init.lua @@ -0,0 +1,79 @@ +minetest.register_node("mcl_dropper:dropper", { + description = "Dropper", + tiles = { + "default_furnace_top.png", "default_furnace_bottom.png", + "default_furnace_side.png", "default_furnace_side.png", + "default_furnace_side.png", "mcl_dropper_dropper_front_horizontal.png" + }, + groups = {cracky=2}, + is_ground_content = false, + paramtype2 = "facedir", + sounds = mcl_sounds.node_sound_stone_defaults(), + after_place_node = function(pos) + local form = "size[9,8.75]".. + "background[-0.19,-0.25;9.41,9.49;crafting_inventory_9_slots.png]".. + mcl_core.inventory_header.. + "image[3,-0.2;5,0.75;mcl_dropper_fnt_dropper.png]".. + "list[current_player;main;0,4.5;9,3;9]".. + "list[current_player;main;0,7.74;9,1;]".. + "list[current_name;main;3,0.5;3,3;]".. + "listring[current_name;main]".. + "listring[current_player;main]" + local meta = minetest.get_meta(pos) + meta:set_string("formspec", form) + local inv = meta:get_inventory() + inv:set_size("main", 9) + end, + after_dig_node = function(pos, oldnode, oldmetadata, digger) + local meta = minetest.get_meta(pos) + local meta2 = meta + meta:from_table(oldmetadata) + local inv = meta:get_inventory() + for i=1, inv:get_size("main") do + local stack = inv:get_stack("main", i) + if not stack:is_empty() then + local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5} + minetest.add_item(p, stack) + end + end + meta:from_table(meta2:to_table()) + end, + mesecons = {effector = { + -- Drop random item when triggered + action_on = function (pos, node) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local droppos = vector.subtract(pos, minetest.facedir_to_dir(node.param2)) + local dropnode = minetest.get_node(droppos) + -- Do not drop into solid nodes + if minetest.registered_nodes[dropnode.name].walkable then + -- TODO: Drop into container + return + end + local stacks = {} + for i=1,inv:get_size("main") do + local stack = inv:get_stack("main", i) + if not stack:is_empty() then + table.insert(stacks, {stack = stack, stackpos = i}) + end + end + if #stacks >= 1 then + local r = math.random(1, #stacks) + local stack = stacks[r].stack + local dropitem = ItemStack(stack:get_name()) + minetest.add_item(droppos, dropitem) + stack:take_item() + inv:set_stack("main", stacks[r].stackpos, stack) + end + end + }} +}) + +minetest.register_craft({ + output = 'mcl_dropper:dropper', + recipe = { + {"mcl_core:cobble", "mcl_core:cobble", "mcl_core:cobble",}, + {"mcl_core:cobble", "", "mcl_core:cobble",}, + {"mcl_core:cobble", "mesecons:redstone", "mcl_core:cobble",}, + } +}) diff --git a/mods/redstone/mcl_dropper/textures/mcl_dropper_dropper_front_horizontal.png b/mods/redstone/mcl_dropper/textures/mcl_dropper_dropper_front_horizontal.png new file mode 100644 index 0000000000..7fe7bf6f5c Binary files /dev/null and b/mods/redstone/mcl_dropper/textures/mcl_dropper_dropper_front_horizontal.png differ diff --git a/mods/redstone/mcl_dropper/textures/mcl_dropper_dropper_front_vertical.png b/mods/redstone/mcl_dropper/textures/mcl_dropper_dropper_front_vertical.png new file mode 100644 index 0000000000..723c4e15ab Binary files /dev/null and b/mods/redstone/mcl_dropper/textures/mcl_dropper_dropper_front_vertical.png differ diff --git a/mods/redstone/mcl_dropper/textures/mcl_dropper_fnt_dropper.png b/mods/redstone/mcl_dropper/textures/mcl_dropper_fnt_dropper.png new file mode 100644 index 0000000000..1a15634fa0 Binary files /dev/null and b/mods/redstone/mcl_dropper/textures/mcl_dropper_fnt_dropper.png differ