use newer 0.4.16 functions
This commit is contained in:
parent
1722432cd5
commit
87931a7d99
@ -15,3 +15,4 @@ Changelog:
|
|||||||
- 0.2 - Added error checking and a 10 second warning before becoming visible
|
- 0.2 - Added error checking and a 10 second warning before becoming visible
|
||||||
- 0.3 - Potions can now be stacked
|
- 0.3 - Potions can now be stacked
|
||||||
- 0.4 - Potion recipe changed now that Nyan Cat no longer in default game
|
- 0.4 - Potion recipe changed now that Nyan Cat no longer in default game
|
||||||
|
- 0.5 - Use newer functions, Minetest 0.4.16 and anove needed to run
|
||||||
|
19
init.lua
19
init.lua
@ -3,8 +3,8 @@ invisibility = {}
|
|||||||
|
|
||||||
local effect_time = 180 -- 3 minutes
|
local effect_time = 180 -- 3 minutes
|
||||||
|
|
||||||
-- reset player invisibility if they go offline
|
|
||||||
|
|
||||||
|
-- reset player invisibility if they go offline
|
||||||
minetest.register_on_leaveplayer(function(player)
|
minetest.register_on_leaveplayer(function(player)
|
||||||
|
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
@ -14,8 +14,15 @@ minetest.register_on_leaveplayer(function(player)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- invisibility potion
|
|
||||||
|
|
||||||
|
-- creative check
|
||||||
|
local creative_mode_cache = minetest.settings:get_bool("creative_mode")
|
||||||
|
function is_creative(name)
|
||||||
|
return creative_mode_cache or minetest.check_player_privs(name, {creative = true})
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- invisibility potion
|
||||||
minetest.register_node("invisibility:potion", {
|
minetest.register_node("invisibility:potion", {
|
||||||
description = "Invisibility Potion",
|
description = "Invisibility Potion",
|
||||||
drawtype = "plantlike",
|
drawtype = "plantlike",
|
||||||
@ -87,7 +94,7 @@ minetest.register_node("invisibility:potion", {
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
-- take potion, return empty bottle (and rest of potion stack)
|
-- take potion, return empty bottle (and rest of potion stack)
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
if not is_creative(user:get_player_name()) then
|
||||||
|
|
||||||
local item_count = user:get_wielded_item():get_count()
|
local item_count = user:get_wielded_item():get_count()
|
||||||
local inv = user:get_inventory()
|
local inv = user:get_inventory()
|
||||||
@ -114,8 +121,8 @@ minetest.register_node("invisibility:potion", {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- craft recipe
|
|
||||||
|
|
||||||
|
-- craft recipe
|
||||||
minetest.register_craft( {
|
minetest.register_craft( {
|
||||||
output = "invisibility:potion",
|
output = "invisibility:potion",
|
||||||
type = "shapeless",
|
type = "shapeless",
|
||||||
@ -129,8 +136,8 @@ minetest.register_craft( {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- invisibility function
|
|
||||||
|
|
||||||
|
-- invisibility function
|
||||||
invisible = function(player, toggle)
|
invisible = function(player, toggle)
|
||||||
|
|
||||||
if not player then return false end
|
if not player then return false end
|
||||||
@ -168,8 +175,8 @@ invisible = function(player, toggle)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- vanish command (admin only)
|
|
||||||
|
|
||||||
|
-- vanish command (admin only)
|
||||||
minetest.register_chatcommand("vanish", {
|
minetest.register_chatcommand("vanish", {
|
||||||
params = "<name>",
|
params = "<name>",
|
||||||
description = "Make player invisible",
|
description = "Make player invisible",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user