Add more local aliases for minetest.* namespace functions
* Add locals for - minetest.is_creative_enabled - minetest.is_protected - minetest.record_protection_violationnewmobs-master
parent
639bf936c5
commit
e54502edd6
|
@ -25,6 +25,9 @@ local add_item = minetest.add_item
|
||||||
|
|
||||||
local registered_nodes = minetest.registered_nodes
|
local registered_nodes = minetest.registered_nodes
|
||||||
local get_item_group = minetest.get_item_group
|
local get_item_group = minetest.get_item_group
|
||||||
|
local is_creative_enabled = minetest.is_creative_enabled
|
||||||
|
local is_protected = minetest.is_protected
|
||||||
|
local record_protection_violation = minetest.record_protection_violation
|
||||||
|
|
||||||
if mod_mcl_core then
|
if mod_mcl_core then
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
@ -64,7 +67,7 @@ end
|
||||||
|
|
||||||
local function give_bucket(new_bucket, itemstack, user)
|
local function give_bucket(new_bucket, itemstack, user)
|
||||||
local inv = user:get_inventory()
|
local inv = user:get_inventory()
|
||||||
if minetest.is_creative_enabled(user:get_player_name()) then
|
if is_creative_enabled(user:get_player_name()) then
|
||||||
--TODO: is a full bucket added if inv doesn't contain one?
|
--TODO: is a full bucket added if inv doesn't contain one?
|
||||||
return itemstack
|
return itemstack
|
||||||
else
|
else
|
||||||
|
@ -131,7 +134,7 @@ end
|
||||||
|
|
||||||
local function get_bucket_drop(itemstack, user, take_bucket)
|
local function get_bucket_drop(itemstack, user, take_bucket)
|
||||||
-- Handle bucket item and inventory stuff
|
-- Handle bucket item and inventory stuff
|
||||||
if take_bucket and not minetest.is_creative_enabled(user:get_player_name()) then
|
if take_bucket and not is_creative_enabled(user:get_player_name()) then
|
||||||
-- Add empty bucket and put it into inventory, if possible.
|
-- Add empty bucket and put it into inventory, if possible.
|
||||||
-- Drop empty bucket otherwise.
|
-- Drop empty bucket otherwise.
|
||||||
local new_bucket = ItemStack("mcl_buckets:bucket_empty")
|
local new_bucket = ItemStack("mcl_buckets:bucket_empty")
|
||||||
|
@ -173,8 +176,8 @@ local function on_place_bucket(itemstack, user, pointed_thing, def)
|
||||||
local pns = user:get_player_name()
|
local pns = user:get_player_name()
|
||||||
|
|
||||||
-- Check protection
|
-- Check protection
|
||||||
if minetest.is_protected(pointed_thing.under, pns) then
|
if is_protected(pointed_thing.under, pns) then
|
||||||
minetest.record_protection_violation(pointed_thing.under, pns)
|
record_protection_violation(pointed_thing.under, pns)
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -194,8 +197,8 @@ local function on_place_bucket(itemstack, user, pointed_thing, def)
|
||||||
local pns = user:get_player_name()
|
local pns = user:get_player_name()
|
||||||
|
|
||||||
-- Check protection
|
-- Check protection
|
||||||
if minetest.is_protected(pointed_thing.above, pns) then
|
if is_protected(pointed_thing.above, pns) then
|
||||||
minetest.record_protection_violation(pointed_thing.above, pns)
|
record_protection_violation(pointed_thing.above, pns)
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -232,8 +235,8 @@ local function on_place_bucket_empty(itemstack, user, pointed_thing)
|
||||||
local new_bucket
|
local new_bucket
|
||||||
local liquid_node = bucket_raycast(user)
|
local liquid_node = bucket_raycast(user)
|
||||||
if liquid_node then
|
if liquid_node then
|
||||||
if minetest.is_protected(liquid_node.above, user:get_player_name()) then
|
if is_protected(liquid_node.above, user:get_player_name()) then
|
||||||
minetest.record_protection_violation(liquid_node.above, user:get_player_name())
|
record_protection_violation(liquid_node.above, user:get_player_name())
|
||||||
end
|
end
|
||||||
local liquid_name = get_node(liquid_node.above).name
|
local liquid_name = get_node(liquid_node.above).name
|
||||||
if liquid_name then
|
if liquid_name then
|
||||||
|
@ -242,7 +245,7 @@ local function on_place_bucket_empty(itemstack, user, pointed_thing)
|
||||||
--minetest.chat_send_all("test")
|
--minetest.chat_send_all("test")
|
||||||
-- Fill bucket, but not in Creative Mode
|
-- Fill bucket, but not in Creative Mode
|
||||||
-- FIXME: remove this line
|
-- FIXME: remove this line
|
||||||
--if not minetest.is_creative_enabled(user:get_player_name()) then
|
--if not is_creative_enabled(user:get_player_name()) then
|
||||||
if not false then
|
if not false then
|
||||||
new_bucket = ItemStack({name = liquid_def.bucketname})
|
new_bucket = ItemStack({name = liquid_def.bucketname})
|
||||||
if liquid_def.on_take then
|
if liquid_def.on_take then
|
||||||
|
@ -268,14 +271,14 @@ local function on_place_bucket_empty(itemstack, user, pointed_thing)
|
||||||
if nn == "mcl_cauldrons:cauldron_3" then
|
if nn == "mcl_cauldrons:cauldron_3" then
|
||||||
-- Take water out of full cauldron
|
-- Take water out of full cauldron
|
||||||
set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"})
|
set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"})
|
||||||
if not minetest.is_creative_enabled(user:get_player_name()) then
|
if not is_creative_enabled(user:get_player_name()) then
|
||||||
new_bucket = ItemStack("mcl_buckets:bucket_water")
|
new_bucket = ItemStack("mcl_buckets:bucket_water")
|
||||||
end
|
end
|
||||||
sound_take("mcl_core:water_source", pointed_thing.under)
|
sound_take("mcl_core:water_source", pointed_thing.under)
|
||||||
elseif nn == "mcl_cauldrons:cauldron_3r" then
|
elseif nn == "mcl_cauldrons:cauldron_3r" then
|
||||||
-- Take river water out of full cauldron
|
-- Take river water out of full cauldron
|
||||||
set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"})
|
set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"})
|
||||||
if not minetest.is_creative_enabled(user:get_player_name()) then
|
if not is_creative_enabled(user:get_player_name()) then
|
||||||
new_bucket = ItemStack("mcl_buckets:bucket_river_water")
|
new_bucket = ItemStack("mcl_buckets:bucket_river_water")
|
||||||
end
|
end
|
||||||
sound_take("mclx_core:river_water_source", pointed_thing.under)
|
sound_take("mclx_core:river_water_source", pointed_thing.under)
|
||||||
|
|
Loading…
Reference in New Issue