50 lines
1.0 KiB
Lua
50 lines
1.0 KiB
Lua
PyuTest.make_gun = function(name, desc, texture, cooldown, damage, extra)
|
|
local bullet_id = name .. "_bullet"
|
|
|
|
local cd = cooldown or 1
|
|
PyuTest.make_tool(name, desc, {
|
|
tool = 1,
|
|
gun = 1,
|
|
}, texture, {
|
|
stack_max = 1,
|
|
|
|
on_use = function(itemstack, user, pointed_thing)
|
|
PyuTest.shoot_projectile_from_object(bullet_id, user, 35)
|
|
core.sound_play("pyutest_shoot", {
|
|
pos = user:get_pos()
|
|
})
|
|
|
|
if extra ~= nil then
|
|
extra(itemstack, user, pointed_thing)
|
|
end
|
|
|
|
return itemstack
|
|
end,
|
|
})
|
|
|
|
PyuTest.make_projectile(bullet_id, {
|
|
visual_size = {x = 0.2, y = 0.2},
|
|
textures = {
|
|
"pyutest-bullet.png",
|
|
"pyutest-bullet.png",
|
|
"pyutest-bullet.png",
|
|
"pyutest-bullet.png",
|
|
"pyutest-bullet.png",
|
|
"pyutest-bullet.png",
|
|
}
|
|
}, {
|
|
}, {
|
|
on_hit_node = function(self, pos, node) end,
|
|
on_hit_object = function(self, object)
|
|
if self._owner == nil or not self._owner:is_valid() then
|
|
return
|
|
end
|
|
PyuTest.deal_damage(object, damage, {
|
|
type = "punch",
|
|
object = self._owner
|
|
})
|
|
end
|
|
})
|
|
end
|
|
|