diff --git a/digiline.lua b/digiline.lua index 6913c36..098ea4f 100644 --- a/digiline.lua +++ b/digiline.lua @@ -101,15 +101,19 @@ function digibuilder.digiline_effector(pos, _, channel, msg) return end - -- check if node is in inventory + local is_creative = meta:get_int("creative") == 1 local inv = meta:get_inventory() - if not inv:contains_item("main", msg.name) then - digilines.receptor_send(pos, digibuilder.digiline_rules, set_channel, { - pos = msg.pos, - error = true, - message = "Item not in inventory: " .. msg.name - }) - return + + if not is_creative then + -- check if node is in inventory + if not inv:contains_item("main", msg.name) then + digilines.receptor_send(pos, digibuilder.digiline_rules, set_channel, { + pos = msg.pos, + error = true, + message = "Item not in inventory: " .. msg.name + }) + return + end end -- get and validate place node definition @@ -133,8 +137,10 @@ function digibuilder.digiline_effector(pos, _, channel, msg) return end - -- remove item - inv:remove_item("main", msg.name) + if not is_creative then + -- remove item + inv:remove_item("main", msg.name) + end local param2 = tonumber(msg.param2) local enable_param2 = place_node_def.paramtype2 == "facedir" and param2 and param2 > 0 and param2 <= 255 diff --git a/mod.conf b/mod.conf index 09ff71a..6cf8909 100644 --- a/mod.conf +++ b/mod.conf @@ -1,3 +1,3 @@ name = digibuilder depends = digilines -optional_depends = default +optional_depends = default, pipeworks diff --git a/node.lua b/node.lua index 265cfd9..b9a7669 100644 --- a/node.lua +++ b/node.lua @@ -45,7 +45,19 @@ minetest.register_node("digibuilder:digibuilder", { after_place_node = function(pos, placer) local meta = minetest.get_meta(pos) - meta:set_string("owner", placer:get_player_name() or "") + + -- set owner + local owner = placer:get_player_name() or "" + meta:set_string("owner", owner) + + -- creative flag + local has_give = minetest.check_player_privs(owner, "give") + local has_creative = minetest.check_player_privs(owner, "creative") + if has_give or has_creative then + meta:set_int("creative", 1) + else + meta:set_int("creative", 0) + end end, on_construct = function(pos) diff --git a/readme.md b/readme.md index 46931a5..84d21d0 100644 --- a/readme.md +++ b/readme.md @@ -52,10 +52,7 @@ For code examples for the `luacontroller` see the "examples" directory # Open issues -* [ ] creative mode * [ ] `after_place_node(pos, placer, itemstack, pointed_thing)` compat (digtron mod?) - -further issues: * [ ] Storage of read schematics/buildings