diff options
Diffstat (limited to 'handle_schematics.lua')
-rw-r--r-- | handle_schematics.lua | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/handle_schematics.lua b/handle_schematics.lua index e72ed60..bd443d7 100644 --- a/handle_schematics.lua +++ b/handle_schematics.lua @@ -8,6 +8,10 @@ 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 @@ -526,7 +545,7 @@ handle_schematics.on_receive_fields = function(pos, formname, fields, sender) end pname = sender:get_player_name(); - if( not( minetest.check_player_privs(pname, {apartment_unrent=true}))) then + if( not( minetest.check_player_privs(pname, {apartment_spawn=true}))) then minetest.chat_send_player( pname, 'You do not have the necessary privileges.'); return; end @@ -590,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, |