mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-12-24 17:50:37 +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},
|
damage_groups={fleshy=damage},
|
||||||
}, nil)
|
}, nil)
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
local toughness = 0.9
|
minetest.add_item(self.lastpos, "throwing:arrow_dig")
|
||||||
if math.random() < toughness then
|
|
||||||
minetest.add_item(self.lastpos, 'throwing:arrow_dig')
|
|
||||||
else
|
|
||||||
minetest.add_item(self.lastpos, 'default:stick')
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -68,18 +63,15 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
|||||||
|
|
||||||
if self.lastpos.x~=nil then
|
if self.lastpos.x~=nil then
|
||||||
if node.name ~= "air" then
|
if node.name ~= "air" then
|
||||||
self.object:remove()
|
|
||||||
if minetest.get_item_group(node.name, "unbreakable") == 0
|
if minetest.get_item_group(node.name, "unbreakable") == 0
|
||||||
and areas:canInteract(self.lastpos, self.player:get_player_name())
|
and areas:canInteract(self.lastpos, self.player:get_player_name())
|
||||||
and node.diggable ~= false then
|
and node.diggable ~= false then
|
||||||
minetest.set_node(pos, {name = "air"})
|
minetest.set_node(pos, {name = "air"})
|
||||||
end
|
end
|
||||||
local toughness = 0.65
|
minetest.add_item(self.lastpos, node.name)
|
||||||
if math.random() < toughness then
|
minetest.add_item(self.lastpos, "throwing:arrow_dig")
|
||||||
minetest.add_item(self.lastpos, 'default:pick_steel')
|
self.object:remove()
|
||||||
else
|
|
||||||
minetest.add_item(self.lastpos, 'default:stick')
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||||
|
@ -17,11 +17,13 @@ minetest.register_on_leaveplayer(function(player)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
function throwing_shoot_arrow (itemstack, player, stiffness, is_cross)
|
function throwing_shoot_arrow (itemstack, player, stiffness, is_cross)
|
||||||
|
if not player then return end
|
||||||
local arrow = itemstack:get_metadata()
|
local arrow = itemstack:get_metadata()
|
||||||
itemstack:set_metadata("")
|
itemstack:set_metadata("")
|
||||||
player:set_wielded_item(itemstack)
|
player:set_wielded_item(itemstack)
|
||||||
local playerpos = player:getpos()
|
local playerpos = player:getpos()
|
||||||
local obj = minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, arrow)
|
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()
|
local dir = player:get_look_dir()
|
||||||
obj:setvelocity({x=dir.x*stiffness, y=dir.y*stiffness, z=dir.z*stiffness})
|
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})
|
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
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
player:get_inventory():add_item("main", arrow[1])
|
player:get_inventory():add_item("main", arrow[1])
|
||||||
end
|
end
|
||||||
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user