From 0462b79dcacd416fce7e4d265ed7fdb30a9ee775 Mon Sep 17 00:00:00 2001 From: kaadmy Date: Wed, 30 Sep 2015 08:55:54 -0700 Subject: [PATCH] increased village density and trying to get locks working --- mods/locks/init.lua | 40 ++++++++++++++++++++++++++++++++++------ mods/village/mapgen.lua | 2 +- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/mods/locks/init.lua b/mods/locks/init.lua index 18219ab..1c90cbd 100644 --- a/mods/locks/init.lua +++ b/mods/locks/init.lua @@ -5,8 +5,13 @@ locks = {} -function locks.is_locked(pos, player) - local pos = pointed_thing.under +locks.picked_time = tonumber(minetest.setting_getbool("locks_picked_time")) or 15 -- unlocked for 15 seconds + +local all_unlocked = minetest.setting_getbool("locks_all_unlocked") + +function locks.is_locked(meta, player) + if meta:get_float("last_lock_pick") > locks.picked_time then + end end minetest.register_craftitem( @@ -18,10 +23,33 @@ minetest.register_craftitem( wield_image = "locks_pick.png", on_use = function(itemstack, user, pointed_thing) - local pos = pointed_thing.under - - local meta = minetest.get_meta(pos) - end, + }) + +minetest.register_node( + "locks:chest", + { + description = "Locked Chest", + tiles ={"default_chest_top.png", "default_chest_top.png", "default_chest_sides.png", + "default_chest_sides.png", "default_chest_sides.png", "default_chest_front.png^default_ingot_steel.png"}, + paramtype2 = "facedir", + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, + is_ground_content = false, + sounds = default.node_sound_wood_defaults(), + after_place_node = function(pos, player) + local form = default.ui.get_page("default_chest") + + local meta = minetest.get_meta(pos) + meta:set_string("formspec", form) + meta:set_string("infotext", "Locked Chest (Owned by " .. player:get_player_name() .. ")") + + 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 locks.is_owner(meta, player) + end, }) \ No newline at end of file diff --git a/mods/village/mapgen.lua b/mods/village/mapgen.lua index e96145e..4a16e1b 100644 --- a/mods/village/mapgen.lua +++ b/mods/village/mapgen.lua @@ -44,7 +44,7 @@ minetest.register_abm( minetest.remove_node(pos) local pr = PseudoRandom(minetest.get_mapgen_params().seed+pos.x+pos.y+pos.z) if node.name == "village:grassland_village_mg" then - if pr:next(1, 80) == 1 then + if pr:next(1, 60) == 1 then print("Spawning a (Mapgen)Grassland village at "..dump(pos)) minetest.after(3.0, function() village.spawn_village(pos, pr) end) -- a short delay to (hopefully)ensure that the surrounding terrain is generated end