forked from MineClone5/MineClone5
Improve rocket
This commit is contained in:
parent
8d22102c66
commit
5b93ee5e40
|
@ -1,5 +1,7 @@
|
||||||
local S = minetest.get_translator("mcl_fireworks")
|
local S = minetest.get_translator("mcl_fireworks")
|
||||||
|
|
||||||
|
player_rocketing = {}
|
||||||
|
|
||||||
local help = S("Flight Duration:")
|
local help = S("Flight Duration:")
|
||||||
local description = S("Firework Rocket")
|
local description = S("Firework Rocket")
|
||||||
local rocket_sound = function()
|
local rocket_sound = function()
|
||||||
|
@ -12,13 +14,17 @@ minetest.register_craftitem("mcl_fireworks:rocket_1", {
|
||||||
inventory_image = "mcl_fireworks_rocket.png",
|
inventory_image = "mcl_fireworks_rocket.png",
|
||||||
stack_max = 64,
|
stack_max = 64,
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
itemstack:take_item()
|
local torso = user:get_inventory():get_stack("armor", 3)
|
||||||
local torso = user:get_inventory():get_stack("armor", 3)
|
if torso and torso:get_name() == "mcl_armor:elytra" and player_rocketing[user] ~= true then
|
||||||
if torso and torso:get_name() == "mcl_armor:elytra" then
|
player_rocketing[user] = true
|
||||||
user:add_player_velocity(vector.multiply(user:get_look_dir(), 20))
|
minetest.after(2.2, function()
|
||||||
rocket_sound()
|
player_rocketing[user] = false
|
||||||
end
|
end)
|
||||||
return itemstack
|
itemstack:take_item()
|
||||||
|
--user:add_player_velocity(vector.multiply(user:get_look_dir(), 20))
|
||||||
|
rocket_sound()
|
||||||
|
end
|
||||||
|
return itemstack
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -28,13 +34,17 @@ minetest.register_craftitem("mcl_fireworks:rocket_2", {
|
||||||
inventory_image = "mcl_fireworks_rocket.png",
|
inventory_image = "mcl_fireworks_rocket.png",
|
||||||
stack_max = 64,
|
stack_max = 64,
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
itemstack:take_item()
|
local torso = user:get_inventory():get_stack("armor", 3)
|
||||||
local torso = user:get_inventory():get_stack("armor", 3)
|
if torso and torso:get_name() == "mcl_armor:elytra" and player_rocketing[user] ~= true then
|
||||||
if torso and torso:get_name() == "mcl_armor:elytra" then
|
player_rocketing[user] = true
|
||||||
user:add_player_velocity(vector.multiply(user:get_look_dir(), 30))
|
minetest.after(4.5, function()
|
||||||
rocket_sound()
|
player_rocketing[user] = false
|
||||||
end
|
end)
|
||||||
return itemstack
|
itemstack:take_item()
|
||||||
|
--user:add_player_velocity(vector.multiply(user:get_look_dir(), 20))
|
||||||
|
rocket_sound()
|
||||||
|
end
|
||||||
|
return itemstack
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -43,13 +53,17 @@ minetest.register_craftitem("mcl_fireworks:rocket_3", {
|
||||||
_tt_help = help.." 3",
|
_tt_help = help.." 3",
|
||||||
inventory_image = "mcl_fireworks_rocket.png",
|
inventory_image = "mcl_fireworks_rocket.png",
|
||||||
stack_max = 64,
|
stack_max = 64,
|
||||||
on_use = function(itemstack, user, pointed_thing, player)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
itemstack:take_item()
|
local torso = user:get_inventory():get_stack("armor", 3)
|
||||||
local torso = user:get_inventory():get_stack("armor", 3)
|
if torso and torso:get_name() == "mcl_armor:elytra" and player_rocketing[user] ~= true then
|
||||||
if torso and torso:get_name() == "mcl_armor:elytra" then
|
player_rocketing[user] = true
|
||||||
user:add_player_velocity(vector.multiply(user:get_look_dir(), 40))
|
minetest.after(6, function()
|
||||||
rocket_sound()
|
player_rocketing[user] = false
|
||||||
end
|
end)
|
||||||
return itemstack
|
itemstack:take_item()
|
||||||
|
--user:add_player_velocity(vector.multiply(user:get_look_dir(), 20))
|
||||||
|
rocket_sound()
|
||||||
|
end
|
||||||
|
return itemstack
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
local S = minetest.get_translator("mcl_playerplus")
|
local S = minetest.get_translator("mcl_playerplus")
|
||||||
|
|
||||||
local elytra = {}
|
elytra = {}
|
||||||
|
|
||||||
local node_stand_return = ":air"
|
local node_stand_return = ":air"
|
||||||
local get_connected_players = minetest.get_connected_players
|
local get_connected_players = minetest.get_connected_players
|
||||||
|
@ -200,6 +200,16 @@ minetest.register_globalstep(function(dtime)
|
||||||
minetest.log("action", "somehow player got of loaded areas")
|
minetest.log("action", "somehow player got of loaded areas")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local chestplate = player:get_inventory():get_stack("armor", 3)
|
||||||
|
|
||||||
|
if player_rocketing[player] and player_rocketing[player] == true and chestplate:get_name() == "mcl_armor:elytra" then
|
||||||
|
if math.abs(player_velocity.x) + math.abs(player_velocity.y) + math.abs(player_velocity.z) < 40 then
|
||||||
|
player:add_player_velocity(vector.multiply(player:get_look_dir(), 4))
|
||||||
|
elytra[player] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
controls.register_on_press(function(player, key)
|
controls.register_on_press(function(player, key)
|
||||||
if key~="jump" and key~="RMB" then return end
|
if key~="jump" and key~="RMB" then return end
|
||||||
if key=="jump" then
|
if key=="jump" then
|
||||||
|
@ -214,8 +224,6 @@ minetest.register_globalstep(function(dtime)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local chestplate = player:get_inventory():get_stack("armor", 3)
|
|
||||||
|
|
||||||
if elytra[player] == true and node_stand_return ~= "air" or elytra[player] == true and player:get_inventory():get_stack("armor", 3):get_name() ~= "mcl_armor:elytra" or player:get_attach() ~= nil then
|
if elytra[player] == true and node_stand_return ~= "air" or elytra[player] == true and player:get_inventory():get_stack("armor", 3):get_name() ~= "mcl_armor:elytra" or player:get_attach() ~= nil then
|
||||||
elytra[player] = false
|
elytra[player] = false
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue