added optional self-healing feature via abm in case of loss of savedata; version switched to 2.2
This commit is contained in:
parent
316ffff896
commit
fae093dfad
@ -15,6 +15,8 @@ travelnet.elevator_enabled = true;
|
||||
-- if you set this to false, doors will be disabled
|
||||
travelnet.doors_enabled = true;
|
||||
|
||||
-- starts an abm which re-adds travelnet stations to networks in case the savefile got lost
|
||||
travelnet.abm_enabled = false;
|
||||
|
||||
-- change these if you want other receipes for travelnet or elevator
|
||||
travelnet.travelnet_recipe = {
|
||||
|
20
init.lua
20
init.lua
@ -17,11 +17,15 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Version: 2.1 (with config file)
|
||||
Version: 2.2 (with optional abm for self-healing)
|
||||
|
||||
Please configure this mod in config.lua
|
||||
|
||||
Changelog:
|
||||
05.11.14 - Added an optional abm so that the travelnet network can heal itshelf in case of loss of the savefile.
|
||||
If you want to use this, set
|
||||
travelnet.enable_abm = true
|
||||
in config.lua and edit the interval in the abm to suit your needs.
|
||||
19.11.13 - moved doors and travelnet definition into an extra file
|
||||
- moved configuration to config.lua
|
||||
05.08.13 - fixed possible crash when the node in front of the travelnet is unknown
|
||||
@ -463,11 +467,17 @@ travelnet.on_receive_fields = function(pos, formname, fields, player)
|
||||
or not( travelnet.targets[ owner_name ][ station_network ] )) then
|
||||
|
||||
|
||||
minetest.chat_send_player(name, "Error: There is something wrong with the configuration of this station. "..
|
||||
if( owner_name
|
||||
and station_name
|
||||
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. "..
|
||||
" DEBUG DATA: owner: "..( owner_name or "?")..
|
||||
" station_name: "..(station_name or "?")..
|
||||
" station_network: "..(station_network or "?")..".");
|
||||
return
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local this_node = minetest.env:get_node( pos );
|
||||
@ -664,6 +674,10 @@ if( travelnet.doors_enabled ) then
|
||||
dofile(minetest.get_modpath("travelnet").."/doors.lua"); -- doors that open and close automaticly when the travelnet or elevator is used
|
||||
end
|
||||
|
||||
if( travelnet.abm_enabled ) then
|
||||
dofile(minetest.get_modpath("travelnet").."/restore_network_via_abm.lua"); -- restore travelnet data when players pass by broken networks
|
||||
end
|
||||
|
||||
-- upon server start, read the savefile
|
||||
travelnet.restore_data();
|
||||
|
||||
|
24
restore_network_via_abm.lua
Normal file
24
restore_network_via_abm.lua
Normal file
@ -0,0 +1,24 @@
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"travelnet:travelnet"},
|
||||
interval = 20,
|
||||
chance = 1,
|
||||
action = function(pos, node)
|
||||
local meta = minetest.get_meta( pos );
|
||||
|
||||
local owner_name = meta:get_string( "owner" );
|
||||
local station_name = meta:get_string( "station_name" );
|
||||
local station_network = meta:get_string( "station_network" );
|
||||
|
||||
if( owner_name and station_name and station_network
|
||||
and ( not( travelnet.targets )
|
||||
or not( travelnet.targets[ owner_name ] )
|
||||
or not( travelnet.targets[ owner_name ][ station_network ] )
|
||||
or not( travelnet.targets[ owner_name ][ station_network ][ station_name ] ))) then
|
||||
|
||||
travelnet.add_target( station_name, station_network, pos, owner_name, meta, owner_name );
|
||||
print( 'TRAVELNET: re-adding '..tostring( station_name )..' to '..tostring( station_network )..' owned by '..tostring( owner_name ));
|
||||
end
|
||||
end
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user