diff --git a/README.md b/README.md index 4860d414..72a8202b 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,12 @@ The game includes the mods from the default [minetest_game](https://github.com/m The following mods are also included: * [awards][] ([LGPL](mods/awards/LICENSE.txt)) -* building/ +* buildings/ * building_blocks ([homedecor_modpack][homedecor]) ([LGPL/WTFPL/CC-BY-SA](doc/modpacks/homedecor/LICENSE)) * chains ([homedecor_modpack][homedecor]) * computer ([homedecor_modpack][homedecor]) * fake_fire ([homedecor_modpack][homedecor]) + * [fort_spikes][] ([MIT/CC0](mods/buildings/fort_spikes/LICENSE)) * homedecor([homedecor_modpack][homedecor]) * homedecor_3d_extras ([homedecor_modpack][homedecor]) * inbox ([homedecor_modpack][homedecor]) @@ -58,6 +59,7 @@ The following mods are also included: [character_creator]: https://forum.minetest.net/viewtopic.php?f=9&t=13138 [craftguide]: https://forum.minetest.net/viewtopic.php?f=11&t=14088 [farming_plus]: https://forum.minetest.net/viewtopic.php?t=2787 +[fort_spikes]: https://forum.minetest.net/viewtopic.php?t=14574 [homedecor]: https://forum.minetest.net/viewtopic.php?t=2041 [mesecons]: https://forum.minetest.net/viewtopic.php?t=628 [moreblocks]: https://forum.minetest.net/viewtopic.php?t=509 diff --git a/mods/buildings/fort_spikes/LICENSE b/mods/buildings/fort_spikes/LICENSE new file mode 100644 index 00000000..e3f99cfd --- /dev/null +++ b/mods/buildings/fort_spikes/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Artūras Norkus + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/mods/buildings/fort_spikes/README.md b/mods/buildings/fort_spikes/README.md new file mode 100644 index 00000000..640e739f --- /dev/null +++ b/mods/buildings/fort_spikes/README.md @@ -0,0 +1,12 @@ +# Fort Spikes +Mod for Minetest game + +Improve your base defense with wood and iron spikes around. + +License of source code: +----------------------- +MIT + +Media +----------------------- +Texture files are created by xeranas and lisensed under CC-0 diff --git a/mods/buildings/fort_spikes/depends.txt b/mods/buildings/fort_spikes/depends.txt new file mode 100644 index 00000000..4ad96d51 --- /dev/null +++ b/mods/buildings/fort_spikes/depends.txt @@ -0,0 +1 @@ +default diff --git a/mods/buildings/fort_spikes/description.txt b/mods/buildings/fort_spikes/description.txt new file mode 100644 index 00000000..d853cc39 --- /dev/null +++ b/mods/buildings/fort_spikes/description.txt @@ -0,0 +1 @@ +Improve your base defense with wood and iron spikes around. \ No newline at end of file diff --git a/mods/buildings/fort_spikes/fort_spikes.lua b/mods/buildings/fort_spikes/fort_spikes.lua new file mode 100644 index 00000000..0fbacd9e --- /dev/null +++ b/mods/buildings/fort_spikes/fort_spikes.lua @@ -0,0 +1,170 @@ +fort_spikes = { + wood_durability_index = 0.4, + iron_durability_index = 0.9 +} + +-- add damage to any object. +fort_spikes.do_damage = function(obj, durability_index) + if obj == nil then return end + + if obj:is_player() or (obj:get_luaentity() ~= nil and obj:get_luaentity().name ~= "__builtin:item") then + obj:punch(obj, 1.0, {full_punch_interval = 1.0, damage_groups = {fleshy=5}}, nil) + if durability_index ~= nil and fort_spikes.is_broken(durability_index) then + return 1 + end + end + return 0 +end + +-- check nodes below/above to forbid construct spikes in two vertical rows. +fort_spikes.is_allowed_position = function(pos) + local node = minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z}) + if minetest.get_node_group(node.name, "spikes") > 0 then + return false + end + node = minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z}) + if minetest.get_node_group(node.name, "spikes") > 0 then + return false + end + return true +end + +-- ramdomly decide if spike is broken. +fort_spikes.is_broken = function(durability_index) + if (durability_index < math.random()) then + return true + end + return false +end + +minetest.register_node("fort_spikes:wood_spikes", { + description = "Wood spikes", + drawtype = "plantlike", + visual_scale = 1, + tile_images = {"fort_spikes_wood_spikes.png"}, + inventory_image = ("fort_spikes_wood_spikes.png"), + paramtype = "light", + walkable = false, + drop = "default:stick 3", + sunlight_propagates = true, + groups = {spikes=1, flammable=2, choppy = 2, oddly_breakable_by_hand = 1}, + on_punch = function(pos, node, puncher, pointed_thing) + fort_spikes.do_damage(puncher, nil) + end, + on_construct = function(pos) + if fort_spikes.is_allowed_position(pos) == false then + minetest.dig_node(pos) + end + end, +}) + +minetest.register_node("fort_spikes:broken_wood_spikes", { + description = "Broken wood spikes", + drawtype = "plantlike", + visual_scale = 1, + tile_images = {"fort_spikes_broken_wood_spikes.png"}, + inventory_image = ("fort_spikes_broken_wood_spikes.png"), + paramtype = "light", + walkable = false, + sunlight_propagates = true, + drop = "default:stick 3", + groups = {spikes=1, flammable=2, choppy = 2, oddly_breakable_by_hand = 1}, +}) + +minetest.register_craft({ + output = 'fort_spikes:wood_spikes 3', + recipe = { + {'default:stick', '', 'default:stick'}, + {'', 'default:stick', ''}, + {'default:stick', '', 'default:stick'}, + }, + on_place = function(itemstack, placer, pointed_thing, param2) + if (fort_spikes.is_spikes_below(pointed_thing)) then + return + end + end, +}) + +minetest.register_node("fort_spikes:iron_spikes", { + description = "Iron spikes", + drawtype = "plantlike", + visual_scale = 1, + tile_images = {"fort_spikes_iron_spikes.png"}, + inventory_image = ("fort_spikes_iron_spikes.png"), + paramtype = "light", + walkable = false, + sunlight_propagates = true, + drop = "default:steel_ingot 2", + groups = {cracky=2, spikes=1}, + on_punch = function(pos, node, puncher, pointed_thing) + fort_spikes.do_damage(puncher, nil) + end, + on_construct = function(pos) + if fort_spikes.is_allowed_position(pos) == false then + minetest.dig_node(pos) + end + end, +}) + +minetest.register_node("fort_spikes:broken_iron_spikes", { + description = "Broken spikes", + drawtype = "plantlike", + visual_scale = 1, + tile_images = {"fort_spikes_broken_iron_spikes.png"}, + inventory_image = ("fort_spikes_broken_iron_spikes.png"), + paramtype = "light", + walkable = false, + sunlight_propagates = true, + drop = "default:steel_ingot 2", + groups = {cracky=2, spikes=1}, +}) + +minetest.register_craft({ + output = 'fort_spikes:iron_spikes 3', + recipe = { + {'default:steel_ingot', '', 'default:steel_ingot'}, + {'', 'default:steel_ingot', ''}, + {'default:steel_ingot', '', 'default:steel_ingot'}, + }, + on_place = function(itemstack, placer, pointed_thing, param2) + if (fort_spikes.is_spikes_below(pointed_thing)) then + return + end + end, +}) + +minetest.register_abm( + {nodenames = {"fort_spikes:wood_spikes"}, + interval = 1.0, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + local times_broken = 0 + local objs = minetest.get_objects_inside_radius(pos, 1) + for k, obj in pairs(objs) do + times_broken = times_broken + fort_spikes.do_damage(obj, fort_spikes.wood_durability_index) + end + if times_broken > 0 then + minetest.remove_node(pos) + minetest.place_node(pos, {name="fort_spikes:broken_wood_spikes"}) + end + end, + } +) + +minetest.register_abm( + {nodenames = {"fort_spikes:iron_spikes"}, + interval = 1.0, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + local times_broken = 0 + local objs = minetest.get_objects_inside_radius(pos, 1) + for k, obj in pairs(objs) do + times_broken = times_broken + fort_spikes.do_damage(obj, fort_spikes.iron_durability_index) + end + if times_broken > 0 then + minetest.remove_node(pos) + minetest.place_node(pos, {name="fort_spikes:broken_iron_spikes"}) + end + end, + } +) diff --git a/mods/buildings/fort_spikes/init.lua b/mods/buildings/fort_spikes/init.lua new file mode 100644 index 00000000..3b70a522 --- /dev/null +++ b/mods/buildings/fort_spikes/init.lua @@ -0,0 +1,3 @@ +-- init file for fort_spikes +local modpath = minetest.get_modpath("fort_spikes"); +dofile(modpath.."/fort_spikes.lua") \ No newline at end of file diff --git a/mods/buildings/fort_spikes/screenshot.png b/mods/buildings/fort_spikes/screenshot.png new file mode 100644 index 00000000..040b9676 Binary files /dev/null and b/mods/buildings/fort_spikes/screenshot.png differ diff --git a/mods/buildings/fort_spikes/textures/fort_spikes_broken_iron_spikes.png b/mods/buildings/fort_spikes/textures/fort_spikes_broken_iron_spikes.png new file mode 100644 index 00000000..d135cd46 Binary files /dev/null and b/mods/buildings/fort_spikes/textures/fort_spikes_broken_iron_spikes.png differ diff --git a/mods/buildings/fort_spikes/textures/fort_spikes_broken_wood_spikes.png b/mods/buildings/fort_spikes/textures/fort_spikes_broken_wood_spikes.png new file mode 100644 index 00000000..7fdd2c8e Binary files /dev/null and b/mods/buildings/fort_spikes/textures/fort_spikes_broken_wood_spikes.png differ diff --git a/mods/buildings/fort_spikes/textures/fort_spikes_iron_spikes.png b/mods/buildings/fort_spikes/textures/fort_spikes_iron_spikes.png new file mode 100644 index 00000000..9c68f897 Binary files /dev/null and b/mods/buildings/fort_spikes/textures/fort_spikes_iron_spikes.png differ diff --git a/mods/buildings/fort_spikes/textures/fort_spikes_wood_spikes.png b/mods/buildings/fort_spikes/textures/fort_spikes_wood_spikes.png new file mode 100644 index 00000000..2ad0cdd4 Binary files /dev/null and b/mods/buildings/fort_spikes/textures/fort_spikes_wood_spikes.png differ