MineClone2/mods/ITEMS/mcl_fireworks/register.lua

70 lines
2.3 KiB
Lua
Raw Normal View History

2021-04-13 22:33:34 +02:00
local S = minetest.get_translator("mcl_fireworks")
2021-04-14 02:07:28 +02:00
player_rocketing = {}
2021-04-13 22:33:34 +02:00
local help = S("Flight Duration:")
local description = S("Firework Rocket")
local rocket_sound = function()
minetest.sound_play("mcl_fireworks_rocket")
end
minetest.register_craftitem("mcl_fireworks:rocket_1", {
description = description,
_tt_help = help.." 1",
inventory_image = "mcl_fireworks_rocket.png",
stack_max = 64,
on_use = function(itemstack, user, pointed_thing)
2021-04-14 02:07:28 +02:00
local torso = user:get_inventory():get_stack("armor", 3)
if torso and torso:get_name() == "mcl_armor:elytra" and player_rocketing[user] ~= true then
player_rocketing[user] = true
minetest.after(2.2, function()
player_rocketing[user] = false
end)
itemstack:take_item()
--user:add_player_velocity(vector.multiply(user:get_look_dir(), 20))
rocket_sound()
end
return itemstack
2021-04-13 22:33:34 +02:00
end,
})
minetest.register_craftitem("mcl_fireworks:rocket_2", {
description = description,
_tt_help = help.." 2",
inventory_image = "mcl_fireworks_rocket.png",
stack_max = 64,
on_use = function(itemstack, user, pointed_thing)
2021-04-14 02:07:28 +02:00
local torso = user:get_inventory():get_stack("armor", 3)
if torso and torso:get_name() == "mcl_armor:elytra" and player_rocketing[user] ~= true then
player_rocketing[user] = true
minetest.after(4.5, function()
player_rocketing[user] = false
end)
itemstack:take_item()
--user:add_player_velocity(vector.multiply(user:get_look_dir(), 20))
rocket_sound()
end
return itemstack
2021-04-13 22:33:34 +02:00
end,
})
minetest.register_craftitem("mcl_fireworks:rocket_3", {
description = description,
_tt_help = help.." 3",
inventory_image = "mcl_fireworks_rocket.png",
stack_max = 64,
2021-04-14 02:07:28 +02:00
on_use = function(itemstack, user, pointed_thing)
local torso = user:get_inventory():get_stack("armor", 3)
if torso and torso:get_name() == "mcl_armor:elytra" and player_rocketing[user] ~= true then
player_rocketing[user] = true
minetest.after(6, function()
player_rocketing[user] = false
end)
itemstack:take_item()
--user:add_player_velocity(vector.multiply(user:get_look_dir(), 20))
rocket_sound()
end
return itemstack
2021-04-13 22:33:34 +02:00
end,
})