Update init.lua
This commit is contained in:
parent
8b0900ac82
commit
1a42bcd1e0
1 changed files with 45 additions and 25 deletions
|
@ -17,6 +17,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
|
local plcooldown = {}
|
||||||
|
local COOLDOWN = 5
|
||||||
|
|
||||||
|
minetest.register_on_joinplayer(function(player)
|
||||||
|
plcooldown[player:get_player_name()] = 0
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_on_leaveplayer(function(player)
|
||||||
|
plcooldown[player:get_player_name()] = nil
|
||||||
|
end)
|
||||||
|
|
||||||
minetest.register_craftitem("shooter_rocket:rocket", {
|
minetest.register_craftitem("shooter_rocket:rocket", {
|
||||||
description = "Rocket",
|
description = "Rocket",
|
||||||
stack_max = 1,
|
stack_max = 1,
|
||||||
|
@ -70,6 +81,9 @@ minetest.register_tool("shooter_rocket:rocket_gun_loaded", {
|
||||||
inventory_image = "shooter_rocket_gun_loaded.png",
|
inventory_image = "shooter_rocket_gun_loaded.png",
|
||||||
groups = {not_in_creative_inventory=1},
|
groups = {not_in_creative_inventory=1},
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
|
if plcooldown[user:get_player_name()] ~= 0 then
|
||||||
|
minetest.chat_send_player(user:get_player_name(), "Your rocket has a cooldown!")
|
||||||
|
else
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
itemstack:add_wear(65535 / 50)
|
itemstack:add_wear(65535 / 50)
|
||||||
end
|
end
|
||||||
|
@ -98,6 +112,13 @@ minetest.register_tool("shooter_rocket:rocket_gun_loaded", {
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
plcooldown[user:get_player_name()] = COOLDOWN
|
||||||
|
minetest.after(COOLDOWN, function(user)
|
||||||
|
if plcooldown[user:get_player_name()] then
|
||||||
|
plcooldown[user:get_player_name()] = 0
|
||||||
|
end
|
||||||
|
end, user)
|
||||||
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
@ -159,4 +180,3 @@ end)
|
||||||
minetest.register_alias("shooter:rocket", "shooter_rocket:rocket")
|
minetest.register_alias("shooter:rocket", "shooter_rocket:rocket")
|
||||||
minetest.register_alias("shooter:rocket_gun", "shooter_rocket:rocket_gun")
|
minetest.register_alias("shooter:rocket_gun", "shooter_rocket:rocket_gun")
|
||||||
minetest.register_alias("shooter:rocket_gun_loaded", "shooter_rocket:rocket_gun_loaded")
|
minetest.register_alias("shooter:rocket_gun_loaded", "shooter_rocket:rocket_gun_loaded")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue