diff --git a/api.lua b/api.lua index 0b75471..8a8177b 100644 --- a/api.lua +++ b/api.lua @@ -276,17 +276,19 @@ function projectile.shoot(wep, user, level) --Look through each inventory slot... for i = 1, inv:get_size("main") do - --get the stack itself + --Get the stack itself local ammo = inv:get_stack("main", i) + --Get the name of the entity that will be created by this ammo type. + local ammo_entity = projectile.registered_projectiles[def.rw_category][ammo:get_name()] --If there is an item stack, and it's registered as an ammo type that this weapon can use... - if not ammo:is_empty() and projectile.registered_projectiles[def.rw_category][ammo:get_name()] then - local adef = minetest.registered_entities[ammo:get_name()] + if not ammo:is_empty() and ammo_entity then + local adef = minetest.registered_entities[ammo_entity] --Fire an amount of projectiles at once according to the ammo's defined "count". for n = 1, (adef.count or 1) do --Create the projectile entity at the determined position - local projectile = minetest.add_entity(pos, projectile.registered_projectiles[def.rw_category][ammo:get_name()]) + local projectile = minetest.add_entity(pos, ammo_entity) --A shorthand of the luaentity version of the projectile, where data can easily be stored local luapro = projectile:get_luaentity() diff --git a/bugs.txt b/bugs.txt deleted file mode 100644 index bbba5c4..0000000 --- a/bugs.txt +++ /dev/null @@ -1 +0,0 @@ -projectile isn't unloaded when player leaves diff --git a/changelog.txt b/changelog.txt index 630b9c4..8c56764 100644 --- a/changelog.txt +++ b/changelog.txt @@ -23,3 +23,20 @@ v1.1.0: v1.1.1: Added optional support for my new node_damage mod. With it an tnt, bomb arrows will crack blocks just outside the destruction radius. + +v1.1.2: + New: + +Waterworks support: waterworks pipes can be used as gun barrels in craft recipes + +screenshot.png + + Made optional dependencies more optional: + +Craftable rocks are available if hardtrees isn't present + +Craftable steel pipes if both pipeworks and waterworks aren't present. + *Flintlock recipes now use steel strips and flint in place of mesecon wall levers. + + Removed: + -Optional dependency on mesecons_walllever + -bugs.txt + + Fixes: + -Slingshots crashing the game when used diff --git a/crafts.lua b/crafts.lua index 326ad9e..3b138b8 100644 --- a/crafts.lua +++ b/crafts.lua @@ -17,6 +17,22 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA --]] +--Gun components +if not (pipeworks or waterworks) then + minetest.register_craftitem("projectile:steel_pipe", { + description = "Steel Pipe", + inventory_image = "projectile_steel_pipe.png" + }) +end + +--Basic slingshot ammo +if not hardtrees then + minetest.register_craftitem("projectile:rock", { + description = "Rock", + inventory_image = "projectile_rock.png" + }) +end + --A basic arrow minetest.register_craftitem("projectile:arrow", { description = "Arrow", @@ -79,23 +95,43 @@ minetest.register_craftitem("projectile:shot_pile_mithril", { ---Two cobblestone blocks can shapelessly be used to craft 18 rocks. ---Two are used since it's very possible that other mods use one rock to make other things. -minetest.register_craft({ - type = "shapeless", - output = "hardtrees:rock 18", - recipe = {"default:cobble", "default:cobble"} -}) +if hardtrees then + --Two cobblestone blocks can shapelessly be used to craft 18 rocks. + --Two are used since it's very possible that other mods use one rock to make other things. + minetest.register_craft({ + type = "shapeless", + output = "hardtrees:rock 18", + recipe = {"default:cobble", "default:cobble"} + }) ---If the player no longer needs rocks, 9 can be crafted back into a cobblestone block. -minetest.register_craft({ - output = "default:cobble", - recipe = { - {"hardtrees:rock", "hardtrees:rock", "hardtrees:rock"}, - {"hardtrees:rock", "hardtrees:rock", "hardtrees:rock"}, - {"hardtrees:rock", "hardtrees:rock", "hardtrees:rock"} - } -}) + --If the player no longer needs rocks, 9 can be crafted back into a cobblestone block. + minetest.register_craft({ + output = "default:cobble", + recipe = { + {"hardtrees:rock", "hardtrees:rock", "hardtrees:rock"}, + {"hardtrees:rock", "hardtrees:rock", "hardtrees:rock"}, + {"hardtrees:rock", "hardtrees:rock", "hardtrees:rock"} + } + }) +else + --Two cobblestone blocks can shapelessly be used to craft 18 rocks. + --Two are used since it's very possible that other mods use one rock to make other things. + minetest.register_craft({ + type = "shapeless", + output = "projectile:rock 18", + recipe = {"default:cobble", "default:cobble"} + }) + + --If the player no longer needs rocks, 9 can be crafted back into a cobblestone block. + minetest.register_craft({ + output = "default:cobble", + recipe = { + {"projectile:rock", "projectile:rock", "projectile:rock"}, + {"projectile:rock", "projectile:rock", "projectile:rock"}, + {"projectile:rock", "projectile:rock", "projectile:rock"} + } + }) +end --Four sticks in a diagonal Y, with a string on top, makes a slingshot. minetest.register_craft({ @@ -139,33 +175,89 @@ minetest.register_craft({ } }) ---Flintlocks are made from metal and steel, with a pipe segment for the barrel and a lever for the trigger. -minetest.register_craft({ - output = "projectile:flintlock_pistol", - recipe = { - {"pipeworks:pipe_1_empty", ""}, - {"mesecons_walllever:wall_lever_off", "default:steel_ingot"}, - {"group:stick", ""} - } -}) +if pipeworks then + --Flintlocks are made from metal and steel, with a steel pipe for the barrel and a lever for the trigger. + minetest.register_craft({ + output = "projectile:flintlock_pistol", + recipe = { + {"pipeworks:pipe_1_empty", ""}, + {"basic_materials:steel_strip", "default:steel_ingot"}, + {"group:stick", "default:flint"} + } + }) ---Muskets add an extra barrel because they're long. -minetest.register_craft({ - output = "projectile:musket", - recipe = { - {"pipeworks:pipe_1_empty", "", ""}, - {"", "pipeworks:pipe_1_empty", "default:steel_ingot"}, - {"", "mesecons_walllever:wall_lever_off", "group:stick"} - } -}) + --Muskets add an extra pipe because they're long. + minetest.register_craft({ + output = "projectile:musket", + recipe = { + {"pipeworks:pipe_1_empty", "", ""}, + {"", "pipeworks:pipe_1_empty", "default:steel_ingot"}, + {"basic_materials:steel_strip", "group:stick", "default:flint"} + } + }) +end ---Blunderbusses are thucker, so a second steel ingot is used in place of a pipe segment. +if waterworks then + --Flintlocks are made from metal and steel, with a steel pipe for the barrel and a lever for the trigger. + minetest.register_craft({ + output = "projectile:flintlock_pistol", + recipe = { + {"waterworks:pipe", ""}, + {"basic_materials:steel_strip", "default:steel_ingot"}, + {"group:stick", "default:flint"} + } + }) + + --Muskets add an extra pipe because they're long. + minetest.register_craft({ + output = "projectile:musket", + recipe = { + {"waterworks:pipe", "", ""}, + {"", "waterworks:pipe", "default:steel_ingot"}, + {"basic_materials:steel_strip", "group:stick", "default:flint"} + } + }) +end + +if not (pipeworks or waterworks) then + --6 steel ingots in an = shape can make any kind of pipe. + minetest.register_craft({ + output = "projectile:steel_pipe 12", + recipe = { + {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"}, + {"", "", ""}, + {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"} + } + }) + + --Flintlocks are made from metal and steel, with a steel pipe for the barrel and a lever for the trigger. + minetest.register_craft({ + output = "projectile:flintlock_pistol", + recipe = { + {"projectile:steel_pipe", ""}, + {"basic_materials:steel_strip", "default:steel_ingot"}, + {"group:stick", "default:flint"} + } + }) + + --Muskets add an extra pipe because they're long. + minetest.register_craft({ + output = "projectile:musket", + recipe = { + {"projectile:steel_pipe", "", ""}, + {"", "projectile:steel_pipe", "default:steel_ingot"}, + {"basic_materials:steel_strip", "group:stick", "default:flint"} + } + }) +end + +--Blunderbusses are thucker, so a second steel ingot is used in place of a steel pipe. minetest.register_craft({ output = "projectile:blunderbuss", recipe = { {"default:steel_ingot", ""}, - {"mesecons_walllever:wall_lever_off", "default:steel_ingot"}, - {"group:stick", ""} + {"basic_materials:steel_strip", "default:steel_ingot"}, + {"group:stick", "default:flint"} } }) diff --git a/init.lua b/init.lua index b8cf4b9..b382710 100644 --- a/init.lua +++ b/init.lua @@ -224,12 +224,20 @@ projectile.register_weapon("projectile:blunderbuss", { ---The basic slingshot projectile: rocks from hardtrees -projectile.register_projectile("projectile:rock", "slingshot", "hardtrees:rock", { - image = "rock_lump.png", - damage = 5, - speed = 15 -}) +--The basic slingshot projectile: rocks, optionally the ones from hardtrees +if hardtrees then + projectile.register_projectile("projectile:rock", "slingshot", "hardtrees:rock", { + image = "rock_lump.png", + damage = 5, + speed = 15 + }) +else + projectile.register_projectile("projectile:rock", "slingshot", "projectile:rock", { + image = "projectile_rock.png", + damage = 5, + speed = 15 + }) +end --A helper function for mese projectiles, to check if a particular node can be powered. local is_mesecon = function(pos) diff --git a/mod.conf b/mod.conf index b39ac07..f33e0fd 100644 --- a/mod.conf +++ b/mod.conf @@ -1,3 +1,3 @@ name = projectile description = Adds a small slingshot that can launch certain small objects as projectiles, such as rocks. -optional_depends = animalmaterials, creatures, default, farming, fire, hardtrees, mesecons_walllever, mesecons, mobs, moreores, node_damage, parties, pipeworks, tnt +optional_depends = animalmaterials, creatures, default, farming, fire, hardtrees, mesecons, mobs, moreores, node_damage, parties, pipeworks, tnt, waterworks diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..13a289d Binary files /dev/null and b/screenshot.png differ diff --git a/textures/projectile_rock.png b/textures/projectile_rock.png new file mode 100644 index 0000000..808d229 Binary files /dev/null and b/textures/projectile_rock.png differ diff --git a/textures/projectile_steel_pipe.png b/textures/projectile_steel_pipe.png new file mode 100644 index 0000000..4730bef Binary files /dev/null and b/textures/projectile_steel_pipe.png differ