diff options
Diffstat (limited to 'handle_schematics.lua')
-rw-r--r-- | handle_schematics.lua | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/handle_schematics.lua b/handle_schematics.lua index a80daf6..bd443d7 100644 --- a/handle_schematics.lua +++ b/handle_schematics.lua @@ -6,8 +6,12 @@ handle_schematics.SCAFFOLDING = 'random_buildings:support'; handle_schematics.AUTODECAY = 'apartment:autodecay'; +handle_schematics.ENABLE_SLOW_DECAY = false + + minetest.register_privilege("apartment_spawn", { description = "allows you to spawn apartments", give_to_singleplayer = false}); + -- taken from https://github.com/MirceaKitsune/minetest_mods_structures/blob/master/structures_io.lua (Taokis Sructures I/O mod) -- gets the size of a structure file -- nodenames: contains all the node names that are used in the schematic @@ -183,11 +187,26 @@ handle_schematics.update_nodes = function( start_pos, end_pos, on_constr, after_ -- steel doors are annoying because the cannot be catched with the functions above local doornodes = minetest.find_nodes_in_area( start_pos, end_pos, {'doors:door_steel_b_1','doors:door_steel_b_2', - 'doors:door_steel_t_1','doors:door_steel_t_2'}); + 'doors:door_steel_t_1','doors:door_steel_t_2', + 'doors:door_steel_a', 'doors:door_steel_b'}); for _, p in ipairs( doornodes ) do + local node = minetest.get_node( p ); local meta = minetest.get_meta( p ); - meta:set_string("doors_owner", player_name ); - meta:set_string("infotext", "Owned by "..player_name) + if( not( node ) or not( node.name )) then + -- do nothing + elseif( node.name=='doors:door_steel_t_1' or node.name=='doors:door_steel_t_2') then + -- replace top of old steel doors with new node + minetest.swap_node( p, {name='doors:door_hidden', param2=node.param2} ); + else + -- set the new owner + meta:set_string("doors_owner", player_name ); + meta:set_string("infotext", "Owned by "..player_name) + if( node.name == 'doors:door_steel_b_1' ) then + minetest.swap_node( p, {name='doors:door_steel_a', param2=nod3.param2}); + elseif( node.name == 'doors:door_steel_b_2' ) then + minetest.swap_node( p, {name='doors:door_steel_b', param2=node.param2}); + end + end end @@ -459,7 +478,11 @@ handle_schematics.replacement_function_decay = function( nodenames ) local replacements = {}; for _,v in ipairs( nodenames ) do - table.insert( replacements, { v, handle_schematics.AUTODECAY }) + if( handle_schematics.ENABLE_SLOW_DECAY ) then + table.insert( replacements, { v, handle_schematics.AUTODECAY }) + else + table.insert( replacements, { v, 'air' }) + end end return replacements; end @@ -586,8 +609,8 @@ end minetest.register_node("apartment:build_chest", { description = "Apartment spawner", - tiles = {"default_chest_side.png", "default_chest_top.png^door_steel.png", "default_chest_side.png", - "default_chest_side.png", "default_chest_side.png", "default_chest_lock.png^door_steel.png"}, + tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_top.png", + "default_chest_top.png", "default_chest_top.png", "apartment_controls_vacant.png"}, paramtype2 = "facedir", groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, legacy_facedir_simple = true, @@ -642,7 +665,8 @@ minetest.register_node("apartment:build_chest", { }) -minetest.register_node( handle_schematics.AUTODECAY, { +if handle_schematics.ENABLE_SLOW_DECAY then + minetest.register_node( handle_schematics.AUTODECAY, { description = "decaying building", drawtype = "allfaces_optional", visual_scale = 1.3, @@ -651,9 +675,9 @@ minetest.register_node( handle_schematics.AUTODECAY, { waving = 1, is_ground_content = false, groups = {snappy=3}, -}) + }) -minetest.register_abm({ + minetest.register_abm({ nodenames = {handle_schematics.AUTODECAY}, -- A low interval and a high inverse chance spreads the load interval = 2, @@ -661,4 +685,5 @@ minetest.register_abm({ action = function(p0, node, _, _) minetest.remove_node( p0 ); end -}) + }) +end |