From a523aff8269f65b4f57f7756bde5a3398bf3b8c2 Mon Sep 17 00:00:00 2001 From: echoes91 Date: Wed, 28 Sep 2022 23:44:35 +0200 Subject: [PATCH] Update 2.3 --- CHANGELOG | 5 +++++ README | 2 +- defaults.lua | 1 + depends.txt | 1 - functions.lua | 12 ++++++------ init.lua | 5 +++-- mod.conf | 7 +++++++ spears.conf.example | 3 ++- tools.lua | 12 ++++++++---- 9 files changed, 33 insertions(+), 15 deletions(-) delete mode 100644 depends.txt create mode 100644 mod.conf diff --git a/CHANGELOG b/CHANGELOG index 4bc3040..ed3c853 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +Version 2.3: +- Updated to Minetest 5.6.0 API +- Changed receipts to avoid being confused with arrows +- Various cleansing and fixes + Version 2.2: - "Hit detection" based on spearhead position - Spears go through buildable_to nodes (snow) diff --git a/README b/README index 9c02ecf..a927120 100644 --- a/README +++ b/README @@ -19,7 +19,7 @@ Spears can be used to dig, but are slower and weaker and pickaxes. If you miss the target it's your fault, the spear is fine. You can grab a spear on the fly (or maybe wait until it falls?). You can stick a spear into a block, but if you remove the block then the spear falls (obviously). -This mod contains the word "spear" more than 100 times, if you want the exact number count them yourself. +This mod contains the word "spear" more than 100 times, if you want the exact number you can count them. If you feel clever, throw a spear right above you and look at it to see what happens. You can even throw a spear from above down to your foes, it's even easier to hit. Someone once reported to have hit its own foot but it takes practice to do that. diff --git a/defaults.lua b/defaults.lua index 62bf9bd..59e6bae 100644 --- a/defaults.lua +++ b/defaults.lua @@ -4,3 +4,4 @@ DISABLE_COPPER_SPEAR = false DISABLE_BRONZE_SPEAR = false DISABLE_DIAMOND_SPEAR = false DISABLE_OBSIDIAN_SPEAR = false +DISABLE_GOLD_SPEAR = false diff --git a/depends.txt b/depends.txt deleted file mode 100644 index 4ad96d5..0000000 --- a/depends.txt +++ /dev/null @@ -1 +0,0 @@ -default diff --git a/functions.lua b/functions.lua index 28be11b..1b9d33f 100644 --- a/functions.lua +++ b/functions.lua @@ -7,7 +7,7 @@ function spears_throw (itemstack, player, pointed_thing) local pitch = player:get_look_vertical() local yaw = player:get_look_horizontal() local rotation = vector.new(0, yaw + math.pi/2, pitch + math.pi/6) - -- Plant into node + -- Stick into node if pointed_thing.type == "node" then local node = minetest.get_node(pointed_thing.under) if minetest.registered_nodes[node.name].walkable and vector.distance(pointed_thing.above, throw_pos) < 1 then @@ -23,7 +23,7 @@ function spears_throw (itemstack, player, pointed_thing) while vector.distance(player_pos, throw_pos) < 1.2 do throw_pos = vector.add(throw_pos, vector.multiply(direction, 0.1)) end - local player_vel = player:get_player_velocity() + local player_vel = player:get_velocity() local spear_object = minetest.add_entity(throw_pos, spear) spear_object:set_velocity(vector.add(player_vel, vector.multiply(direction, throw_speed))) spear_object:set_rotation(rotation) @@ -63,6 +63,7 @@ function spears_set_entity(spear_type, base_damage, toughness) self.object:remove() return end + local pos = self.object:get_pos() local velocity = self.object:get_velocity() local speed = vector.length(velocity) -- Spear is stuck ? @@ -72,21 +73,20 @@ function spears_set_entity(spear_type, base_damage, toughness) if node_cracky and node_cracky < 3 then minetest.sound_play("default_metal_footstep", {pos = pos}, true) self.object:remove() - minetest.add_item(self.object:get_pos(), {name='spears:spear_' .. spear_type, wear = self._wear}) + minetest.add_item(pos, {name='spears:spear_' .. spear_type, wear = self._wear}) elseif not self._node_walkable then - minetest.sound_play("default_place_node", {pos = throw_pos}, true) + minetest.sound_play("default_place_node", {pos = pos}, true) end self._node_walkable = minetest.registered_nodes[node.name].walkable if not node or not self._node_walkable then -- Fall when node is removed self.object:remove() - minetest.add_item(self.object:get_pos(), {name='spears:spear_' .. spear_type, wear = self._wear}) + minetest.add_item(pos, {name='spears:spear_' .. spear_type, wear = self._wear}) return end else -- Spear is flying local direction = vector.normalize(velocity) local yaw = minetest.dir_to_yaw(direction) local pitch = math.acos(velocity.y/speed) - math.pi/3 - local pos = self.object:get_pos() local spearhead_pos = vector.add(pos, vector.multiply(direction, 0.5)) local node = minetest.get_node(spearhead_pos) self.object:set_rotation({x = 0, y = yaw + math.pi/2, z = pitch}) diff --git a/init.lua b/init.lua index 3a45772..eca9a05 100644 --- a/init.lua +++ b/init.lua @@ -11,7 +11,8 @@ dofile(minetest.get_modpath("spears").."/functions.lua") dofile(minetest.get_modpath("spears").."/tools.lua") +local log_mods = minetest.settings:get_bool("log_mods") -if minetest.setting_get("log_mods") then - minetest.log("action", "spears loaded") +if minetest.settings:get_bool("log_mods") then + minetest.log("action", "[MOD] Spears loaded") end diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..4923e2a --- /dev/null +++ b/mod.conf @@ -0,0 +1,7 @@ +name = spears +depends = default +description = Add spears to Minetest, versatile weapons that can be thrown +release = 2.3 +author = Echoes91 +title = Spears + diff --git a/spears.conf.example b/spears.conf.example index 241ce08..a9bed2d 100644 --- a/spears.conf.example +++ b/spears.conf.example @@ -3,4 +3,5 @@ DISABLE_STEEL_SPEAR = true DISABLE_COPPER_SPEAR = true DISABLE_BRONZE_SPEAR = true DISABLE_DIAMOND_SPEAR = true -DISABLE_OBSIDIAN_SPEAR = true \ No newline at end of file +DISABLE_OBSIDIAN_SPEAR = true +DISABLE_GOLD_SPEAR = true diff --git a/tools.lua b/tools.lua index 49b5af4..6cd33a7 100644 --- a/tools.lua +++ b/tools.lua @@ -7,14 +7,14 @@ function spears_register_spear(spear_type, desc, base_damage, toughness, materia wield_scale= {x = 1.5, y = 1.5, z = 1.5}, on_secondary_use = function(itemstack, user, pointed_thing) spears_throw(itemstack, user, pointed_thing) - if not minetest.setting_getbool("creative_mode") then + if not minetest.settings:get_bool("creative_mode") then itemstack:take_item() end return itemstack end, on_place = function(itemstack, user, pointed_thing) spears_throw(itemstack, user, pointed_thing) - if not minetest.setting_getbool("creative_mode") then + if not minetest.settings:get_bool("creative_mode") then itemstack:take_item() end return itemstack @@ -38,14 +38,18 @@ function spears_register_spear(spear_type, desc, base_damage, toughness, materia minetest.register_craft({ output = 'spears:spear_' .. spear_type, recipe = { - {'group:stick', 'group:stick', material}, + {"", "", material}, + {"", "group:stick", ""}, + {"group:stick", "", ""} } }) minetest.register_craft({ output = 'spears:spear_' .. spear_type, recipe = { - {material, 'group:stick', 'group:stick'}, + {material, "", ""}, + {"", "group:stick", ""}, + {"", "", "group:stick"} } }) end