Commit a32a3543 authored by DonBatman's avatar DonBatman

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?
This diff is collapsed.
-- xjailbarss mod by xyz
local function rshift(x, by)
return math.floor(x / 2 ^ by)
end
local directions = {
{x = 1, y = 0, z = 0},
{x = 0, y = 0, z = 1},
{x = -1, y = 0, z = 0},
{x = 0, y = 0, z = -1},
}
local function update_jailbars(pos)
if minetest.get_node(pos).name:find("castle:jailbars") == nil then
return
end
local sum = 0
for i = 1, 4 do
local node = minetest.get_node({x = pos.x + directions[i].x, y = pos.y + directions[i].y, z = pos.z + directions[i].z})
if minetest.registered_nodes[node.name].walkable ~= false then
sum = sum + 2 ^ (i - 1)
end
end
if sum == 0 then
sum = 15
end
minetest.add_node(pos, {name = "castle:jailbars_"..sum})
end
local function update_nearby(pos)
for i = 1,4 do
update_jailbars({x = pos.x + directions[i].x, y = pos.y + directions[i].y, z = pos.z + directions[i].z})
end
end
local half_blocks = {
{0, -0.5, -0.06, 0.5, 0.5, 0.06},
{-0.06, -0.5, 0, 0.06, 0.5, 0.5},
{-0.5, -0.5, -0.06, 0, 0.5, 0.06},
{-0.06, -0.5, -0.5, 0.06, 0.5, 0}
}
local full_blocks = {
{-0.5, -0.5, -0.06, 0.5, 0.5, 0.06},
{-0.06, -0.5, -0.5, 0.06, 0.5, 0.5}
}
for i = 1, 15 do
local need = {}
local cnt = 0
for j = 1, 4 do
if rshift(i, j - 1) % 2 == 1 then
need[j] = true
cnt = cnt + 1
end
end
local take = {}
if need[1] == true and need[3] == true then
need[1] = nil
need[3] = nil
table.insert(take, full_blocks[1])
end
if need[2] == true and need[4] == true then
need[2] = nil
need[4] = nil
table.insert(take, full_blocks[2])
end
for k in pairs(need) do
table.insert(take, half_blocks[k])
end
local texture = "castle_jailbars.png"
if cnt == 1 then
texture = "castle_jailbars.png"
end
minetest.register_node("castle:jailbars_"..i, {
drawtype = "nodebox",
tiles = {"castle_grey.png", "castle_grey.png", texture},
paramtype = "light",
groups = {cracky=2},
drop = "castle:jailbars",
node_box = {
type = "fixed",
fixed = take
},
selection_box = {
type = "fixed",
fixed = take
}
})
end
minetest.register_node("castle:jailbars", {
description = "Jailbars",
tiles = {"castle_space.png"},
inventory_image = "castle_jailbars.png",
wield_image = "castle_jailbars.png",
node_placement_prediction = "",
on_construct = update_jailbars
})
minetest.register_on_placenode(update_nearby)
minetest.register_on_dignode(update_nearby)
minetest.register_craft({
output = "castle:jailbars 12",
recipe = {
{"default:steel_ingot","","default:steel_ingot"},
{"default:steel_ingot","default:steel_ingot","default:steel_ingot"},
{"default:steel_ingot","","default:steel_ingot"},
}
})
local hole = {}
hole.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(hole.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:hole_"..name, {
drawtype = "nodebox",
description = desc.." Murder Hole",
tiles = {tile..".png"},
groups = {cracky=3},
sounds = default.node_sound_defaults(),
paramtype = "light",
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = {
{-8/16,-8/16,-8/16,-4/16,8/16,8/16},
{4/16,-8/16,-8/16,8/16,8/16,8/16},
{-4/16,-8/16,-8/16,4/16,8/16,-4/16},
{-4/16,-8/16,8/16,4/16,8/16,4/16},
},
},
})
if craft_material then
--Choose craft material
minetest.register_craft({
output = "castle:hole_"..name.." 4",
recipe = {
{"",craft_material, "" },
{craft_material,"", craft_material},
{"",craft_material, ""} },
})
end
end
minetest.register_craftitem("castle:orb_day", {
description = "Orb of Midday",
tiles = {"castle_day.png"},
inventory_image = "castle_day.png",
wield_image = "castle_day.png",
groups = {not_in_creative_inventory=1},
on_use = function()
minetest.set_timeofday(0.5)
end,
})
minetest.register_craftitem("castle:orb_night", {
description = "Orb of Midnight",
tiles = {"castle_night.png"},
inventory_image = "castle_night.png",
wield_image = "castle_night.png",
groups = {not_in_creative_inventory=1},
on_use = function()
minetest.set_timeofday(0)
end,
})
minetest.register_craft( {
output = "castle:orb_day",
recipe = {
{"", "default:glass",""},
{"default:glass", "default:mese_crystal","default:glass"},
{"", "default:glass",""}
},
})
minetest.register_craft({
output = "castle:orb_night",
recipe = {
{"", "default:glass",""},
{"default:glass", "default:obsidian","default:glass"},
{"", "default:glass",""}
}
})
minetest.register_alias("castle:pillars_bottom", "castle:pillars_stonewall_bottom")
minetest.register_alias("castle:pillars_top", "castle:pillars_stonewall_top")
minetest.register_alias("castle:pillars_middle", "castle:pillars_stonewall_middle")
local pillar = {}
pillar.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(pillar.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:pillars_"..name.."_bottom", {
drawtype = "nodebox",
description = desc.." Pillar Base",
tiles = {tile..".png"},
groups = {cracky=3,attached_node=1},
sounds = default.node_sound_defaults(),
paramtype = "light",
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = {
{-0.500000,-0.500000,-0.500000,0.500000,-0.375000,0.500000},
{-0.375000,-0.375000,-0.375000,0.375000,-0.125000,0.375000},
{-0.250000,-0.125000,-0.250000,0.250000,0.500000,0.250000},
},
},
})
minetest.register_node("castle:pillars_"..name.."_top", {
drawtype = "nodebox",
description = desc.." Pillar Top",
tiles = {tile..".png"},
groups = {cracky=3,attached_node=1},
sounds = default.node_sound_defaults(),
paramtype = "light",
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = {
{-0.500000,0.312500,-0.500000,0.500000,0.500000,0.500000},
{-0.375000,0.062500,-0.375000,0.375000,0.312500,0.375000},
{-0.250000,-0.500000,-0.250000,0.250000,0.062500,0.250000},
},
},
})
minetest.register_node("castle:pillars_"..name.."_middle", {
drawtype = "nodebox",
description = desc.." Pillar Middle",
tiles = {tile..".png"},
groups = {cracky=3,attached_node=1},
sounds = default.node_sound_defaults(),
paramtype = "light",
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = {
{-0.250000,-0.500000,-0.250000,0.250000,0.500000,0.250000},
},
},
})
if craft_material then
--Choose craft material
minetest.register_craft({
output = "castle:pillars_"..name.."_bottom 4",
recipe = {
{"",craft_material,""},
{"",craft_material,""},
{craft_material,craft_material,craft_material} },
})
end
if craft_material then
--Choose craft material
minetest.register_craft({
output = "castle:pillars_"..name.."_top 4",
recipe = {
{craft_material,craft_material,craft_material},
{"",craft_material,""},
{"",craft_material,""} },
})
end
if craft_material then
--Choose craft material
minetest.register_craft({
output = "castle:pillars_"..name.."_middle 4",
recipe = {
{craft_material,craft_material},
{craft_material,craft_material},
{craft_material,craft_material} },
})
end
end
minetest.register_node("castle:ropes",{
description = "Rope",
drawtype = "nodebox",
sunlight_propagates = true,
tiles = {"castle_ropes.png"},
groups = {choppy=3,snappy=3,oddly_breakable_by_hand=3,flammable=1},
paramtype = "light",
climbable = true,
walkable = false,
node_box = {
type = "fixed",
fixed = {
{-1/16, -8/16, -1/16, 1/16, 8/16, 1/16},
},
},
selection_box = {
type = "fixed",
fixed = {
{-1/16, -8/16, -1/16, 1/16, 8/16, 1/16},
},
},
})
minetest.register_craft({
output = "castle:ropes",
recipe = {
{"farming:string"},
{"farming:string"},
{"farming:string"},
}
})
minetest.register_node("castle:box_rope", {
description = "Rope from Ropebox",
drawtype = "nodebox",
paramtype = "light",
sunlight_propagates = true,
tiles = {"castle_ropes.png"},
groups = {not_in_creative_inventory=1},
climbable = true,
walkable = false,
diggable = false,
node_box = {
type = "fixed",
fixed = {
{-1/16, -8/16, -1/16, 1/16, 8/16, 1/16},
},
},
selection_box = {
type = "fixed",
fixed = {
{-1/16, -8/16, -1/16, 1/16, 8/16, 1/16},
},
},
after_destruct = function(pos,oldnode)
local node = minetest.