diff --git a/depends.txt b/depends.txt index 4aae46a..54d0584 100644 --- a/depends.txt +++ b/depends.txt @@ -13,3 +13,4 @@ mobs_animal ? mobs_better_rat ? mobs_slimes ? mobs_sandworm ? +wiki diff --git a/nodes.lua b/nodes.lua index 8df448f..b3aa87d 100644 --- a/nodes.lua +++ b/nodes.lua @@ -1,3 +1,60 @@ +-- TODO: refactor / cleanup +-- +function illuna.wikiconstruct(pos) + local meta = minetest.get_meta(pos) + minetest.add_entity({x=pos.x, y=pos.y+0.96, z=pos.z}, "illuna:wikitop") + local timer = minetest.get_node_timer(pos) + timer:start(5.0) +end + +function illuna.wikidestruct(pos) + for _, obj in pairs(minetest.get_objects_inside_radius(pos, 0.9)) do + if obj and obj:get_luaentity() and + obj:get_luaentity().name == "illuna:wikitop" then + obj:remove() + break + end + end +end + +minetest.override_item("wiki:wiki", { + tiles= { + "illuna_wiki_top.png", + "illuna_wiki_bottom.png", + "illuna_wiki_side.png", + "illuna_wiki_side.png", + "illuna_wiki_side.png", + "illuna_wiki_side.png", + }, + on_construct = illuna.wikiconstruct, + on_destruct = illuna.wikidestruct +}) + +minetest.register_entity("illuna:wikitop", { + visual = "wielditem", + visual_size = {x=0.4, y=0.4}, + collisionbox = {0}, + physical = false, + automatic_rotate = math.pi * 0.15, + nametag = "Illuna Wiki", + nametag_color = "#6893c4", + textures = {"illuna:wikitop"}, + on_activate = function(self) + local pos = self.object:getpos() + local pos_under = {x=pos.x, y=pos.y-1, z=pos.z} + if minetest.get_node(pos_under).name ~= "wiki:wiki" then + self.object:remove() + end + end +}) + +-- +-- + +minetest.register_craftitem("illuna:wikitop", { + inventory_image = "illuna_wikitop.png", +}) + minetest.register_node("illuna:desert_gravel", { description = "Gravel", tiles = {"illuna_desertgravel.png"},