Commit a32a3543 authored by DonBatman's avatar DonBatman
Browse files

first commit

parents
This diff is collapsed.
=-=-=-=-=-=-=-=-=-=
Castles Mod
by: Philipbenr And DanDuncombe
=-=-=-=-=-=-=-=-=-=
Licence: GPLv3
see: LICENSE
=-=-=-=-=-=-=-=-=-=
This is a mod all about creating castles and castle dungeons. Many of the nodes are used for the outer-walls or dungeons.
=-=-=-=-=-=-=-=-=-=
Contains as of now:
--Walls, Corner-walls,
--Castlestone Stairs, Slabs, and Pillars
--Jailbars
--Hides
--Arrowslits
--Rubble (for between walls)
--Doors
--and more!
=-=-=-=-=-=-=-=-=-=
" Although crossbows have been removed, along with arrows, the code is still there.
To get the crossbows back, look in init.lua. You will see at the top some lines
with dofile in them. Copy and paste two more of these lines, and change them to
crossbow.lua and arrow.lua to get them back. "
I, (philipbenr) will take a look at the arrows and crossbows, and see about this.
minetest.register_craftitem("castle:arrow", {
description = "Arrow",
inventory_image = "castle_arrow.png",
})
minetest.register_node("castle:arrow_box", {
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
-- Shaft
{-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17},
--Spitze
{-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17},
{-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17},
--Federn
{6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17},
{7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17},
{7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17},
{6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17},
{7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17},
{8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17},
{8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17},
{7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17},
}
},
tiles = {"castle_arrow.png", "castle_arrow.png", "castle_arrow_back.png", "castle_arrow_front.png", "castle_arrow_2.png", "castle_arrow.png"},
groups = {not_in_creative_inventory=1},
})
local castle_ARROW_ENTITY={
physical = false,
timer=0,
visual = "wielditem",
visual_size = {x=0.1, y=0.1},
textures = {"castle:arrow_box"},
lastpos={},
collisionbox = {0,0,0,0,0,0},
}
castle_ARROW_ENTITY.on_step = function(self, dtime)
self.timer=self.timer+dtime
local pos = self.object:getpos()
local node = minetest.get_node(pos)
if self.timer>0.2 then
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2)
for k, obj in pairs(objs) do
if obj:get_luaentity() ~= nil then
if obj:get_luaentity().name ~= "castle:arrow_entity" and obj:get_luaentity().name ~= "__builtin:item" then
local damage = 3
obj:punch(self.object, 1.0, {
full_punch_interval=1.0,
groupcaps={
fleshy={times={[1]=1/(damage-2), [2]=1/(damage-1), [3]=1/damage}},
snappy={times={[1]=1/(damage-2), [2]=1/(damage-1), [3]=1/damage}},
}
}, nil)
self.object:remove()
end
else
local damage = 3
obj:punch(self.object, 1.0, {
full_punch_interval=1.0,
groupcaps={
fleshy={times={[1]=1/(damage-2), [2]=1/(damage-1), [3]=1/damage}},
snappy={times={[1]=1/(damage-2), [2]=1/(damage-1), [3]=1/damage}},
}
}, nil)
self.object:remove()
end
end
end
if self.lastpos.x~=nil then
if node.name ~= "air" then
minetest.add_item(self.lastpos, 'castle:arrow')
self.object:remove()
end
end
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
end
minetest.register_entity("castle:arrow_entity", castle_ARROW_ENTITY)
minetest.register_craft({
output = 'castle:arrow 16',
recipe = {
{'default:stick', 'default:stick', 'default:steel_ingot'},
}
})
minetest.register_alias("castle:arrowslit", "castle:arrowslit_stonewall")
minetest.register_alias("castle:arrowslit_hole", "castle:arrowslit_stonewall_hole")
minetest.register_alias("castle:arrowslit", "castle:arrowslit_stonewall_cross")
local arrowslit = {}
arrowslit.types = {
{"stonewall", "Stonewall", "castle_stonewall", "castle:stonewall"},
{"cobble", "Cobble", "default_cobble", "default:cobble"},
{"stonebrick", "Stonebrick", "default_stone_brick", "default:stonebrick"},
{"sandstonebrick", "Sandstone Brick", "default_sandstone_brick", "default:sandstonebrick"},
{"desertstonebrick", "Desert Stone Brick", "default_desert_stone_brick", "default:desert_stonebrick"},
{"stone", "Stone", "default_stone", "default:stone"},
{"sandstone", "Sandstone", "default_sandstone", "default:sandstone"},
{"desertstone", "Desert Stone", "default_desert_stone", "default:desert_stone"},
}
for _, row in ipairs(arrowslit.types) do
local name = row[1]
local desc = row[2]
local tile = row[3]
local craft_material = row[4]
-- Node Definition
minetest.register_node("castle:arrowslit_"..name, {
drawtype = "nodebox",
description = desc.." Arrowslit",
tiles = {tile..".png"},
groups = {cracky=3},
sounds = default.node_sound_defaults(),
paramtype = "light",
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = {
{-0.500000,-0.375000,-0.500000,-0.062500,0.375000,-0.312500},
{0.062500,-0.375000,-0.500000,0.500000,0.375000,-0.312500},
{-0.500000,0.375000,-0.500000,0.500000,0.500000,-0.312500},
{-0.500000,-0.500000,-0.500000,0.500000,-0.375000,-0.312500},
},
},
selection_box = {
type = "fixed",
fixed = {
{-0.500000,-0.500000,-0.500000,0.500000,0.500000,-0.312500},
},
},
})
minetest.register_node("castle:arrowslit_"..name.."_cross", {
drawtype = "nodebox",
description = desc.." Arrowslit with Cross",
tiles = {tile..".png"},
groups = {cracky=3},
sounds = default.node_sound_defaults(),
paramtype = "light",
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = {
{-0.500000,-0.125000,-0.500000,-0.062500,0.375000,-0.312500},
{0.062500,-0.125000,-0.500000,0.500000,0.375000,-0.312500},
{-0.500000,0.375000,-0.500000,0.500000,0.500000,-0.312500},
{-0.500000,-0.500000,-0.500000,0.500000,-0.375000,-0.312500},
{0.062500,-0.375000,-0.500000,0.500000,-0.250000,-0.312500},
{-0.500000,-0.375000,-0.500000,-0.062500,-0.250000,-0.312500},
{-0.500000,-0.250000,-0.500000,-0.187500,-0.125000,-0.312500},
{0.187500,-0.250000,-0.500000,0.500000,-0.125000,-0.312500},
},
},
selection_box = {
type = "fixed",
fixed = {
{-0.500000,-0.500000,-0.500000,0.500000,0.500000,-0.312500},
},
},
})
minetest.register_node("castle:arrowslit_"..name.."_hole", {
drawtype = "nodebox",
description = desc.." Arrowslit with Hole",
tiles = {tile..".png"},
groups = {cracky=3},
sounds = default.node_sound_defaults(),
paramtype = "light",
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = {
{-0.500000,-0.375000,-0.500000,-0.125000,0.375000,-0.312500},
{0.125000,-0.375000,-0.500000,0.500000,0.375000,-0.312500},
{-0.500000,-0.500000,-0.500000,0.500000,-0.375000,-0.312500},
{0.062500,-0.125000,-0.500000,0.125000,0.375000,-0.312500},
{-0.125000,-0.125000,-0.500000,-0.062500,0.375000,-0.312500},
{-0.500000,0.375000,-0.500000,0.500000,0.500000,-0.312500},
},
},
selection_box = {
type = "fixed",
fixed = {
{-0.500000,-0.500000,-0.500000,0.500000,0.500000,-0.312500},
},
},
})
if craft_material then
--Choose craft material
minetest.register_craft({
output = "castle:arrowslit_"..name.." 6",
recipe = {
{craft_material,"", craft_material},
{craft_material,"", craft_material},
{craft_material,"", craft_material} },
})
end
if craft_material then
minetest.register_craft({
output = "castle:arrowslit_"..name.."_cross",
recipe = {
{"castle:arrowslit_"..name} },
})
end
if craft_material then
minetest.register_craft({
output = "castle:arrowslit_"..name.."_hole",
recipe = {
{"castle:arrowslit_"..name.."_cross"} },
})
end
if craft_material then
minetest.register_craft({
output = "castle:arrowslit_"..name,
recipe = {
{"castle:arrowslit_"..name.."_hole"} },
})
end
end
arrows = {
{"castle:arrow", "castle:arrow_entity"},
}
local castle_shoot_arrow = function(itemstack, player)
for _,arrow in ipairs(arrows) do
if player:get_inventory():get_stack("main", player:get_wield_index()+1):get_name() == arrow[1] then
if not minetest.setting_getbool("creative_mode") then
player:get_inventory():remove_item("main", arrow[1])
end
local playerpos = player:getpos()
local obj = minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, arrow[2])
local dir = player:get_look_dir()
obj:setvelocity({x=dir.x*19, y=dir.y*19, z=dir.z*19})
obj:setacceleration({x=dir.x*-3, y=-10, z=dir.z*-3})
obj:setyaw(player:get_look_yaw()+math.pi)
minetest.sound_play("castle_sound", {pos=playerpos})
if obj:get_luaentity().player == "" then
obj:get_luaentity().player = player
end
obj:get_luaentity().node = player:get_inventory():get_stack("main", 1):get_name()
return true
end
end
return false
end
minetest.register_tool("castle:crossbow", {
description = "Crossbow",
inventory_image = "castle_crossbow.png",
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
if castle_shoot_arrow(item, user, pointed_thing) then
if not minetest.setting_getbool("creative_mode") then
itemstack:add_wear(65535/200)
end
end
return itemstack
end,
})
minetest.register_craft({
output = 'castle:crossbow',
recipe = {
{'default:steel_ingot', 'default:stick', 'default:steel_ingot'},
{'farming:string', 'farming:string', 'farming:string'},
{'', 'default:stick', ''},
}
})
default
stairs
doors
farming
building_blocks?
asphalt?
streets?
moreblocks?
dofile(minetest.get_modpath("castle").."/pillars.lua")
dofile(minetest.get_modpath("castle").."/arrowslit.lua")
dofile(minetest.get_modpath("castle").."/tapestry.lua")
dofile(minetest.get_modpath("castle").."/jailbars.lua")
dofile(minetest.get_modpath("castle").."/town_item.lua")
dofile(minetest.get_modpath("castle").."/shields_decor.lua")
dofile(minetest.get_modpath("castle").."/murder_hole.lua")
--dofile(minetest.get_modpath("castle").."/orbs.lua")
dofile(minetest.get_modpath("castle").."/rope.lua")
minetest.register_node("castle:stonewall", {
description = "Castle Wall",
drawtype = "normal",
tiles = {"castle_stonewall.png"},
paramtype = light,
drop = "castle:stonewall",
groups = {cracky=3},
})
minetest.register_node("castle:rubble", {
description = "Castle Rubble",
drawtype = "normal",
tiles = {"castle_rubble.png"},
paramtype = light,
groups = {crumbly=3,falling_node=1},
})
minetest.register_craft({
output = "castle:stonewall",
recipe = {
{"default:cobble"},
{"default:desert_stone"},
}
})
minetest.register_craft({
output = "castle:rubble",
recipe = {
{"castle:stonewall"},
}
})
minetest.register_craft({
output = "castle:rubble 2",
recipe = {
{"default:gravel"},
{"default:desert_stone"},
}
})
minetest.register_node("castle:stonewall_corner", {
drawtype = "normal",
paramtype = light,
paramtype2 = "facedir",
description = "Castle Corner",
tiles = {"castle_stonewall.png",
"castle_stonewall.png",
"castle_corner_stonewall1.png",
"castle_stonewall.png",
"castle_stonewall.png",
"castle_corner_stonewall2.png"},
groups = {cracky=3},
})
minetest.register_craft({
output = "castle:stonewall_corner",
recipe = {
{"", "castle:stonewall"},
{"castle:stonewall", "default:sandstone"},
}
})
minetest.register_node("castle:roofslate", {
drawtype = "raillike",
description = "Roof Slates",
inventory_image = "castle_slate.png",
paramtype = "light",
walkable = false,
tiles = {'castle_slate.png'},
climbable = true,
selection_box = {
type = "fixed",
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
},
groups = {cracky=3,attached_node=1},
})
minetest.register_node("castle:hides", {
drawtype = "signlike",
description = "Hides",
inventory_image = "castle_hide.png",
paramtype = "light",
walkable = false,
tiles = {'castle_hide.png'},
climbable = true,
paramtype2 = "wallmounted",
legacy_wallmounted = true,
groups = {dig_immediate=2},
selection_box = {
type = "wallmounted",
},
})
minetest.register_craft({
output = "castle:hides",
recipe = {
{"wool:white"},
{"bucket:bucket_water"},
}
})
minetest.register_craft( {
type = "shapeless",
output = "castle:hides 6",
recipe = { "wool:white" , "bucket:bucket_water" },
replacements = {
{ 'bucket:bucket_water', 'bucket:bucket_empty' }
}
} )
local mod_building_blocks = minetest.get_modpath("building_blocks")
local mod_streets = minetest.get_modpath("streets") or minetest.get_modpath("asphalt")
if mod_building_blocks then
minetest.register_craft( {
output = "castle:roofslate 4",
recipe = {
{ "building_blocks:Tar" , "default:gravel" },
{ "default:gravel", "building_blocks:Tar" }
}
})
minetest.register_craft( {
output = "castle:roofslate 4",
recipe = {
{ "default:gravel", "building_blocks:Tar" },
{ "building_blocks:Tar" , "default:gravel" }
}
})
end
if mod_streets then
minetest.register_craft( {
output = "castle:roofslate 4",
recipe = {
{ "streets:asphalt" , "default:gravel" },
{ "default:gravel", "streets:asphalt" }
}
})
minetest.register_craft( {
output = "castle:roofslate 4",
recipe = {
{ "default:gravel", "streets:asphalt" },
{ "streets:asphalt" , "default:gravel" }
}
})
end
if not (mod_building_blocks or mod_streets) then
minetest.register_craft({
type = "cooking",
output = "castle:roofslate",
recipe = "default:gravel",
})
end
stairs.register_stair_and_slab("stonewall", "castle:stonewall",
{cracky=3},
{"castle_stonewall.png"},
"Castle Wall Stair",
"Castle Wall Slab",
default.node_sound_stone_defaults())
minetest.register_craft({
output = "castle:stairs 4",
recipe = {
{"castle:stonewall","",""},
{"castle:stonewall","castle:stonewall",""},
{"castle:stonewall","castle:stonewall","castle:stonewall"},
}
})
minetest.register_craft({
output = "stairs:stair_stonewall 4",
recipe = {
{"","","castle:stonewall"},
{"","castle:stonewall","castle:stonewall"},
{"castle:stonewall","castle:stonewall","castle:stonewall"},
}
})
minetest.register_craft({
output = "stairs:slab_stonewall 6",
recipe = {
{"castle:stonewall","castle:stonewall","castle:stonewall"},
}
})
doors.register_door("castle:oak_door", {
description = "Oak Door",
inventory_image = "castle_oak_door_inv.png",
groups = {choppy=2,door=1},
tiles_bottom = {"castle_oak_door_bottom.png", "door_oak.png"},
tiles_top = {"castle_oak_door_top.png", "door_oak.png"},
only_placer_can_open = true,
})
doors.register_door("castle:jail_door", {
description = "Jail Door",
inventory_image = "castle_jail_door_inv.png",
groups = {cracky=2,door=1},
tiles_bottom = {"castle_jail_door_bottom.png", "door_jail.png"},
tiles_top = {"castle_jail_door_top.png", "door_jail.png"},
only_placer_can_open = true,
})
minetest.register_craft({
output = "castle:oak_door",
recipe = {
{"default:tree", "default:tree"},
{"default:tree", "default:tree"},
{"default:tree", "default:tree"}
}
})
minetest.register_craft({
output = "castle:jail_door",
recipe = {
{"castle:jailbars", "castle:jailbars"},
{"castle:jailbars", "castle:jailbars"},
{"castle:jailbars", "castle:jailbars"}
}
})
function default.get_ironbound_chest_formspec(pos)
local spos = pos.x .. "," .. pos.y .. "," ..pos.z
local formspec =
"size[8,9]"..
"list[nodemeta:".. spos .. ";main;0,0;8,4;]"..
"list[current_player;main;0,5;8,4;]"
return formspec
end
local function has_ironbound_chest_privilege(meta, player)
if player:get_player_name() ~= meta:get_string("owner") then
return false
end
return true
end
minetest.register_node("castle:ironbound_chest",{
drawtype = "nodebox",
description = "Ironbound Chest",
tiles = {"castle_ironbound_chest_top.png",
"castle_ironbound_chest_top.png",
"castle_ironbound_chest_side.png",
"castle_ironbound_chest_side.png",
"castle_ironbound_chest_back.png",
"castle_ironbound_chest_front.png"},
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky=2},
node_box = {
type = "fixed",
fixed = {
{-0.500000,-0.500000,-0.312500,0.500000,-0.062500,0.312500},
{-0.500000,-0.062500,-0.250000,0.500000,0.000000,0.250000},
{-0.500000,0.000000,-0.187500,0.500000,0.062500,0.187500},
{-0.500000,0.062500,-0.062500,0.500000,0.125000,0.062500},
},
},
selection_box = {
type = "fixed",
fixed = {
{-0.5,-0.500000,-0.400000,0.5,0.200000,0.4},
},
},
sounds = default.node_sound_wood_defaults(),
after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos)