diff --git a/mods/bg_funnel/api.lua b/mods/bg_funnel/api.lua deleted file mode 100644 index 51be302..0000000 --- a/mods/bg_funnel/api.lua +++ /dev/null @@ -1,57 +0,0 @@ -local function get_inventory (pos) - local meta = minetest.get_meta(pos) - return minetest.deserialize(meta:get_string("inventory")) -end - -local function set_inventory (pos, inventory) - local meta = minetest.get_meta(pos) - meta:set_string("inventory", minetest.serialize(inventory)) -end - - - -local function push (pos, value) - local inventory = get_inventory(pos) - if not inventory then return false end - - table.insert(inventory, value) - set_inventory(pos, inventory) - return true -end - -local function pop (pos) - local inventory = get_inventory(pos) - if not inventory then return nil end - - local value = table.remove(inventory, 1) - set_inventory(pos, inventory) - return value -end - - - -local function place_funnel (itemstack, placed, pointed) - local result = minetest.item_place(itemstack, placer, pointed) - - local pos = pointed.above - local meta = minetest.get_meta(pos) - set_inventory(pos, {}) - - return result -end - -local function dig_funnel (pos, ...) - local result = minetest.node_dig(pos, ...) - return result -end - - - -return { - get_inventory = get_inventory, - set_inventory = set_inventory, - place_funnel = place_funnel, - dig_funnel = dig_funnel, - push = push, - pop = pop, -} diff --git a/mods/bg_funnel/funnel.lua b/mods/bg_funnel/funnel.lua deleted file mode 100644 index 3af1384..0000000 --- a/mods/bg_funnel/funnel.lua +++ /dev/null @@ -1,82 +0,0 @@ -local modname = minetest.get_current_modname() - -local api = load_file("api") - -local function get_meta_table (pos) - return minetest.get_meta(pos):to_table() -end - -local function set_meta (pos, meta_table) - local meta = minetest.get_meta(pos) - for key, value in pairs(meta_table) do - local fn = nil - if type(value) == "string" then fn = "set_string" end - if type(value) == "int" then fn = "set_int" end - if type(value) == "float" then fn = "set_float" end - if fn then - meta[fn](key, value) - end - end -end - -local function attempt_input (pos) - -- TODO: add max limit for amount of nodes inside funnel inventory. - local above = pos + blockgame.vector.dirs.up - if minetest.get_node(above).name == "air" then return false end - - local node = minetest.get_node(above) - local meta = get_meta_table(above) - local value = { - node = node, - meta = meta, - } - - local success = api.push(pos, value) - if not success then return false end - minetest.remove_node(above) - return true -end - -local function attempt_output (pos) - local below = pos + blockgame.vector.dirs.down - if minetest.get_node(below).name ~= "air" then return false end - - local value = api.pop(pos) - if not value then return nil end - - local node = value.node - local meta = value.meta - minetest.set_node(below, node) - set_meta(below, meta) - - return true -end - -blockgame.register_abm({ - label = "funnel nodes", - nodenames = {modname .. ":funnel"}, - interval = 1, - chance = 1, - catch_up = false, - action = function (pos) - -- NOTE: metadata storage might not work, and funnels might not be able to pick up other funnels successfully. - attempt_input(pos) - attempt_output(pos) - end, -}) - - - --- NOTE: the documentation says `register_on_placenode` is "not recommended"; what else could be used for this? -minetest.register_on_placenode(function (pos) - local below = pos + blockgame.vector.dirs.down - if minetest.get_node(below).name ~= modname .. ":funnel" then return end - attempt_input(below) -end) - --- NOTE: the documentation says `register_on_dignode` is "not recommended"; what else could be used for this? -minetest.register_on_dignode(function (pos) - local above = pos + blockgame.vector.dirs.up - if minetest.get_node(above).name ~= modname .. ":funnel" then return end - attempt_output(above) -end) diff --git a/mods/bg_funnel/init.lua b/mods/bg_funnel/init.lua deleted file mode 100644 index 5e12982..0000000 --- a/mods/bg_funnel/init.lua +++ /dev/null @@ -1,6 +0,0 @@ --- this mod is disabled for now. ---[[ -load_file("node") -load_file("recipe") -load_file("funnel") -]]-- diff --git a/mods/bg_funnel/mod.conf b/mods/bg_funnel/mod.conf deleted file mode 100644 index 80b9366..0000000 --- a/mods/bg_funnel/mod.conf +++ /dev/null @@ -1,3 +0,0 @@ -name = bg_funnel -description = adds a funnel node to blockgame. -depends = bg_terrain, bg_api, bg_tree, bg_woodworking diff --git a/mods/bg_funnel/node.lua b/mods/bg_funnel/node.lua deleted file mode 100644 index 602df66..0000000 --- a/mods/bg_funnel/node.lua +++ /dev/null @@ -1,27 +0,0 @@ -local modname = minetest.get_current_modname() - -local api = load_file("api") - -blockgame.register_node(modname .. ":funnel", { - description = "Funnel", - tiles = { - modname .. "_funnel_top.png", - modname .. "_funnel_top.png", - modname .. "_funnel.png", - }, - groups = { - woody = 1, - }, - on_place = function (...) - return api.place_funnel(...) - end, - on_dig = function (...) - return api.dig_funnel(...) - end, - preserve_metadata = function (pos, node, meta, drops) - -- TODO: store funnel contents inside dropped item. - end, - after_place_node = function (pos, placer, item_stack) - -- TODO: recreate funnel contents from placed item. - end, -}) diff --git a/mods/bg_funnel/recipe.lua b/mods/bg_funnel/recipe.lua deleted file mode 100644 index 15a9039..0000000 --- a/mods/bg_funnel/recipe.lua +++ /dev/null @@ -1,16 +0,0 @@ -local modname = minetest.get_current_modname() - -blockgame.crafting.register_pummel_recipe({ - label = "pummel logs into funnel", - used_item = "woodworking:plank", - target_node = "bg_tree:log", - check = function (pos, used_node, target_node) - local below = pos + blockgame.vector.dirs.down - return minetest.get_node(below).name == "bg_tree:log" - end, - on_success = function (pos, used_node, target_node) - local below = pos + blockgame.vector.dirs.down - minetest.remove_node(pos) - minetest.set_node(below, {name = modname .. ":funnel"}) - end, -}) diff --git a/mods/bg_funnel/textures/bg_funnel_funnel.png b/mods/bg_funnel/textures/bg_funnel_funnel.png deleted file mode 100644 index 5e5ffca..0000000 Binary files a/mods/bg_funnel/textures/bg_funnel_funnel.png and /dev/null differ diff --git a/mods/bg_funnel/textures/bg_funnel_funnel_top.png b/mods/bg_funnel/textures/bg_funnel_funnel_top.png deleted file mode 100644 index 0a44dd1..0000000 Binary files a/mods/bg_funnel/textures/bg_funnel_funnel_top.png and /dev/null differ