mirror of
https://git.minetest.org/BuckarooBanzay/digibuilder.git
synced 2024-12-13 10:53:18 +01:00
creative check
This commit is contained in:
parent
4d189f01e5
commit
6c4b5295f0
26
digiline.lua
26
digiline.lua
@ -101,15 +101,19 @@ function digibuilder.digiline_effector(pos, _, channel, msg)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- check if node is in inventory
|
local is_creative = meta:get_int("creative") == 1
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
if not inv:contains_item("main", msg.name) then
|
|
||||||
digilines.receptor_send(pos, digibuilder.digiline_rules, set_channel, {
|
if not is_creative then
|
||||||
pos = msg.pos,
|
-- check if node is in inventory
|
||||||
error = true,
|
if not inv:contains_item("main", msg.name) then
|
||||||
message = "Item not in inventory: " .. msg.name
|
digilines.receptor_send(pos, digibuilder.digiline_rules, set_channel, {
|
||||||
})
|
pos = msg.pos,
|
||||||
return
|
error = true,
|
||||||
|
message = "Item not in inventory: " .. msg.name
|
||||||
|
})
|
||||||
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- get and validate place node definition
|
-- get and validate place node definition
|
||||||
@ -133,8 +137,10 @@ function digibuilder.digiline_effector(pos, _, channel, msg)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- remove item
|
if not is_creative then
|
||||||
inv:remove_item("main", msg.name)
|
-- remove item
|
||||||
|
inv:remove_item("main", msg.name)
|
||||||
|
end
|
||||||
|
|
||||||
local param2 = tonumber(msg.param2)
|
local param2 = tonumber(msg.param2)
|
||||||
local enable_param2 = place_node_def.paramtype2 == "facedir" and param2 and param2 > 0 and param2 <= 255
|
local enable_param2 = place_node_def.paramtype2 == "facedir" and param2 and param2 > 0 and param2 <= 255
|
||||||
|
2
mod.conf
2
mod.conf
@ -1,3 +1,3 @@
|
|||||||
name = digibuilder
|
name = digibuilder
|
||||||
depends = digilines
|
depends = digilines
|
||||||
optional_depends = default
|
optional_depends = default, pipeworks
|
||||||
|
14
node.lua
14
node.lua
@ -45,7 +45,19 @@ minetest.register_node("digibuilder:digibuilder", {
|
|||||||
|
|
||||||
after_place_node = function(pos, placer)
|
after_place_node = function(pos, placer)
|
||||||
local meta = minetest.get_meta(pos)
|
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,
|
end,
|
||||||
|
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
|
@ -52,10 +52,7 @@ For code examples for the `luacontroller` see the "examples" directory
|
|||||||
|
|
||||||
# Open issues
|
# Open issues
|
||||||
|
|
||||||
* [ ] creative mode
|
|
||||||
* [ ] `after_place_node(pos, placer, itemstack, pointed_thing)` compat (digtron mod?)
|
* [ ] `after_place_node(pos, placer, itemstack, pointed_thing)` compat (digtron mod?)
|
||||||
|
|
||||||
further issues:
|
|
||||||
* [ ] Storage of read schematics/buildings
|
* [ ] Storage of read schematics/buildings
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user