-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjumptools.lua
62 lines (55 loc) · 1.7 KB
/
jumptools.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
56
57
58
59
60
61
62
local thismod = minetest.get_current_modname()
minetest.register_entity(thismod .. ":jumptool", {
on_activate = function(self, data)
self.item = data
local obj = self.object
obj:set_velocity({x = 0, y = 8, z = 0})
obj:set_acceleration({x = 0, y = -8, z = 0})
obj:set_yaw(math.random() * math.pi * 2)
obj:set_properties({
hp_max = 1,
physical = false,
collide_with_objects = false,
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
visual = "wielditem",
visual_size = {x = 0.5, y = 0.5},
textures = {data},
spritediv = {x = 1, y = 1},
initial_sprite_basepos = {x = 0, y = 0},
is_visible = true,
static_save = false,
automatic_rotate = (math.random() - 0.5) * 10,
glow = -1
})
end,
on_step = function(self, dtime)
if self.wac_tick then self:wac_tick(dtime) end
local vel = self.object:get_velocity()
if vel.y > 0 then return end
local pos = self.object:get_pos()
if self.jumpcorn then pos.y = pos.y + 0.5 end
local node = minetest.get_node(pos)
local def = minetest.registered_nodes[node.name]
if def and not def.walkable then return end
return self.object:remove()
end,
on_punch = function(self, puncher)
if not puncher or not puncher.is_player
or not puncher:is_player() then return end
if self.item then
local inv = puncher:get_inventory()
for i = 1, inv:get_size("main") do
if inv:get_stack("main", i):get_name() == self.item then return end
end
inv:add_item("main", self.item)
end
return self.object:remove()
end
})
minetest.register_abm({
label = "Spawn flying tools",
nodenames = {"wac:resigned_grass"},
interval = 1,
chance = 2000,
action = wac.jumpspawner("jumptool", function(_, v) return v.wac_tool_rarity end)
})