added filter

This commit is contained in:
cale 2016-02-19 18:21:57 +01:00
parent 7bbfb82052
commit 94c006d167
5 changed files with 64 additions and 0 deletions

16
mods/filter/LICENSE.txt Normal file
View File

@ -0,0 +1,16 @@
License for Code
----------------
Copyright (C) 2016 cd2 (cdqwertz) <cdqwertz@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
http://www.gnu.org/licenses/lgpl-2.1.html
License for Media
-----------------
CC-BY-SA 3.0 UNPORTED. Created by cd2 (cdqwertz)

1
mods/filter/depends.txt Normal file
View File

@ -0,0 +1 @@
default

47
mods/filter/init.lua Normal file
View File

@ -0,0 +1,47 @@
filter = {}
filter.materials = {}
local filter_form = "size[8,6]"
local filter_form = filter_form..default.gui_colors
local filter_form = filter_form..default.gui_bg
local filter_form = filter_form.."list[current_name;main;3.5,0.3;1,1;]"
local filter_form = filter_form..default.itemslot_bg(3.5,0.3,1,1)
local filter_form = filter_form.."list[current_player;main;0,1.85;8,1;]"
local filter_form = filter_form..default.itemslot_bg(0,1.85,8,1)
local filter_form = filter_form.."list[current_player;main;0,3.08;8,3;8]"
local filter_form = filter_form..default.itemslot_bg(0,3.08,8,3)
function filter.register_material(name, drops)
filter.materials[name] = drops
end
filter.register_material("default:sand", {"default:stone_item", "default:diamond"})
minetest.register_node("filter:filter", {
description = "Filter",
tiles = {"filter_filter_top.png", "filter_filter.png"},
groups = {crumbly=3},
on_punch = function(pos, node, player, pointed_thing)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local item = inv:get_stack("main", 1)
print("[filter] item : " .. item:to_string())
if item:get_count() == 1 then
if filter.materials[item:get_name()] then
inv:set_stack("main", 1, {name = filter.materials[item:get_name()][1]})
else
meta:set_string("infotext", "[filter] This wont work...")
end
else
meta:set_string("infotext", "[filter] Put only one item in the filter!")
end
end,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", filter_form)
meta:set_string("infotext", "Filter")
local inv = meta:get_inventory()
inv:set_size("main", 1)
end,
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 B