-
Notifications
You must be signed in to change notification settings - Fork 9
/
rocket.lua
56 lines (47 loc) · 1.37 KB
/
rocket.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
local S = deltaglider.translator
local rocket_cooldown = deltaglider.rocket_cooldown
minetest.register_craftitem("deltaglider:rocket", {
description = S("Rocket (Use while gliding to boost delta glider speed.)"),
inventory_image = "deltaglider_rocket.png",
on_use = function(itemstack, player)
local attach = player:get_attach()
if not attach then
return itemstack
end
local luaent = attach:get_luaentity()
if luaent.name ~= "deltaglider:hangglider" then
return itemstack
end
-- Avoid rocket overuse.
if rocket_cooldown > luaent.time_from_last_rocket then
return itemstack
end
luaent.speed = luaent.speed + luaent.time_from_last_rocket
luaent.time_from_last_rocket = 0
-- Add some fancy particles
minetest.add_particlespawner({
amount = 200,
time = 2,
minpos = { x = -0.05, y = -0.05, z = -0.05 },
maxpos = { x = 0.05, y = 0.05, z = 0.05 },
minexptime = 1,
maxexptime = 2,
attached = attach,
texture = "deltaglider_rocket_particle.png",
})
-- Use a rocket
itemstack:take_item()
return itemstack
end
})
local gunpowder = minetest.get_modpath("mcl_mobitems")
and "mcl_mobitems:gunpowder"
or "tnt:gunpowder"
minetest.register_craft({
output = "deltaglider:rocket 33",
recipe = {
{ "group:wood", gunpowder, "group:wood" },
{ "group:wood", gunpowder, "group:wood" },
{ "group:wood", gunpowder, "group:wood" },
}
})