Add "for_spikes" mod.
This commit is contained in:
21
mods/buildings/fort_spikes/LICENSE
Normal file
21
mods/buildings/fort_spikes/LICENSE
Normal file
@@ -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.
|
12
mods/buildings/fort_spikes/README.md
Normal file
12
mods/buildings/fort_spikes/README.md
Normal file
@@ -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
|
1
mods/buildings/fort_spikes/depends.txt
Normal file
1
mods/buildings/fort_spikes/depends.txt
Normal file
@@ -0,0 +1 @@
|
||||
default
|
1
mods/buildings/fort_spikes/description.txt
Normal file
1
mods/buildings/fort_spikes/description.txt
Normal file
@@ -0,0 +1 @@
|
||||
Improve your base defense with wood and iron spikes around.
|
170
mods/buildings/fort_spikes/fort_spikes.lua
Normal file
170
mods/buildings/fort_spikes/fort_spikes.lua
Normal file
@@ -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,
|
||||
}
|
||||
)
|
3
mods/buildings/fort_spikes/init.lua
Normal file
3
mods/buildings/fort_spikes/init.lua
Normal file
@@ -0,0 +1,3 @@
|
||||
-- init file for fort_spikes
|
||||
local modpath = minetest.get_modpath("fort_spikes");
|
||||
dofile(modpath.."/fort_spikes.lua")
|
BIN
mods/buildings/fort_spikes/screenshot.png
Normal file
BIN
mods/buildings/fort_spikes/screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 55 KiB |
Binary file not shown.
After Width: | Height: | Size: 691 B |
Binary file not shown.
After Width: | Height: | Size: 706 B |
BIN
mods/buildings/fort_spikes/textures/fort_spikes_iron_spikes.png
Normal file
BIN
mods/buildings/fort_spikes/textures/fort_spikes_iron_spikes.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 897 B |
BIN
mods/buildings/fort_spikes/textures/fort_spikes_wood_spikes.png
Normal file
BIN
mods/buildings/fort_spikes/textures/fort_spikes_wood_spikes.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 966 B |
Reference in New Issue
Block a user