diff options
-rw-r--r-- | handle_schematics.lua | 31 | ||||
-rw-r--r-- | init.lua | 6 |
2 files changed, 28 insertions, 9 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, @@ -458,7 +458,7 @@ apartment.rent = function( pos, pname, oldmetadata, actor ) -- change the actual owner -- set a fitting infotext local itext = 'Object in Ap. '..descr..' ('..rented_by..')'; - n = minetest.get_node( {x=px, y=py, z=pz} ); + local n = minetest.get_node( {x=px, y=py, z=pz} ); if( n.name == 'default:chest_locked' ) then if( pname == '' ) then itext = "Locked Chest (owned by "..original_owner..")"; @@ -741,7 +741,7 @@ minetest.register_node("apartment:apartment_free", { paramtype = "light", paramtype2 = "facedir", light_source = 14, - groups = {cracky=2}, + groups = {cracky=2,not_in_creative_inventory=1}, node_box = { type = "fixed", fixed = { @@ -871,7 +871,7 @@ minetest.register_node("apartment:apartment", { paramtype = "light", paramtype2 = "facedir", light_source = 14, - groups = {cracky=2}, + groups = {cracky=2,not_in_creative_inventory=1}, node_box = { type = "fixed", fixed = { |