fixed undeclared globals; updated deprecated functions

This commit is contained in:
Sokomine 2017-12-16 07:20:32 +01:00
parent 580cd12f96
commit 4535449f2b

@ -24,6 +24,8 @@
Changelog: Changelog:
16.07.17 - Merged several PR from others (Typo, screenshot, documentation, mesecon support, bugfix). 16.07.17 - Merged several PR from others (Typo, screenshot, documentation, mesecon support, bugfix).
Added buttons to move stations up or down in the list, independent on when they where added. Added buttons to move stations up or down in the list, independent on when they where added.
Fixed undeclared globals.
Changed deprecated functions set_look_yaw/pitch to current functions.
22.07.17 - Fixed bug with locked travelnets beeing removed from the network due to not beeing recognized. 22.07.17 - Fixed bug with locked travelnets beeing removed from the network due to not beeing recognized.
30.08.16 - If the station the traveller just travelled to no longer exists, the player is sent back to the 30.08.16 - If the station the traveller just travelled to no longer exists, the player is sent back to the
station where he/she came from. station where he/she came from.
@ -259,13 +261,14 @@ travelnet.update_formspec = function( pos, puncher_name, fields )
or (minetest.check_player_privs(puncher_name, {travelnet_attach=true}))) or (minetest.check_player_privs(puncher_name, {travelnet_attach=true})))
) then ) then
local current_pos = -1;
for index,k in ipairs( stations ) do for index,k in ipairs( stations ) do
if( k==station_name ) then if( k==station_name ) then
current_pos = index; current_pos = index;
end end
end end
swap_with_pos = -1; local swap_with_pos = -1;
if( fields.move_up ) then if( fields.move_up ) then
swap_with_pos = current_pos - 1; swap_with_pos = current_pos - 1;
else else
@ -630,7 +633,7 @@ travelnet.on_receive_fields = function(pos, formname, fields, player)
player:moveto( pos, false ); player:moveto( pos, false );
-- do this only on servers where the function exists -- do this only on servers where the function exists
elseif( player.set_look_yaw ) then elseif( player.set_look_horizontal ) then
-- rotate the player so that he/she can walk straight out of the box -- rotate the player so that he/she can walk straight out of the box
local yaw = 0; local yaw = 0;
@ -645,8 +648,8 @@ travelnet.on_receive_fields = function(pos, formname, fields, player)
yaw = 270; yaw = 270;
end end
player:set_look_yaw( math.rad( yaw )); -- this is only supported in recent versions of MT player:set_look_horizontal( math.rad( yaw ));
player:set_look_pitch( math.rad( 0 )); -- this is only supported in recent versions of MT player:set_look_vertical( math.rad( 0 ));
end end
travelnet.open_close_door( target_pos, player, 2 ); travelnet.open_close_door( target_pos, player, 2 );
@ -695,16 +698,16 @@ travelnet.can_dig = function( pos, player, description )
return false; return false;
end end
local name = player:get_player_name(); local name = player:get_player_name();
local meta = minetest.get_meta( pos );
local owner = meta:get_string('owner');
local network_name = meta:get_string( "station_network" );
-- players with that priv can dig regardless of owner -- players with that priv can dig regardless of owner
if( minetest.check_player_privs(name, {travelnet_remove=true}) if( minetest.check_player_privs(name, {travelnet_remove=true})
or travelnet.allow_dig( player_name, owner_name, network_name )) then or travelnet.allow_dig( name, owner, network_name )) then
return true; return true;
end end
local meta = minetest.get_meta( pos );
local owner = meta:get_string('owner');
if( not( meta ) or not( owner) or owner=='') then if( not( meta ) or not( owner) or owner=='') then
minetest.chat_send_player(name, "This "..description.." has not been configured yet. Please set it up first to claim it. Afterwards you can remove it because you are then the owner."); minetest.chat_send_player(name, "This "..description.." has not been configured yet. Please set it up first to claim it. Afterwards you can remove it because you are then the owner.");
return false; return false;