diff options
author | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2018-02-13 14:05:34 -0500 |
---|---|---|
committer | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2018-02-13 14:05:34 -0500 |
commit | 335d9a3eddcb590c3ca5de9cba9b152e5e560af1 (patch) | |
tree | 1b95d73b945fbc9924438c28a35d7f1019fa255f /travelnet/init.lua | |
parent | 1d0f113f4c5afcf8479973f2e01786fb9a1fbbb7 (diff) | |
download | dreambuilder_modpack-335d9a3eddcb590c3ca5de9cba9b152e5e560af1.tar dreambuilder_modpack-335d9a3eddcb590c3ca5de9cba9b152e5e560af1.tar.gz dreambuilder_modpack-335d9a3eddcb590c3ca5de9cba9b152e5e560af1.tar.bz2 dreambuilder_modpack-335d9a3eddcb590c3ca5de9cba9b152e5e560af1.tar.xz dreambuilder_modpack-335d9a3eddcb590c3ca5de9cba9b152e5e560af1.zip |
removed boost_cart and carbone_mobs -- too many crashes
updated blox, homedecor, plantlifed, cottages, farming_redo,
framedglass, gloopblocks, mesecons, moreblocks, moretrees,
pipeworks, player_textures, replacer, signs_lib, stained_glass,
technic, travelnet, unified_inventory, unifieddyes, and worldedit.
Diffstat (limited to 'travelnet/init.lua')
-rw-r--r-- | travelnet/init.lua | 334 |
1 files changed, 270 insertions, 64 deletions
diff --git a/travelnet/init.lua b/travelnet/init.lua index 4267601..5be6cac 100644 --- a/travelnet/init.lua +++ b/travelnet/init.lua @@ -22,6 +22,19 @@ Please configure this mod in config.lua Changelog: + 24.12.17 - Added support for localization through intllib. + Added localization for German (de). + 17.07.17 - Added more detailled licence information. + TNT and DungeonMasters ought to leave travelnets and elevators untouched now. + Added function to register elevator doors. + Added elevator doors made out of tin ingots. + Provide information about the nearest elevator network when placing a new elevator. This + ought to make it easier to find the right spot. + Improved formspec. + 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. + 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. 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. @@ -62,13 +75,21 @@ --]] -minetest.register_privilege("travelnet_attach", { description = "allows to attach travelnet boxes to travelnets of other players", give_to_singleplayer = false}); -minetest.register_privilege("travelnet_remove", { description = "allows to dig travelnet boxes which belog to nets of other players", give_to_singleplayer = false}); - travelnet = {}; travelnet.targets = {}; +-- Boilerplate to support localized strings if intllib mod is installed. +if minetest.get_modpath( "intllib" ) and intllib then + travelnet.S = intllib.Getter() +else + travelnet.S = function(s) return s end +end + +local S = travelnet.S; + +minetest.register_privilege("travelnet_attach", { description = S("allows to attach travelnet boxes to travelnets of other players"), give_to_singleplayer = false}); +minetest.register_privilege("travelnet_remove", { description = S("allows to dig travelnet boxes which belog to nets of other players"), give_to_singleplayer = false}); -- read the configuration dofile(minetest.get_modpath("travelnet").."/config.lua"); -- the normal, default travelnet @@ -87,7 +108,7 @@ travelnet.save_data = function() file:write( data ); file:close(); else - print("[Mod travelnet] Error: Savefile '"..tostring( path ).."' could not be written."); + print(S("[Mod travelnet] Error: Savefile '%s' could not be written."):format(tostring(path))); end end @@ -102,15 +123,111 @@ travelnet.restore_data = function() travelnet.targets = minetest.deserialize( data ); file:close(); else - print("[Mod travelnet] Error: Savefile '"..tostring( path ).."' not found."); + print(S("[Mod travelnet] Error: Savefile '%s' not found."):format(tostring(path))); end end +-- punching the travelnet updates its formspec and shows it to the player; +-- however, that would be very annoying when actually trying to dig the thing. +-- Thus, check if the player is wielding a tool that can dig nodes of the +-- group cracky +travelnet.check_if_trying_to_dig = function( puncher, node ) + -- if in doubt: show formspec + if( not( puncher) or not( puncher:get_wielded_item())) then + return false; + end + local tool_capabilities = puncher:get_wielded_item():get_tool_capabilities(); + if( not( tool_capabilities ) + or not( tool_capabilities["groupcaps"]) + or not( tool_capabilities["groupcaps"]["cracky"])) then + return false; + end + -- tools which can dig cracky items can start digging immediately + return true; +end + +-- minetest.chat_send_player is sometimes not so well visible +travelnet.show_message = function( pos, player_name, title, message ) + if( not( pos ) or not( player_name ) or not( message )) then + return; + end + local formspec = "size[8,3]".. + "label[3,0;"..minetest.formspec_escape( title or "Error").."]".. + "textlist[0,0.5;8,1.5;;"..minetest.formspec_escape( message or "- nothing -")..";]".. + "button_exit[3.5,2.5;1.0,0.5;back;"..S("Back").."]".. + "button_exit[6.8,2.5;1.0,0.5;station_exit;"..S("Exit").."]".. + "field[20,20;0.1,0.1;pos2str;Pos;".. minetest.pos_to_string( pos ).."]"; + minetest.show_formspec(player_name, "travelnet:show", formspec); +end + +-- show the player the formspec he would see when right-clicking the node; +-- needs to be simulated this way as calling on_rightclick would not do +travelnet.show_current_formspec = function( pos, meta, player_name ) + if( not( pos ) or not( meta ) or not( player_name )) then + return; + end + -- we need to supply the position of the travelnet box + formspec = meta:get_string("formspec").. + "field[20,20;0.1,0.1;pos2str;Pos;".. minetest.pos_to_string( pos ).."]"; + -- show the formspec manually + minetest.show_formspec(player_name, "travelnet:show", formspec); +end + +-- a player clicked on something in the formspec he was manually shown +-- (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 ); + -- back button leads back to the main menu + if( fields.back and fields.back ~= "" ) then + return travelnet.show_current_formspec( pos, + minetest.get_meta( pos ), player:get_player_name()); + end + return travelnet.on_receive_fields(pos, formname, fields, player); + end +end + +-- most formspecs the travelnet uses are stored in the travelnet node itself, +-- but some may require some "back"-button functionality (i.e. help page, +-- move up/down etc.) +minetest.register_on_player_receive_fields( travelnet.form_input_handler ); -travelnet.update_formspec = function( pos, puncher_name ) +travelnet.reset_formspec = function( meta ) + if( not( meta )) then + return; + end + meta:set_string("infotext", S("Travelnet-box (unconfigured)")); + meta:set_string("station_name", ""); + meta:set_string("station_network",""); + meta:set_string("owner", ""); + -- some players seem to be confused with entering network names at first; provide them + -- with a default name + if( not( station_network ) or station_network == "" ) then + station_network = "net1"; + end + -- request initinal data + meta:set_string("formspec", + "size[10,6.0]".. + "label[2.0,0.0;--> "..S("Configure this travelnet station").." <--]".. + "field[0.3,1.2;9,0.9;station_name;"..S("Name of this station")..":;".. + minetest.formspec_escape(station_name or "").."]".. + "label[0.3,1.5;"..S("How do you call this place here? Example: \"my first house\", \"mine\", \"shop\"...").."]".. + + "field[0.3,2.8;9,0.9;station_network;"..S("Assign to Network:")..";".. + minetest.formspec_escape(station_network or "").."]".. + "label[0.3,3.1;"..S("You can have more than one network. If unsure, use \"%s\""):format(tostring(station_network)).."\".]".. + "field[0.3,4.4;9,0.9;owner;"..S("Owned by:")..";]".. + "label[0.3,4.7;"..S("Unless you know what you are doing, leave this empty.").."]".. + "button_exit[1.3,5.3;1.7,0.7;station_help_setup;"..S("Help").."]".. + "button_exit[3.8,5.3;1.7,0.7;station_set;"..S("Save").."]".. + "button_exit[6.3,5.3;1.7,0.7;station_exit;"..S("Exit").."]"); +end + + +travelnet.update_formspec = function( pos, puncher_name, fields ) local meta = minetest.get_meta(pos); local this_node = minetest.get_node( pos ); @@ -144,19 +261,8 @@ travelnet.update_formspec = function( pos, puncher_name ) -- minetest.chat_send_player(puncher_name, "data: "..minetest.serialize( travelnet.targets )); - meta:set_string("infotext", "Travelnet-box (unconfigured)"); - meta:set_string("station_name", ""); - meta:set_string("station_network",""); - meta:set_string("owner", ""); - -- request initinal data - meta:set_string("formspec", - "size[12,10]".. - "field[0.3,7.6;9,0.9;station_name;Name of this station:;"..(station_name or "?").."]".. - "field[0.3,8.6;9,0.9;station_network;Assign to Network:;"..(station_network or "?").."]".. - "field[0.3,9.6;9,0.9;owner;Owned by:;"..(owner_name or "?").."]".. - "button_exit[6.3,8.2;1.7,0.7;station_set;Store]" ); - - minetest.chat_send_player(puncher_name, "Error: Update failed! Resetting this box on the travelnet."); + travelnet.reset_formspec( meta ); + travelnet.show_message( pos, puncher_name, "Error", S("Update failed! Resetting this box on the travelnet.")); return; end @@ -184,8 +290,9 @@ travelnet.update_formspec = function( pos, puncher_name ) -- add this station travelnet.targets[ owner_name ][ station_network ][ station_name ] = {pos=pos, timestamp=zeit }; - minetest.chat_send_player(owner_name, "Station '"..station_name.."' has been reattached to the network '"..station_network.."'."); - + minetest.chat_send_player(owner_name, S("Station '%s'"):format(station_name).." ".. + S(" has been reattached to the network '%s'."):format(station_network)); + travelnet.save_data(); end @@ -193,15 +300,15 @@ travelnet.update_formspec = function( pos, puncher_name ) local zusatzstr = ""; local trheight = "10"; if( this_node and this_node.name=="locked_travelnet:travelnet" ) then - zusatzstr = "field[0.3,11;6,0.7;locks_sent_lock_command;Locked travelnet. Type /help for help:;]"; + zusatzstr = "field[0.3,11;6,0.7;locks_sent_lock_command;"..S("Locked travelnet. Type /help for help:")..";]"; trheight = "11.5"; end local formspec = "size[12,"..trheight.."]".. - "label[3.3,0.0;Travelnet-Box:]".."label[6.3,0.0;Punch box to update target list.]".. - "label[0.3,0.4;Name of this station:]".."label[6.3,0.4;"..(station_name or "?").."]".. - "label[0.3,0.8;Assigned to Network:]" .."label[6.3,0.8;"..(station_network or "?").."]".. - "label[0.3,1.2;Owned by:]" .."label[6.3,1.2;"..(owner_name or "?").."]".. - "label[3.3,1.6;Click on target to travel there:]".. + "label[3.3,0.0;"..S("Travelnet-Box")..":]".."label[6.3,0.0;"..S("Punch box to update target list.").."]".. + "label[0.3,0.4;"..S("Name of this station:").."]".."label[6.3,0.4;"..minetest.formspec_escape(station_name or "?").."]".. + "label[0.3,0.8;"..S("Assigned to Network:").."]" .."label[6.3,0.8;"..minetest.formspec_escape(station_network or "?").."]".. + "label[0.3,1.2;"..S("Owned by:").."]" .."label[6.3,1.2;"..minetest.formspec_escape(owner_name or "?").."]".. + "label[3.3,1.6;"..S("Click on target to travel there:").."]".. zusatzstr; -- "button_exit[5.3,0.3;8,0.8;do_update;Punch box to update destination list. Click on target to travel there.]".. local x = 0; @@ -234,7 +341,7 @@ travelnet.update_formspec = function( pos, puncher_name ) end for index,k in ipairs( stations ) do if( index == ground_level ) then - travelnet.targets[ owner_name ][ station_network ][ k ].nr = 'G'; + travelnet.targets[ owner_name ][ station_network ][ k ].nr = S('G'); else travelnet.targets[ owner_name ][ station_network ][ k ].nr = tostring( ground_level - index ); end @@ -246,6 +353,58 @@ travelnet.update_formspec = function( pos, puncher_name ) travelnet.targets[ owner_name ][ station_network ][ b ].timestamp end); end + -- does the player want to move this station one position up in the list? + -- only the owner and players with the travelnet_attach priv can change the order of the list + -- Note: With elevators, only the "G"(round) marking is actually moved + if( fields + and (fields.move_up or fields.move_down) + and owner_name + and owner_name ~= "" + and ((owner_name == puncher_name) + or (minetest.check_player_privs(puncher_name, {travelnet_attach=true}))) + ) then + + local current_pos = -1; + for index,k in ipairs( stations ) do + if( k==station_name ) then + current_pos = index; + end + end + + local swap_with_pos = -1; + if( fields.move_up ) then + swap_with_pos = current_pos - 1; + else + swap_with_pos = current_pos + 1; + end + -- handle errors + if( swap_with_pos < 1) then + travelnet.show_message( pos, puncher_name, "Info", S("This station is already the first one on the list.")); + return; + elseif( swap_with_pos > #stations ) then + travelnet.show_message( pos, puncher_name, "Info", S("This station is already the last one on the list.")); + return; + else + -- swap the actual data by which the stations are sorted + local old_timestamp = travelnet.targets[ owner_name ][ station_network ][ stations[swap_with_pos]].timestamp; + travelnet.targets[ owner_name ][ station_network ][ stations[swap_with_pos]].timestamp = + travelnet.targets[ owner_name ][ station_network ][ stations[current_pos ]].timestamp; + travelnet.targets[ owner_name ][ station_network ][ stations[current_pos ]].timestamp = + old_timestamp; + + -- for elevators, only the "G"(round) marking is moved; no point in swapping stations + if( not( is_elevator )) then + -- actually swap the stations + local old_val = stations[ swap_with_pos ]; + stations[ swap_with_pos ] = stations[ current_pos ]; + stations[ current_pos ] = old_val; + end + + -- store the changed order + travelnet.save_data(); + end + end + -- if there are only 8 stations (plus this one), center them in the formspec if( #stations < 10 ) then x = 4; @@ -287,13 +446,21 @@ travelnet.update_formspec = function( pos, puncher_name ) --x = x+4; end end + formspec = formspec.. + "label[8.0,1.6;"..S("Position in list:").."]".. + "button_exit[11.3,0.0;1.0,0.5;station_exit;"..S("Exit").."]".. + "button_exit[9.6,1.6;1.4,0.5;move_up;"..S("move up").."]".. + "button_exit[10.9,1.6;1.4,0.5;move_down;"..S("move down").."]"; meta:set_string( "formspec", formspec ); - meta:set_string( "infotext", "Station '"..tostring( station_name ).."' on travelnet '"..tostring( station_network ).. - "' (owned by "..tostring( owner_name )..") ready for usage. Right-click to travel, punch to update."); + meta:set_string( "infotext", S("Station '%s'"):format(tostring( station_name )).." ".. + S("on travelnet '%s'"):format(tostring( station_network )).." ".. + S("(owned by %s)"):format(tostring( owner_name )).." ".. + S("ready for usage. Right-click to travel, punch to update.")); - minetest.chat_send_player(puncher_name, "The target list of this box on the travelnet has been updated."); + -- show the player the updated formspec + travelnet.show_current_formspec( pos, meta, puncher_name ); end @@ -310,17 +477,18 @@ travelnet.add_target = function( station_name, network_name, pos, player_name, m is_elevator = true; network_name = tostring( pos.x )..','..tostring( pos.z ); if( not( station_name ) or station_name == '' ) then - station_name = 'at '..tostring( pos.y )..'m'; + station_name = S('at %s m'):format(tostring( pos.y )); end end if( station_name == "" or not(station_name )) then - minetest.chat_send_player(player_name, "Please provide a name for this station."); + travelnet.show_message( pos, player_name, S("Error"), S("Please provide a name for this station." )); return; end if( network_name == "" or not( network_name )) then - minetest.chat_send_player(player_name, "Please provide the name of the network this station ought to be connected to."); + travelnet.show_message( pos, player_name, S("Error"), + S("Please provide the name of the network this station ought to be connected to.")); return; end @@ -332,13 +500,16 @@ travelnet.add_target = function( station_name, network_name, pos, player_name, m elseif( not( minetest.check_player_privs(player_name, {interact=true}))) then - minetest.chat_send_player(player_name, "There is no player with interact privilege named '"..tostring( player_name ).."'. Aborting."); + travelnet.show_message( pos, player_name, S("Error"), + S("There is no player with interact privilege named '%s'. Aborting."):format(tostring( player_name ))); return; elseif( not( minetest.check_player_privs(player_name, {travelnet_attach=true})) and not( travelnet.allow_attach( player_name, owner_name, network_name ))) then - minetest.chat_send_player(player_name, "You do not have the travelnet_attach priv which is required to attach your box to the network of someone else. Aborting."); + travelnet.show_message( pos, player_name, S("Error"), + S("You do not have the travelnet_attach priv which is required to attach your box to ".. + "the network of someone else. Aborting.")); return; end @@ -357,7 +528,8 @@ travelnet.add_target = function( station_name, network_name, pos, player_name, m for k,v in pairs( travelnet.targets[ owner_name ][ network_name ] ) do if( k == station_name ) then - minetest.chat_send_player(player_name, "Error: A station named '"..station_name.."' already exists on this network. Please choose a diffrent name!"); + travelnet.show_message( pos, player_name, S("Error"), + S("A station named '%s' already exists on this network. Please choose a diffrent name!"):format(station_name)); return; end @@ -366,8 +538,10 @@ travelnet.add_target = function( station_name, network_name, pos, player_name, m -- we don't want too many stations in the same network because that would get confusing when displaying the targets if( anz+1 > travelnet.MAX_STATIONS_PER_NETWORK ) then - minetest.chat_send_player(player_name, "Error: Network '"..network_name.."' already contains the maximum number (=" - ..(travelnet.MAX_STATIONS_PER_NETWORK)..") of allowed stations per network. Please choose a diffrent/new network name."); + travelnet.show_message( pos, player_name, S("Error"), + S("Network '%s',"):format(network_name).." ".. + S("already contains the maximum number (=%s) of allowed stations per network. ".. + "Please choose a diffrent/new network name."):format(travelnet.MAX_STATIONS_PER_NETWORK)); return; end @@ -377,8 +551,9 @@ travelnet.add_target = function( station_name, network_name, pos, player_name, m -- do we have a new node to set up? (and are not just reading from a safefile?) if( meta ) then - minetest.chat_send_player(player_name, "Station '"..station_name.."' has been added to the network '" - ..network_name.."', which now consists of "..( anz+1 ).." station(s)."); + minetest.chat_send_player(player_name, S("Station '%s'"):format(station_name).." ".. + S("has been added to the network '%s'"):format(network_name).. + S(", which now consists of %s station(s)."):format(anz+1)); meta:set_string( "station_name", station_name ); meta:set_string( "station_network", network_name ); @@ -387,11 +562,11 @@ travelnet.add_target = function( station_name, network_name, pos, player_name, m meta:set_string("formspec", "size[12,10]".. - "field[0.3,0.6;6,0.7;station_name;Station:;".. meta:get_string("station_name").."]".. - "field[0.3,3.6;6,0.7;station_network;Network:;"..meta:get_string("station_network").."]" ); + "field[0.3,0.6;6,0.7;station_name;"..S("Station:")..";".. minetest.formspec_escape(meta:get_string("station_name")).."]".. + "field[0.3,3.6;6,0.7;station_network;"..S("Network:")..";"..minetest.formspec_escape(meta:get_string("station_network")).."]" ); -- display a list of all stations that can be reached from here - travelnet.update_formspec( pos, player_name ); + travelnet.update_formspec( pos, player_name, nil ); -- save the updated network data in a savefile over server restart travelnet.save_data(); @@ -446,10 +621,30 @@ end travelnet.on_receive_fields = function(pos, formname, fields, player) + if( not( pos )) then + return; + end local meta = minetest.get_meta(pos); local name = player:get_player_name(); + -- the player wants to quit/exit the formspec; do not save/update anything + if( fields and fields.station_exit and fields.station_exit ~= "" ) then + return; + end + + -- show help text + if( fields and fields.station_help_setup and fields.station_help_setup ~= "") then + -- simulate right-click + local node = minetest.get_node( pos ); + if( node and node.name and minetest.registered_nodes[ node.name ] ) then + travelnet.show_message( pos, name, "--> Help <--", +-- TODO: actually add help page + S("No help available yet.")); + end + return; + end + -- if the box has not been configured yet if( meta:get_string("station_network")=="" ) then @@ -462,9 +657,14 @@ travelnet.on_receive_fields = function(pos, formname, fields, player) return; end + -- the owner or players with the travelnet_attach priv can move stations up or down in the list + if( fields.move_up or fields.move_down) then + travelnet.update_formspec( pos, name, fields ); + return; + end if( not( fields.target )) then - minetest.chat_send_player(name, "Please click on the target you want to travel to."); + minetest.chat_send_player(name, S("Please click on the target you want to travel to.")); return; end @@ -486,7 +686,8 @@ travelnet.on_receive_fields = function(pos, formname, fields, player) and station_network ) then travelnet.add_target( station_name, station_network, pos, owner_name, meta, owner_name ); else - minetest.chat_send_player(name, "Error: There is something wrong with the configuration of this station. ".. + minetest.chat_send_player(name, S("Error")..": ".. + S("There is something wrong with the configuration of this station.").. " DEBUG DATA: owner: "..( owner_name or "?").. " station_name: "..(station_name or "?").. " station_network: "..(station_network or "?").."."); @@ -499,7 +700,8 @@ travelnet.on_receive_fields = function(pos, formname, fields, player) or not( travelnet.targets ) or not( travelnet.targets[ owner_name ] ) or not( travelnet.targets[ owner_name ][ station_network ] )) then - minetest.chat_send_player(name, "Error: This travelnet is lacking data and/or improperly configured."); + minetest.chat_send_player(name, S("Error")..": ".. + S("This travelnet is lacking data and/or improperly configured.")); print( "ERROR: The travelnet at "..minetest.pos_to_string( pos ).." has a problem: ".. " DATA: owner: "..( owner_name or "?").. " station_name: "..(station_name or "?").. @@ -521,8 +723,9 @@ travelnet.on_receive_fields = function(pos, formname, fields, player) -- if the target station is gone if( not( travelnet.targets[ owner_name ][ station_network ][ fields.target ] )) then - minetest.chat_send_player(name, "Station '"..( fields.target or "?").." does not exist (anymore?) on this network."); - travelnet.update_formspec( pos, name ); + minetest.chat_send_player(name, S("Station '%s'"):format( fields.target or "?").." ".. + S("does not exist (anymore?) on this network.")); + travelnet.update_formspec( pos, name, nil ); return; end @@ -530,7 +733,7 @@ travelnet.on_receive_fields = function(pos, formname, fields, player) if( not( travelnet.allow_travel( name, owner_name, station_network, station_name, fields.target ))) then return; end - minetest.chat_send_player(name, "Initiating transfer to station '"..( fields.target or "?").."'.'"); + minetest.chat_send_player(name, S("Initiating transfer to station '%s'."):format( fields.target or "?")); @@ -570,7 +773,7 @@ travelnet.on_receive_fields = function(pos, formname, fields, player) player:moveto( pos, false ); -- 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 local yaw = 0; @@ -585,8 +788,8 @@ travelnet.on_receive_fields = function(pos, formname, fields, player) yaw = 270; end - player:set_look_yaw( math.rad( yaw )); -- this is only supported in recent versions of MT - player:set_look_pitch( math.rad( 0 )); -- this is only supported in recent versions of MT + player:set_look_horizontal( math.rad( yaw )); + player:set_look_vertical( math.rad( 0 )); end travelnet.open_close_door( target_pos, player, 2 ); @@ -596,7 +799,8 @@ end travelnet.remove_box = function( pos, oldnode, oldmetadata, digger ) if( not( oldmetadata ) or oldmetadata=="nil" or not(oldmetadata.fields)) then - minetest.chat_send_player( digger:get_player_name(), "Error: Could not find information about the station that is to be removed."); + minetest.chat_send_player( digger:get_player_name(), S("Error")..": ".. + S("Could not find information about the station that is to be removed.")); return; end @@ -611,16 +815,19 @@ travelnet.remove_box = function( pos, oldnode, oldmetadata, digger ) or not( travelnet.targets[ owner_name ] ) or not( travelnet.targets[ owner_name ][ station_network ] )) then - minetest.chat_send_player( digger:get_player_name(), "Error: Could not find the station that is to be removed."); + minetest.chat_send_player( digger:get_player_name(), S("Error")..": ".. + S("Could not find the station that is to be removed.")); return; end travelnet.targets[ owner_name ][ station_network ][ station_name ] = nil; -- inform the owner - minetest.chat_send_player( owner_name, "Station '"..station_name.."' has been REMOVED from the network '"..station_network.."'."); + minetest.chat_send_player( owner_name, S("Station '%s'"):format(station_name ).." ".. + S("has been REMOVED from the network '%s'."):format(station_network)); if( digger ~= nil and owner_name ~= digger:get_player_name() ) then - minetest.chat_send_player( digger:get_player_name(), "Station '"..station_name.."' has been REMOVED from the network '"..station_network.."'."); + minetest.chat_send_player( digger:get_player_name(), S("Station '%s'"):format(station_name).. + S("has been REMOVED from the network '%s'."):format(station_network)); end -- save the updated network data in a savefile over server restart @@ -635,22 +842,22 @@ travelnet.can_dig = function( pos, player, description ) return false; end 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 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; end - local meta = minetest.get_meta( pos ); - local owner = meta:get_string('owner'); - 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, S("This %s has not been configured yet. Please set it up first to claim it. Afterwards you can remove it because you are then the owner."):format(description)); return false; elseif( owner ~= name ) then - minetest.chat_send_player(name, "This "..description.." belongs to "..tostring( meta:get_string('owner'))..". You can't remove it."); + minetest.chat_send_player(name, S("This %s belongs to %s. You can't remove it."):format(description, tostring( meta:get_string('owner')))); return false; end return true; @@ -709,4 +916,3 @@ end -- upon server start, read the savefile travelnet.restore_data(); - |