Skip to content

Commit

Permalink
Merge branch 'master' into issue-55
Browse files Browse the repository at this point in the history
  • Loading branch information
oversword authored Feb 18, 2021
2 parents 30fc53a + 7408ad0 commit ca5e7b3
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 16 deletions.
11 changes: 6 additions & 5 deletions elevator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ minetest.register_node("travelnet:elevator", {
fixed = {

{ 0.48, -0.5,-0.5, 0.5, 0.5, 0.5},
{-0.5 , -0.5, 0.48, 0.48, 0.5, 0.5},
{-0.5 , -0.5, 0.48, 0.48, 0.5, 0.5},
{-0.5, -0.5,-0.5 ,-0.48, 0.5, 0.5},

--groundplate to stand on
{ -0.5,-0.5,-0.5,0.5,-0.48, 0.5},
{ -0.5,-0.5,-0.5,0.5,-0.48, 0.5},
},
},

Expand All @@ -128,7 +128,7 @@ minetest.register_node("travelnet:elevator", {
meta:set_string("station_network","");
meta:set_string("owner", placer:get_player_name() );
-- request initial data
meta:set_string("formspec",
meta:set_string("formspec",
"size[12,10]"..
"field[0.3,5.6;6,0.7;station_name;"..S("Name of this station:")..";]"..
-- "field[0.3,6.6;6,0.7;station_network;Assign to Network:;]"..
Expand All @@ -140,7 +140,7 @@ minetest.register_node("travelnet:elevator", {
minetest.add_node(p, {name="travelnet:elevator_top", paramtype2="facedir", param2=p2})
travelnet.show_nearest_elevator( pos, placer:get_player_name(), p2 );
end,

on_receive_fields = travelnet.on_receive_fields,
on_punch = function(pos, node, puncher)
travelnet.update_formspec(pos, puncher:get_player_name())
Expand All @@ -162,8 +162,9 @@ minetest.register_node("travelnet:elevator", {
on_place = function(itemstack, placer, pointed_thing)
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]
-- leftover elevator_top nodes can be removed by placing a new elevator underneath
if( node ~= nil and node.name ~= "air" and node.name ~= 'travelnet:elevator_top') then
if not def or not def.buildable_to 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: 24 additions & 7 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ end


travelnet.restore_data = function()

local file = io.open( travelnet.mod_data_path, "r" );
if( not file ) then
print(S("[Mod travelnet] Error: Savefile '%s' not found.")
Expand Down Expand Up @@ -204,7 +204,8 @@ end
-- (back from help page, moved travelnet up or down etc.)
travelnet.form_input_handler = function( player, formname, fields)
if(formname == "travelnet:show" and fields and fields.pos2str) then
local pos = minetest.string_to_pos( fields.pos2str );
local pos = minetest.string_to_pos( fields.pos2str )
if not pos then return end
if( locks and (fields.locks_config or fields.locks_authorize)) then
return locks:lock_handle_input( pos, formname, fields, player )
end
Expand Down Expand Up @@ -281,6 +282,13 @@ travelnet.update_formspec = function( pos, puncher_name, fields )


if( is_elevator == true ) then
if minetest.get_modpath("areas") and areas.canInteract then
if owner_name ~= puncher_name and not areas:canInteract(pos, puncher_name) then
minetest.chat_send_player(puncher_name, S("You cannot configure an elevator in an area you don't control"))
return
end
end

travelnet.add_target( nil, nil, pos, puncher_name, meta, owner_name );
return;
end
Expand Down Expand Up @@ -715,6 +723,13 @@ travelnet.on_receive_fields = function(pos, formname, fields, player)
return
end

if minetest.get_modpath("areas") and areas.canInteract then
if owner ~= name and not areas:canInteract(pos, name) then
minetest.chat_send_player(name, S("You cannot remove this travelnet from an area you don't control"))
return
end
end

local pinv = player:get_inventory()
if(not(pinv:room_for_item("main", node.name))) then
minetest.chat_send_player(name, S("You do not have enough room in your inventory."));
Expand All @@ -730,12 +745,14 @@ travelnet.on_receive_fields = function(pos, formname, fields, player)
return;
end




-- if the box has not been configured yet
if( meta:get_string("station_network")=="" ) then

if minetest.get_modpath("areas") and areas.canInteract then
if fields.owner ~= name and not areas:canInteract(pos, name) then
minetest.chat_send_player(name, S("You cannot configure in an area you don't control"))
return
end
end
travelnet.add_target( fields.station_name, fields.station_network, pos, name, meta, fields.owner );
return;
end
Expand Down Expand Up @@ -843,7 +860,7 @@ travelnet.on_receive_fields = function(pos, formname, fields, player)
local target_pos = travelnet.targets[ owner_name ][ station_network ][ fields.target ].pos;
player:move_to( target_pos, false);

if( travelnet.travelnet_effect_enabled ) then
if( travelnet.travelnet_effect_enabled ) then
minetest.add_entity( {x=target_pos.x,y=target_pos.y+0.5,z=target_pos.z}, "travelnet:effect"); -- it self-destructs after 20 turns
end

Expand Down
2 changes: 2 additions & 0 deletions mod.conf
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
name = travelnet
description = Network of teleporter-boxes that allow easy travelling to other boxes on the same network.
optional_depends = areas, intllib, mesecons
8 changes: 4 additions & 4 deletions travelnet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ minetest.register_node("travelnet:travelnet", {
fixed = {

{ 0.45, -0.5,-0.5, 0.5, 1.45, 0.5},
{-0.5 , -0.5, 0.45, 0.45, 1.45, 0.5},
{-0.5 , -0.5, 0.45, 0.45, 1.45, 0.5},
{-0.5, -0.5,-0.5 ,-0.45, 1.45, 0.5},

--groundplate to stand on
{ -0.5,-0.5,-0.5,0.5,-0.45, 0.5},
{ -0.5,-0.5,-0.5,0.5,-0.45, 0.5},
--roof
{ -0.5, 1.45,-0.5,0.5, 1.5, 0.5},
{ -0.5, 1.45,-0.5,0.5, 1.5, 0.5},

-- control panel
-- { -0.2, 0.6, 0.3, 0.2, 1.1, 0.5},
Expand All @@ -54,7 +54,7 @@ minetest.register_node("travelnet:travelnet", {
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,
on_punch = function(pos, node, puncher)
travelnet.update_formspec(pos, puncher:get_player_name(), nil)
Expand Down

0 comments on commit ca5e7b3

Please sign in to comment.