mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-12-24 01:30:38 +01:00
remove random pickaxe or stick and add digged node and throwing:arrow_dig
fix crash if not player in function throwing_shoot_arrow() "LuaEntity name "" not defined" and "functions.lua:34: attempt to index a nil value" fix crash, "self.*" not defined after self.object:remove() "dig_arrow.lua:67: attempt to index field 'player' (a nil value)"
This commit is contained in:
parent
6ddba5a15e
commit
3f288ae184
@ -55,12 +55,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
damage_groups={fleshy=damage},
|
||||
}, nil)
|
||||
self.object:remove()
|
||||
local toughness = 0.9
|
||||
if math.random() < toughness then
|
||||
minetest.add_item(self.lastpos, 'throwing:arrow_dig')
|
||||
else
|
||||
minetest.add_item(self.lastpos, 'default:stick')
|
||||
end
|
||||
minetest.add_item(self.lastpos, "throwing:arrow_dig")
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -68,18 +63,15 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
|
||||
if self.lastpos.x~=nil then
|
||||
if node.name ~= "air" then
|
||||
self.object:remove()
|
||||
|
||||
if minetest.get_item_group(node.name, "unbreakable") == 0
|
||||
and areas:canInteract(self.lastpos, self.player:get_player_name())
|
||||
and node.diggable ~= false then
|
||||
minetest.set_node(pos, {name = "air"})
|
||||
end
|
||||
local toughness = 0.65
|
||||
if math.random() < toughness then
|
||||
minetest.add_item(self.lastpos, 'default:pick_steel')
|
||||
else
|
||||
minetest.add_item(self.lastpos, 'default:stick')
|
||||
end
|
||||
minetest.add_item(self.lastpos, node.name)
|
||||
minetest.add_item(self.lastpos, "throwing:arrow_dig")
|
||||
self.object:remove()
|
||||
end
|
||||
end
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
|
@ -17,11 +17,13 @@ minetest.register_on_leaveplayer(function(player)
|
||||
end)
|
||||
|
||||
function throwing_shoot_arrow (itemstack, player, stiffness, is_cross)
|
||||
if not player then return end
|
||||
local arrow = itemstack:get_metadata()
|
||||
itemstack:set_metadata("")
|
||||
player:set_wielded_item(itemstack)
|
||||
local playerpos = player:getpos()
|
||||
local obj = minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, arrow)
|
||||
if not obj then return end
|
||||
local dir = player:get_look_dir()
|
||||
obj:setvelocity({x=dir.x*stiffness, y=dir.y*stiffness, z=dir.z*stiffness})
|
||||
obj:setacceleration({x=dir.x*-3, y=-10, z=dir.z*-3})
|
||||
@ -44,6 +46,7 @@ function throwing_unload (itemstack, player, unloaded, wear)
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
player:get_inventory():add_item("main", arrow[1])
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user