Skip to content

Commit

Permalink
Hidden node used to block top of travelnets
Browse files Browse the repository at this point in the history
  • Loading branch information
mt-curated committed Feb 18, 2021
2 parents 7408ad0 + 7524c4a commit e9b520b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 10 deletions.
1 change: 1 addition & 0 deletions depends.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
mesecons?
mesecons_mvps?
intllib?
7 changes: 4 additions & 3 deletions elevator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ minetest.register_node("travelnet:elevator", {
-- "field[0.3,7.6;6,0.7;owner_name;(optional) owned by:;]"..
"button_exit[6.3,6.2;1.7,0.7;station_set;"..S("Store").."]" );

local p = {x=pos.x, y=pos.y+1, z=pos.z}
local top_pos = vector.add({x=0,y=1,z=0}, pos)
minetest.set_node(top_pos, {name="travelnet:hidden_top"})
local p2 = minetest.dir_to_facedir(placer:get_look_dir())
minetest.add_node(p, {name="travelnet:elevator_top", paramtype2="facedir", param2=p2})
travelnet.show_nearest_elevator( pos, placer:get_player_name(), p2 );
end,

Expand All @@ -164,7 +164,8 @@ minetest.register_node("travelnet:elevator", {
local node = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z});
local def = minetest.registered_nodes[node.name]
-- leftover elevator_top nodes can be removed by placing a new elevator underneath
if not def or not def.buildable_to then
local def = minetest.registered_nodes[node.name]
if (not def or not def.buildable_to) and node.name ~= "travelnet:hidden_top" then
minetest.chat_send_player( placer:get_player_name(), S('Not enough vertical space to place the travelnet box!'))
return;
end
Expand Down
31 changes: 29 additions & 2 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,8 @@ end

travelnet.remove_box = function( pos, oldnode, oldmetadata, digger )

minetest.remove_node(vector.add({x=0,y=1,z=0}, pos))

if( not( oldmetadata ) or oldmetadata=="nil" or not(oldmetadata.fields)) then
minetest.chat_send_player( digger:get_player_name(), S("Error")..": "..
S("Could not find information about the station that is to be removed."));
Expand Down Expand Up @@ -1005,8 +1007,33 @@ travelnet.can_dig_old = function( pos, player, description )
end
return true;
end


local hidden_def = {
drawtype = "airlike",
paramtype = "light",
sunlight_propagates = true,
walkable = true,
pointable = false,
diggable = false,
builbable_to = false,
floodable = false,
drop="",
groups = {not_in_creative_inventory = 1},
on_blast = function () end,
collision_box = {
type = "fixed",
fixed = { 0,0,0,0,0,0 },
},
}
-- Make hidden node visible for debugging
-- hidden_def.selection_box = {type="fixed",fixed={-0.3,-0.3,-0.3,0.3,0.3,0.3}}
-- hidden_def.pointable = true
-- hidden_def.drawtype = "glasslike"

minetest.register_node("travelnet:hidden_top", hidden_def)

if minetest.global_exists("mesecon") and mesecon.register_mvps_stopper then
mesecon.register_mvps_stopper("travelnet:hidden_top")
end



Expand Down
15 changes: 10 additions & 5 deletions travelnet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ minetest.register_node("travelnet:travelnet", {
light_source = 10,

after_place_node = function(pos, placer, itemstack)
local meta = minetest.get_meta(pos);
travelnet.reset_formspec( meta );
meta:set_string("owner", placer:get_player_name() );
local meta = minetest.get_meta(pos);
travelnet.reset_formspec( meta );
meta:set_string("owner", placer:get_player_name() );
local top_pos = vector.add({x=0,y=1,z=0}, pos)
minetest.set_node(top_pos, {name="travelnet:hidden_top"})
end,

on_receive_fields = travelnet.on_receive_fields,
Expand All @@ -76,8 +78,7 @@ minetest.register_node("travelnet:travelnet", {
local pos = pointed_thing.above;
local node = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z})
local def = minetest.registered_nodes[node.name]
if not def or not def.buildable_to then

if (not def or not def.buildable_to) and node.name ~= "travelnet:hidden_top" then
minetest.chat_send_player( placer:get_player_name(), S('Not enough vertical space to place the travelnet box!'))
return;
end
Expand All @@ -91,3 +92,7 @@ minetest.register_craft({
output = "travelnet:travelnet",
recipe = travelnet.travelnet_recipe,
})

if minetest.global_exists("mesecon") and mesecon.register_mvps_stopper then
mesecon.register_mvps_stopper("travelnet:travelnet")
end

0 comments on commit e9b520b

Please sign in to comment.