mirror of
https://gitlab.com/echoes91/spears.git
synced 2025-06-29 14:10:25 +02:00
alpha1
This commit is contained in:
18
tools.lua
18
tools.lua
@ -52,6 +52,18 @@ function spears_register_spear(kind, desc, eq, toughness, craft)
|
||||
textures = {"spears:spear_" .. kind},
|
||||
lastpos={},
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
on_punch = function(self, puncher)
|
||||
if puncher then
|
||||
if puncher:is_player() then
|
||||
local stack = {name='spears:spear_' .. kind, wear=self.wear+65535/toughness}
|
||||
local inv = puncher:get_inventory()
|
||||
if inv:room_for_item("main", stack) then
|
||||
inv:add_item("main", stack)
|
||||
self.object:remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
SPEAR_ENTITY.on_step = function(self, dtime)
|
||||
@ -69,13 +81,13 @@ function spears_register_spear(kind, desc, eq, toughness, craft)
|
||||
if obj:get_luaentity() ~= nil then
|
||||
if obj:get_luaentity().name ~= "spears:spear_" .. kind .. "_entity" and obj:get_luaentity().name ~= "__builtin:item" then
|
||||
local speed = vector.length(self.object:getvelocity())
|
||||
local damage = ((speed + eq)^1.2)/3
|
||||
local damage = (speed + eq)^1.12-20
|
||||
obj:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
damage_groups={fleshy=damage},
|
||||
}, nil)
|
||||
self.object:remove()
|
||||
minetest.add_item(self.lastpos, {name='spears:spear_' .. kind, count=1, wear=self.wear+65535/toughness, metadata=""})
|
||||
minetest.add_item(self.lastpos, {name='spears:spear_' .. kind, wear=self.wear+65535/toughness})
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -84,7 +96,7 @@ function spears_register_spear(kind, desc, eq, toughness, craft)
|
||||
if self.lastpos.x~=nil then
|
||||
if node.name ~= "air" and not (string.find(node.name, 'grass') and not string.find(node.name, 'dirt')) and not string.find(node.name, 'flowers:') and not string.find(node.name, 'farming:') then
|
||||
self.object:remove()
|
||||
minetest.add_item(self.lastpos, {name='spears:spear_' .. kind, count=1, wear=self.wear+65535/toughness, metadata=""})
|
||||
minetest.add_item(self.lastpos, {name='spears:spear_' .. kind, wear=self.wear+65535/toughness})
|
||||
end
|
||||
end
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
|
Reference in New Issue
Block a user