123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- dofile(minetest.get_modpath("castle").."/pillars.lua")
- dofile(minetest.get_modpath("castle").."/arrowslit.lua")
- dofile(minetest.get_modpath("castle").."/town_item.lua")
- dofile(minetest.get_modpath("castle").."/autocraft.lua") -- from buildcraft
- minetest.register_node("castle:stonewall", {
- description = "Castle Wall",
- drawtype = "normal",
- tiles = {"castle_stonewall.png"},
- paramtype = "light",
- drop = "castle:stonewall",
- groups = {cracky = 3},
- sounds = default.node_sound_stone_defaults(),
- })
- minetest.register_node("castle:rubble", {
- description = "Castle Rubble",
- drawtype = "normal",
- tiles = {"castle_rubble.png"},
- paramtype = "light",
- groups = {crumbly = 3},
- sounds = default.node_sound_stone_defaults(),
- })
- 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},
- sounds = default.node_sound_stone_defaults(),
- })
- minetest.register_craft({
- output = "castle:stonewall_corner",
- recipe = {
- {"", "castle:stonewall"},
- {"castle:stonewall", "default:sandstone"},
- }
- })
- doors.register("door_oak", {
- tiles = {{ name = "doors_door_oak.png", backface_culling = true }},
- description = "Oak Door",
- inventory_image = "doors_item_oak.png",
- protected = true,
- groups = {door = 1, choppy = 2, flammable = 2},
- material = "default:tree",
- recipe = {
- {"default:tree", "default:tree"},
- {"default:tree", "default:tree"},
- {"default:tree", "default:tree"},
- }
- })
- function default.get_ironbound_chest_formspec(pos)
- local spos = pos.x .. "," .. pos.y .. "," ..pos.z
- local formspec =
- "size[8,9]"
- .. default.gui_bg..default.gui_bg_img..default.gui_slots
- .. "list[nodemeta:".. spos .. ";main;0,0;8,4;]"
- .. "list[current_player;main;0,5;8,4;]"
- .. "listring[nodemeta:" .. spos .. ";main]"
- .. "listring[current_player;main]"
- return formspec
- end
- local function has_ironbound_chest_privilege(meta, player)
- if player:get_player_name() == meta:get_string("owner")
- or minetest.check_player_privs(player, {protection_bypass = true}) then
- return true
- end
- return false
- 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)
- meta:set_string("owner", placer:get_player_name() or "")
- meta:set_string("infotext", "Ironbound Chest (owned by "..
- meta:get_string("owner")..")")
- end,
- on_construct = function(pos)
- local meta = minetest.get_meta(pos)
- meta:set_string("infotext", "Ironbound Chest")
- meta:set_string("owner", "")
- local inv = meta:get_inventory()
- inv:set_size("main", 8*4)
- end,
- can_dig = function(pos,player)
- local meta = minetest.get_meta(pos);
- local inv = meta:get_inventory()
- return inv:is_empty("main") and has_ironbound_chest_privilege(meta, player)
- end,
- allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
- local meta = minetest.get_meta(pos)
- if not has_ironbound_chest_privilege(meta, player) then
- minetest.log("action", player:get_player_name()..
- " tried to access a locked chest belonging to "..
- meta:get_string("owner").." at "..
- minetest.pos_to_string(pos))
- return 0
- end
- return count
- end,
- allow_metadata_inventory_put = function(pos, listname, index, stack, player)
- local meta = minetest.get_meta(pos)
- if not has_ironbound_chest_privilege(meta, player) then
- minetest.log("action", player:get_player_name()..
- " tried to access a locked chest belonging to "..
- meta:get_string("owner").." at "..
- minetest.pos_to_string(pos))
- return 0
- end
- return stack:get_count()
- end,
- allow_metadata_inventory_take = function(pos, listname, index, stack, player)
- local meta = minetest.get_meta(pos)
- if not has_ironbound_chest_privilege(meta, player) then
- minetest.log("action", player:get_player_name()..
- " tried to access a locked chest belonging to "..
- meta:get_string("owner").." at "..
- minetest.pos_to_string(pos))
- return 0
- end
- return stack:get_count()
- end,
- on_rightclick = function(pos, node, clicker)
- local meta = minetest.get_meta(pos)
- if has_ironbound_chest_privilege(meta, clicker) then
- minetest.show_formspec(
- clicker:get_player_name(),
- "castle:ironbound_chest",
- default.get_ironbound_chest_formspec(pos)
- )
- end
- end,
- })
- minetest.register_craft({
- output = "castle:ironbound_chest",
- recipe = {
- {"group:wood", "default:steel_ingot","group:wood"},
- {"group:wood", "default:steel_ingot","group:wood"}
- }
- })
- -- Wooden tapestry top
- minetest.register_node("castle:tapestry_top", {
- drawtype = "nodebox",
- description = "Tapestry Top",
- tiles = {"default_wood.png"},
- sunlight_propagates = true,
- groups = {flammable=3,choppy=2,oddly_breakable_by_hand=1},
- sounds = default.node_sound_defaults(),
- paramtype = "light",
- paramtype2 = "facedir",
- node_box = {
- type = "fixed",
- fixed = {-0.6,-0.5,0.375,0.6,-0.375,0.5},
- },
- selection_box = {
- type = "fixed",
- fixed = {-0.6,-0.5,0.375,0.6,-0.375,0.5},
- },
- })
- minetest.register_craft({
- type = "shapeless",
- output = "castle:tapestry_top",
- recipe = {"default:stick"},
- })
- minetest.register_craft({
- type = "shapeless",
- recipe = {"castle:tapestry_top"},
- output = "default:stick",
- })
- print ("[MOD] Castle loaded")
|