aboutsummaryrefslogtreecommitdiff
path: root/advtrains_interlocking
diff options
context:
space:
mode:
Diffstat (limited to 'advtrains_interlocking')
-rw-r--r--advtrains_interlocking/route_prog.lua15
-rw-r--r--advtrains_interlocking/route_ui.lua9
2 files changed, 20 insertions, 4 deletions
diff --git a/advtrains_interlocking/route_prog.lua b/advtrains_interlocking/route_prog.lua
index b080945..96bd211 100644
--- a/advtrains_interlocking/route_prog.lua
+++ b/advtrains_interlocking/route_prog.lua
@@ -267,6 +267,8 @@ local function finishrpform(pname)
local rp = player_rte_prog[pname]
if not rp then return end
+ rp.route.use_rscache = true
+
local form = "size[7,6]label[0.5,0.5;"..S("Finish programming route").."]"
local terminal = get_last_route_item(rp.origin, rp.route)
if terminal then
@@ -286,8 +288,8 @@ local function finishrpform(pname)
form = form .. "label[0.5,2 ;"..S("non-interlocked area").."]"
end
form = form.."field[0.8,3.5;5.2,1;name;"..S("Enter Route Name")..";]"
- form = form.."button_exit[0.5,4.5; 5,1;save;"..S("Save Route").."]"
-
+ form = form.."checkbox[0.8,4.0;use_rscache;"..S("Auto lock turnouts")..";true]"
+ form = form.."button_exit[0.5,5.0; 5,1;save;"..S("Save Route").."]"
minetest.show_formspec(pname, "at_il_routepf", form)
end
@@ -484,6 +486,13 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end
if formname == "at_il_routepf" then
+ -- if it's the checkbox that changed handle before returning (stupid checkboxes)
+ if fields.use_rscache then
+ local rp = player_rte_prog[pname]
+ if rp then
+ rp.route.use_rscache = core.is_yes(fields.use_rscache)
+ end
+ end
if not fields.save or not fields.name then return end
if fields.name == "" then
-- show form again
@@ -507,8 +516,6 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
local terminal = get_last_route_item(rp.origin, rp.route)
rp.route.terminal = terminal
rp.route.name = fields.name
- -- new routes now always use the rscache
- rp.route.use_rscache = true
table.insert(tcbs.routes, rp.route)
diff --git a/advtrains_interlocking/route_ui.lua b/advtrains_interlocking/route_ui.lua
index d1bae63..9ecc947 100644
--- a/advtrains_interlocking/route_ui.lua
+++ b/advtrains_interlocking/route_ui.lua
@@ -106,6 +106,8 @@ function atil.show_route_edit_form(pname, sigd, routeid, sel_rpartidx)
itab(i, "E (none)", "end", nil)
end
+ itab(i, S("(More Options)"), "advanced", nil)
+
if not sel_rpartidx then sel_rpartidx = 1 end
form = form.."textlist[0.5,2;3.5,3.9;routelog;"..table.concat(tab, ",")..";"..(sel_rpartidx or 1)..";false]"
@@ -153,6 +155,10 @@ function atil.show_route_edit_form(pname, sigd, routeid, sel_rpartidx)
-- checkbox for call-on
form = form..string.format("checkbox[4.5,4.0;se_callon;"..S("Call-on (section may be occupied)")..";%s]", rseg.call_on)
end
+ elseif sel_rpart and sel_rpart.advanced then
+ form = form..F.label(4.5, 2, S("Advanced Options:"))
+ -- checkbox for call-on
+ form = form..string.format("checkbox[4.5,4.0;ad_use_rscache;"..S("Auto lock turnouts")..";%s]", route.use_rscache)
elseif sel_rpart and sel_rpart.err then
form = form.."textarea[4.5,2.5;4,4;errorta;"..S("Error:")..";"..tab[sel_rpartidx].."]"
else
@@ -253,6 +259,9 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
return
end
end
+ if fields.ad_use_rscache then
+ route.use_rscache = minetest.is_yes(fields.ad_use_rscache)
+ end
--if fields.noautogen then
-- route.smartroute_generated = nil
id='n250' href='#n250'>250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276
/*
Minetest
Copyright (C) 2015-2017 paramat
Copyright (C) 2015-2016 kwolekr, Ryan Kwolek <kwolekr@minetest.net>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/


#include "mapgen.h"
#include "voxel.h"
#include "noise.h"
#include "mapblock.h"
#include "mapnode.h"
#include "map.h"
#include "content_sao.h"
#include "nodedef.h"
#include "voxelalgorithms.h"
//#include "profiler.h" // For TimeTaker
#include "settings.h" // For g_settings
#include "emerge.h"
#include "dungeongen.h"
#include "cavegen.h"
#include "mg_biome.h"
#include "mg_ore.h"
#include "mg_decoration.h"
#include "mapgen_flat.h"


FlagDesc flagdesc_mapgen_flat[] = {
	{"lakes", MGFLAT_LAKES},
	{"hills", MGFLAT_HILLS},
	{NULL,    0}
};

///////////////////////////////////////////////////////////////////////////////////////


MapgenFlat::MapgenFlat(int mapgenid, MapgenFlatParams *params, EmergeManager *emerge)
	: MapgenBasic(mapgenid, params, emerge)
{
	this->spflags          = params->spflags;
	this->ground_level     = params->ground_level;
	this->large_cave_depth = params->large_cave_depth;
	this->cave_width       = params->cave_width;
	this->lake_threshold   = params->lake_threshold;
	this->lake_steepness   = params->lake_steepness;
	this->hill_threshold   = params->hill_threshold;
	this->hill_steepness   = params->hill_steepness;

	// 2D noise
	noise_filler_depth = new Noise(&params->np_filler_depth, seed, csize.X, csize.Z);

	if ((spflags & MGFLAT_LAKES) || (spflags & MGFLAT_HILLS))
		noise_terrain = new Noise(&params->np_terrain, seed, csize.X, csize.Z);
	// 3D noise
	MapgenBasic::np_cave1 = params->np_cave1;
	MapgenBasic::np_cave2 = params->np_cave2;
}


MapgenFlat::~MapgenFlat()
{
	delete noise_filler_depth;

	if ((spflags & MGFLAT_LAKES) || (spflags & MGFLAT_HILLS))
		delete noise_terrain;
}


MapgenFlatParams::MapgenFlatParams()
{
	spflags          = 0;
	ground_level     = 8;
	large_cave_depth = -33;
	cave_width       = 0.09;
	lake_threshold   = -0.45;
	lake_steepness   = 48.0;
	hill_threshold   = 0.45;
	hill_steepness   = 64.0;

	np_terrain      = NoiseParams(0, 1,   v3f(600, 600, 600), 7244,  5, 0.6, 2.0);
	np_filler_depth = NoiseParams(0, 1.2, v3f(150, 150, 150), 261,   3, 0.7, 2.0);
	np_cave1        = NoiseParams(0, 12,  v3f(61,  61,  61),  52534, 3, 0.5, 2.0);
	np_cave2        = NoiseParams(0, 12,  v3f(67,  67,  67),  10325, 3, 0.5, 2.0);
}


void MapgenFlatParams::readParams(const Settings *settings)
{
	settings->getFlagStrNoEx("mgflat_spflags",      spflags, flagdesc_mapgen_flat);
	settings->getS16NoEx("mgflat_ground_level",     ground_level);
	settings->getS16NoEx("mgflat_large_cave_depth", large_cave_depth);
	settings->getFloatNoEx("mgflat_cave_width",     cave_width);
	settings->getFloatNoEx("mgflat_lake_threshold", lake_threshold);
	settings->getFloatNoEx("mgflat_lake_steepness", lake_steepness);
	settings->getFloatNoEx("mgflat_hill_threshold", hill_threshold);