diff --git a/hoes.lua b/hoes.lua index ee683b5..9dc8d2f 100644 --- a/hoes.lua +++ b/hoes.lua @@ -110,7 +110,7 @@ function farming.hoe_on_use(itemstack, user, pointed_thing, uses) -- turn the node into soil, wear out item and play sound minetest.set_node(pt.under, {name = ndef.soil.dry}) - minetest.sound_play("default_dig_crumbly", {pos = pt.under, gain = 0.5}) + minetest.sound_play("default_dig_crumbly", {pos = pt.under, gain = 0.5}, true) local wdef = itemstack:get_definition() local wear = 65535 / (uses - 1) @@ -130,8 +130,7 @@ function farming.hoe_on_use(itemstack, user, pointed_thing, uses) end if itemstack:get_count() == 0 and wdef.sound and wdef.sound.breaks then - minetest.sound_play(wdef.sound.breaks, {pos = pt.above, - gain = 0.5}, true) + minetest.sound_play(wdef.sound.breaks, {pos = pt.above, gain = 0.5}, true) end return itemstack @@ -252,11 +251,15 @@ end -- throwable hoe bomb minetest.register_entity("farming:hoebomb_entity", { - physical = true, - visual = "sprite", - visual_size = {x = 1.0, y = 1.0}, - textures = {"farming_hoe_bomb.png"}, - collisionbox = {-0.1,-0.1,-0.1,0.1,0.1,0.1}, + + initial_properties = { + physical = true, + visual = "sprite", + visual_size = {x = 1.0, y = 1.0}, + textures = {"farming_hoe_bomb.png"}, + collisionbox = {-0.1,-0.1,-0.1,0.1,0.1,0.1} + }, + lastpos = {}, player = "", @@ -273,7 +276,7 @@ minetest.register_entity("farming:hoebomb_entity", { if self.lastpos.x ~= nil then - local vel = self.object:getvelocity() + local vel = self.object:get_velocity() -- only when potion hits something physical if vel.x == 0 @@ -311,20 +314,14 @@ local function throw_potion(itemstack, player) z = playerpos.z }, "farming:hoebomb_entity") + if not obj then return end + local dir = player:get_look_dir() local velocity = 20 - obj:set_velocity({ - x = dir.x * velocity, - y = dir.y * velocity, - z = dir.z * velocity - }) + obj:set_velocity({x = dir.x * velocity, y = dir.y * velocity, z = dir.z * velocity}) - obj:set_acceleration({ - x = dir.x * -3, - y = -9.5, - z = dir.z * -3 - }) + obj:set_acceleration({x = dir.x * -3, y = -9.5, z = dir.z * -3}) obj:get_luaentity().player = player end @@ -386,18 +383,13 @@ minetest.register_tool("farming:scythe_mithril", { local def = minetest.registered_nodes[node.name] - if not def - or not def.drop - or not def.groups - or not def.groups.plant then + if not def or not def.drop or not def.groups or not def.groups.plant then return end local drops = minetest.get_node_drops(node.name, "") - if not drops - or #drops == 0 - or (#drops == 1 and drops[1] == "") then + if not drops or #drops == 0 or (#drops == 1 and drops[1] == "") then return end @@ -405,6 +397,7 @@ minetest.register_tool("farming:scythe_mithril", { local mname = node.name:split(":")[1] local pname = node.name:split(":")[2] local sname = tonumber(pname:split("_")[2]) + pname = pname:split("_")[1] if not sname then @@ -443,7 +436,7 @@ minetest.register_tool("farming:scythe_mithril", { end -- play sound - minetest.sound_play("default_grass_footstep", {pos = pos, gain = 1.0}) + minetest.sound_play("default_grass_footstep", {pos = pos, gain = 1.0}, true) local replace = mname .. ":" .. pname .. "_1" @@ -458,7 +451,7 @@ minetest.register_tool("farming:scythe_mithril", { if not farming.is_creative(name) then - itemstack:add_wear(65535 / 150) -- 150 uses + itemstack:add_wear(65535 / 350) -- 350 uses return itemstack end