commit 0d96b0aaf1a6c08f14a86557bd9151410a28ec47 Author: Ginger88895 Date: Sat May 31 02:35:23 2014 +0000 initial commit diff --git a/Craft_Recipe.png b/Craft_Recipe.png new file mode 100644 index 0000000..d0f2d76 Binary files /dev/null and b/Craft_Recipe.png differ diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/depends.txt @@ -0,0 +1 @@ +default diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..443a152 --- /dev/null +++ b/init.lua @@ -0,0 +1,93 @@ +max_search_distance = 8 +min_search_distance = 2 +search_item = 'default:stone' + +-- All type detector + +minetest.register_node("mineral_detector:detector", { + description = "Mineral Detector", + tile_images = {"mineral_detector_none_none_none.png", "default_steel_block.png"}, + inventory_image = "mineral_detector_inv.png", + is_ground_content = true, + groups = {crumbly=3}, + drop = 'mineral_detector:detector 1', + metadata_name = "generic", + on_construct = function(pos) + --local n = minetest.get_node(pos) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", "field[text;;${text}]") + end, + on_receive_fields = function(pos, formname, fields, sender) + local meta = minetest.get_meta(pos) + fields.text = fields.text or "" + if fields.text == "" then + return + end + meta:set_string("search_item", fields.text) + UpdateDetectorAll(pos, tonumber(meta:get_string("search_distance")), meta:get_string("search_item")) + end +}) + +minetest.register_craft({ + output = 'mineral_detector:detector 1', + recipe = { + {'default:steelblock', 'default:steelblock', 'default:steelblock'}, + {'default:steelblock', 'default:coalblock', 'default:steelblock'}, + {'default:steelblock', 'default:coalblock', 'default:steelblock'}, + } +}) + +function UpdateDetectorAll(pos, search_distance, search_item) + local search_p = {x=0, y=0, z=0} + + local found = 0 + + for p_x=(pos.x-search_distance), (pos.x+search_distance) do + for p_y=(pos.y-search_distance), (pos.y+search_distance) do + for p_z=(pos.z-search_distance), (pos.z+search_distance) do + local search_n = minetest.env:get_node({x=p_x, y=p_y, z=p_z}) + + if search_n.name == search_item then + found = found + 1 + end + end + end + end + + info_text = ("Range: " .. tostring(search_distance) .. " | Found " .. search_item .. " x " .. found) + + local newmeta = minetest.env:get_meta(pos) + newmeta:set_string("infotext",info_text) + newmeta:set_string("search_distance", tostring(search_distance)) + newmeta:set_string("search_item", search_item) +end + +minetest.register_on_punchnode(function(pos, node, puncher) + if string.match(node.name, "mineral_detector:") ~= nil then + + local meta = minetest.env:get_meta(pos) + local search_distance = tonumber(meta:get_string("search_distance")) + local search_item = meta:get_string("search_item") + + if search_distance < max_search_distance then + search_distance = search_distance + 1 + else + search_distance = min_search_distance + end + + if string.match(node.name, "mineral_detector:detector") ~= nil then + UpdateDetectorAll(pos, search_distance, search_item) + end + end +end) + +minetest.register_on_placenode( +function(pos, newnode, placer) + if string.match(newnode.name, "mineral_detector:") ~= nil then + if newnode.name == "mineral_detector:detector" then + UpdateDetectorAll(pos, min_search_distance, search_item) + end + end +end +) + diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..0d148d1 Binary files /dev/null and b/screenshot.png differ diff --git a/textures/mineral_detector_coal_0.png b/textures/mineral_detector_coal_0.png new file mode 100644 index 0000000..459ef5a Binary files /dev/null and b/textures/mineral_detector_coal_0.png differ diff --git a/textures/mineral_detector_coal_1.png b/textures/mineral_detector_coal_1.png new file mode 100644 index 0000000..40eabd5 Binary files /dev/null and b/textures/mineral_detector_coal_1.png differ diff --git a/textures/mineral_detector_coal_2.png b/textures/mineral_detector_coal_2.png new file mode 100644 index 0000000..e6ea372 Binary files /dev/null and b/textures/mineral_detector_coal_2.png differ diff --git a/textures/mineral_detector_coal_3.png b/textures/mineral_detector_coal_3.png new file mode 100644 index 0000000..576a9ba Binary files /dev/null and b/textures/mineral_detector_coal_3.png differ diff --git a/textures/mineral_detector_coal_4.png b/textures/mineral_detector_coal_4.png new file mode 100644 index 0000000..c871f0b Binary files /dev/null and b/textures/mineral_detector_coal_4.png differ diff --git a/textures/mineral_detector_inv.png b/textures/mineral_detector_inv.png new file mode 100644 index 0000000..f369a00 Binary files /dev/null and b/textures/mineral_detector_inv.png differ diff --git a/textures/mineral_detector_inv_coal.png b/textures/mineral_detector_inv_coal.png new file mode 100644 index 0000000..459ef5a Binary files /dev/null and b/textures/mineral_detector_inv_coal.png differ diff --git a/textures/mineral_detector_inv_iron.png b/textures/mineral_detector_inv_iron.png new file mode 100644 index 0000000..a4db5a4 Binary files /dev/null and b/textures/mineral_detector_inv_iron.png differ diff --git a/textures/mineral_detector_inv_mese.png b/textures/mineral_detector_inv_mese.png new file mode 100644 index 0000000..b9de524 Binary files /dev/null and b/textures/mineral_detector_inv_mese.png differ diff --git a/textures/mineral_detector_iron_0.png b/textures/mineral_detector_iron_0.png new file mode 100644 index 0000000..a4db5a4 Binary files /dev/null and b/textures/mineral_detector_iron_0.png differ diff --git a/textures/mineral_detector_iron_1.png b/textures/mineral_detector_iron_1.png new file mode 100644 index 0000000..ad40e0d Binary files /dev/null and b/textures/mineral_detector_iron_1.png differ diff --git a/textures/mineral_detector_iron_2.png b/textures/mineral_detector_iron_2.png new file mode 100644 index 0000000..bf9b719 Binary files /dev/null and b/textures/mineral_detector_iron_2.png differ diff --git a/textures/mineral_detector_iron_3.png b/textures/mineral_detector_iron_3.png new file mode 100644 index 0000000..f0352e4 Binary files /dev/null and b/textures/mineral_detector_iron_3.png differ diff --git a/textures/mineral_detector_iron_4.png b/textures/mineral_detector_iron_4.png new file mode 100644 index 0000000..653e3a3 Binary files /dev/null and b/textures/mineral_detector_iron_4.png differ diff --git a/textures/mineral_detector_low_low_low.png b/textures/mineral_detector_low_low_low.png new file mode 100644 index 0000000..d37a6ad Binary files /dev/null and b/textures/mineral_detector_low_low_low.png differ diff --git a/textures/mineral_detector_low_low_none.png b/textures/mineral_detector_low_low_none.png new file mode 100644 index 0000000..152bb23 Binary files /dev/null and b/textures/mineral_detector_low_low_none.png differ diff --git a/textures/mineral_detector_low_none_low.png b/textures/mineral_detector_low_none_low.png new file mode 100644 index 0000000..c117b71 Binary files /dev/null and b/textures/mineral_detector_low_none_low.png differ diff --git a/textures/mineral_detector_low_none_none.png b/textures/mineral_detector_low_none_none.png new file mode 100644 index 0000000..f51c8ba Binary files /dev/null and b/textures/mineral_detector_low_none_none.png differ diff --git a/textures/mineral_detector_mese_0.png b/textures/mineral_detector_mese_0.png new file mode 100644 index 0000000..b9de524 Binary files /dev/null and b/textures/mineral_detector_mese_0.png differ diff --git a/textures/mineral_detector_mese_1.png b/textures/mineral_detector_mese_1.png new file mode 100644 index 0000000..f09110e Binary files /dev/null and b/textures/mineral_detector_mese_1.png differ diff --git a/textures/mineral_detector_mese_2.png b/textures/mineral_detector_mese_2.png new file mode 100644 index 0000000..699669e Binary files /dev/null and b/textures/mineral_detector_mese_2.png differ diff --git a/textures/mineral_detector_mese_3.png b/textures/mineral_detector_mese_3.png new file mode 100644 index 0000000..6d1b4f8 Binary files /dev/null and b/textures/mineral_detector_mese_3.png differ diff --git a/textures/mineral_detector_mese_4.png b/textures/mineral_detector_mese_4.png new file mode 100644 index 0000000..8681977 Binary files /dev/null and b/textures/mineral_detector_mese_4.png differ diff --git a/textures/mineral_detector_none_low_low.png b/textures/mineral_detector_none_low_low.png new file mode 100644 index 0000000..4d0d233 Binary files /dev/null and b/textures/mineral_detector_none_low_low.png differ diff --git a/textures/mineral_detector_none_low_none.png b/textures/mineral_detector_none_low_none.png new file mode 100644 index 0000000..8dccf40 Binary files /dev/null and b/textures/mineral_detector_none_low_none.png differ diff --git a/textures/mineral_detector_none_none_low.png b/textures/mineral_detector_none_none_low.png new file mode 100644 index 0000000..d4e1467 Binary files /dev/null and b/textures/mineral_detector_none_none_low.png differ diff --git a/textures/mineral_detector_none_none_none.png b/textures/mineral_detector_none_none_none.png new file mode 100644 index 0000000..2dcdf24 Binary files /dev/null and b/textures/mineral_detector_none_none_none.png differ