2021-04-13 23:33:34 +03:00
|
|
|
local S = minetest.get_translator("mcl_fireworks")
|
|
|
|
|
2021-04-17 20:34:23 +03:00
|
|
|
local player_rocketing = {}
|
2021-04-14 03:07:28 +03:00
|
|
|
|
2021-04-17 20:34:23 +03:00
|
|
|
local tt_help = S("Flight Duration:")
|
2021-04-13 23:33:34 +03:00
|
|
|
local description = S("Firework Rocket")
|
|
|
|
|
2021-04-17 20:34:23 +03:00
|
|
|
local function register_rocket(n, duration, force)
|
|
|
|
minetest.register_craftitem("mcl_fireworks:rocket_" .. n, {
|
|
|
|
description = description,
|
|
|
|
_tt_help = tt_help .. " " .. duration,
|
|
|
|
inventory_image = "mcl_fireworks_rocket.png",
|
|
|
|
stack_max = 64,
|
|
|
|
on_use = function(itemstack, user, pointed_thing)
|
|
|
|
local elytra = mcl_playerplus.elytra[user]
|
|
|
|
if elytra.active and elytra.rocketing <= 0 then
|
|
|
|
elytra.rocketing = duration
|
|
|
|
itemstack:take_item()
|
|
|
|
minetest.sound_play("mcl_fireworks_rocket", {pos = user:get_pos()})
|
|
|
|
end
|
|
|
|
return itemstack
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
end
|
2021-04-13 23:33:34 +03:00
|
|
|
|
2021-04-17 20:34:23 +03:00
|
|
|
register_rocket(1, 2.2, 10)
|
|
|
|
register_rocket(2, 4.5, 20)
|
|
|
|
register_rocket(3, 6, 30)
|