Use creative.is_enabled_for for creative mode if possible (#1558)
This commit is contained in:
parent
b847888cb7
commit
077316b4cd
|
@ -89,7 +89,8 @@ function beds.register_bed(name, def)
|
|||
minetest.set_node(pos, {name = name .. "_bottom", param2 = dir})
|
||||
minetest.set_node(botpos, {name = name .. "_top", param2 = dir})
|
||||
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
if not (creative and creative.is_enabled_for
|
||||
and creative.is_enabled_for(placer:get_player_name())) then
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
|
|
|
@ -110,7 +110,8 @@ function boat.on_punch(self, puncher)
|
|||
if not self.driver then
|
||||
self.removed = true
|
||||
local inv = puncher:get_inventory()
|
||||
if not minetest.setting_getbool("creative_mode")
|
||||
if not (creative and creative.is_enabled_for
|
||||
and creative.is_enabled_for(puncher:get_player_name()))
|
||||
or not inv:contains_item("main", "boats:boat") then
|
||||
local leftover = inv:add_item("main", "boats:boat")
|
||||
-- if no room in inventory add a replacement boat to the world
|
||||
|
@ -244,7 +245,8 @@ minetest.register_craftitem("boats:boat", {
|
|||
boat = minetest.add_entity(pointed_thing.under, "boats:boat")
|
||||
if boat then
|
||||
boat:setyaw(placer:get_look_horizontal())
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
if not (creative and creative.is_enabled_for
|
||||
and creative.is_enabled_for(placer:get_player_name())) then
|
||||
itemstack:take_item()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -167,7 +167,8 @@ minetest.register_on_dieplayer(function(player)
|
|||
end
|
||||
|
||||
-- return if keep inventory set or in creative mode
|
||||
if bones_mode == "keep" or minetest.setting_getbool("creative_mode") then
|
||||
if bones_mode == "keep" or (creative and creative.is_enabled_for
|
||||
and creative.is_enabled_for(player:get_player_name())) then
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
@ -92,7 +92,8 @@ function cart_entity:on_punch(puncher, time_from_last_punch, tool_capabilities,
|
|||
end
|
||||
-- Pick up cart
|
||||
local inv = puncher:get_inventory()
|
||||
if not minetest.setting_getbool("creative_mode")
|
||||
if not (creative and creative.is_enabled_for
|
||||
+ and creative.is_enabled_for(puncher:get_player_name()))
|
||||
or not inv:contains_item("main", "carts:cart") then
|
||||
local leftover = inv:add_item("main", "carts:cart")
|
||||
-- If no room in inventory add a replacement cart to the world
|
||||
|
@ -385,7 +386,8 @@ minetest.register_craftitem("carts:cart", {
|
|||
minetest.sound_play({name = "default_place_node_metal", gain = 0.5},
|
||||
{pos = pointed_thing.above})
|
||||
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
if not (creative and creative.is_enabled_for
|
||||
and creative.is_enabled_for(placer:get_player_name())) then
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
|
|
|
@ -8,7 +8,7 @@ end
|
|||
|
||||
dofile(minetest.get_modpath("creative") .. "/inventory.lua")
|
||||
|
||||
if minetest.setting_getbool("creative_mode") then
|
||||
if creative_mode_cache then
|
||||
-- Dig time is modified according to difference (leveldiff) between tool
|
||||
-- 'maxlevel' and node 'level'. Digtime is divided by the larger of
|
||||
-- leveldiff and 1.
|
||||
|
|
|
@ -96,7 +96,8 @@ minetest.register_on_joinplayer(function(player)
|
|||
player:set_local_animation({x=0, y=79}, {x=168, y=187}, {x=189, y=198}, {x=200, y=219}, 30)
|
||||
|
||||
-- set GUI
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
if not (creative and creative.is_enabled_for
|
||||
and creative.is_enabled_for(player:get_player_name())) then
|
||||
player:set_inventory_formspec(default.gui_survival_form)
|
||||
end
|
||||
player:hud_set_hotbar_image("gui_hotbar.png")
|
||||
|
|
|
@ -471,7 +471,8 @@ function default.sapling_on_place(itemstack, placer, pointed_thing,
|
|||
minetest.log("action", player_name .. " places node "
|
||||
.. sapling_name .. " at " .. minetest.pos_to_string(pos))
|
||||
|
||||
local take_item = not minetest.setting_getbool("creative_mode")
|
||||
local take_item = not (creative and creative.is_enabled_for
|
||||
and creative.is_enabled_for(player_name))
|
||||
local newnode = {name = sapling_name}
|
||||
local ndef = minetest.registered_nodes[sapling_name]
|
||||
minetest.set_node(pos, newnode)
|
||||
|
|
|
@ -328,7 +328,7 @@ function doors.register(name, def)
|
|||
meta:set_string("infotext", "Owned by " .. pn)
|
||||
end
|
||||
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
if not (creative and creative.is_enabled_for and creative.is_enabled_for(pn)) then
|
||||
itemstack:take_item()
|
||||
end
|
||||
|
||||
|
@ -576,7 +576,7 @@ function doors.register_trapdoor(name, def)
|
|||
meta:set_string("owner", pn)
|
||||
meta:set_string("infotext", "Owned by "..pn)
|
||||
|
||||
return minetest.setting_getbool("creative_mode")
|
||||
return (creative and creative.is_enabled_for and creative.is_enabled_for(pn))
|
||||
end
|
||||
|
||||
def.on_blast = function() end
|
||||
|
|
|
@ -57,7 +57,8 @@ farming.hoe_on_use = function(itemstack, user, pointed_thing, uses)
|
|||
gain = 0.5,
|
||||
})
|
||||
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
if not (creative and creative.is_enabled_for
|
||||
and creative.is_enabled_for(user:get_player_name())) then
|
||||
-- wear tool
|
||||
local wdef = itemstack:get_definition()
|
||||
itemstack:add_wear(65535/(uses-1))
|
||||
|
@ -187,7 +188,8 @@ farming.place_seed = function(itemstack, placer, pointed_thing, plantname)
|
|||
-- add the node and remove 1 item from the itemstack
|
||||
minetest.add_node(pt.above, {name = plantname, param2 = 1})
|
||||
tick(pt.above)
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
if not (creative and creative.is_enabled_for
|
||||
and creative.is_enabled_for(placer:get_player_name())) then
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
|
|
|
@ -85,13 +85,13 @@ minetest.register_tool("fire:flint_and_steel", {
|
|||
"fire_flint_and_steel",
|
||||
{pos = sound_pos, gain = 0.5, max_hear_distance = 8}
|
||||
)
|
||||
local player_name = user:get_player_name()
|
||||
if pointed_thing.type == "node" then
|
||||
local node_under = minetest.get_node(pointed_thing.under).name
|
||||
local nodedef = minetest.registered_nodes[node_under]
|
||||
if not nodedef then
|
||||
return
|
||||
end
|
||||
local player_name = user:get_player_name()
|
||||
if minetest.is_protected(pointed_thing.under, player_name) then
|
||||
minetest.chat_send_player(player_name, "This area is protected")
|
||||
return
|
||||
|
@ -103,7 +103,8 @@ minetest.register_tool("fire:flint_and_steel", {
|
|||
minetest.set_node(pointed_thing.above, {name = "fire:basic_flame"})
|
||||
end
|
||||
end
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
if not (creative and creative.is_enabled_for
|
||||
and creative.is_enabled_for(player_name)) then
|
||||
-- Wear tool
|
||||
local wdef = itemstack:get_definition()
|
||||
itemstack:add_wear(1000)
|
||||
|
|
|
@ -289,7 +289,8 @@ minetest.register_node("flowers:waterlily", {
|
|||
if not minetest.is_protected(pos, player_name) then
|
||||
minetest.set_node(pos, {name = "flowers:waterlily",
|
||||
param2 = math.random(0, 3)})
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
if not (creative and creative.is_enabled_for
|
||||
and creative.is_enabled_for(player_name)) then
|
||||
itemstack:take_item()
|
||||
end
|
||||
else
|
||||
|
|
|
@ -128,7 +128,8 @@ screwdriver.handler = function(itemstack, user, pointed_thing, mode, uses)
|
|||
minetest.check_for_falling(pos)
|
||||
end
|
||||
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
if not (creative and creative.is_enabled_for
|
||||
and creative.is_enabled_for(user:get_player_name())) then
|
||||
itemstack:add_wear(65535 / ((uses or 200) - 1))
|
||||
end
|
||||
|
||||
|
|
|
@ -150,6 +150,8 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
|
|||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local under = minetest.get_node(pointed_thing.under)
|
||||
local wield_item = itemstack:get_name()
|
||||
local creative_enabled = (creative and creative.is_enabled_for
|
||||
and creative.is_enabled_for(placer:get_player_name()))
|
||||
|
||||
if under and wield_item == under.name then
|
||||
-- place slab using under node orientation
|
||||
|
@ -171,7 +173,7 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
|
|||
return
|
||||
end
|
||||
minetest.set_node(pointed_thing.under, {name = recipeitem, param2 = p2})
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
if not creative_enabled then
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
|
@ -187,7 +189,7 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
|
|||
|
||||
-- else attempt to place node with proper param2
|
||||
minetest.item_place_node(ItemStack(wield_item), placer, pointed_thing, p2)
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
if not creative_enabled then
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
|
|
Loading…
Reference in New Issue