Add np settings to profile list
This commit is contained in:
parent
08a460c1e2
commit
0264774553
30
init.lua
30
init.lua
@ -53,7 +53,19 @@ local current_perlin = {}
|
||||
-- holds the current PerlinNoise object
|
||||
current_perlin.noise = nil
|
||||
current_perlin.noiseparams = table.copy(default_noiseparams)
|
||||
table.insert(np_profiles, current_perlin.noiseparams)
|
||||
|
||||
local noise_settings = dofile(minetest.get_modpath(minetest.get_current_modname()).."/noise_settings_list.lua")
|
||||
|
||||
for n=1, #noise_settings do
|
||||
local np = minetest.get_mapgen_setting_noiseparams(noise_settings[n])
|
||||
-- TODO/FIXME: Make sure that ALL noise settings are gettable (not just those of the active mapgen)
|
||||
if np then
|
||||
table.insert(np_profiles, {noiseparams=np, name=noise_settings[n], can_delete=false})
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(np_profiles, {noiseparams=current_perlin.noiseparams})
|
||||
|
||||
-- Side length of calculated perlin area
|
||||
current_perlin.size = 64
|
||||
-- Theoretical min and max values for Perlin noise (for colorization)
|
||||
@ -718,8 +730,15 @@ local show_noise_formspec = function(player, noiseparams, profile_id)
|
||||
local absvalue = tostring(flags_table.absvalue)
|
||||
|
||||
local noiseparams_list = {}
|
||||
local counter = 1
|
||||
for i=1, #np_profiles do
|
||||
table.insert(noiseparams_list, S("Profile @1", i))
|
||||
local npp = np_profiles[i]
|
||||
local name = npp.name
|
||||
if not name then
|
||||
name = S("Profile @1", counter)
|
||||
counter = counter + 1
|
||||
end
|
||||
table.insert(noiseparams_list, F(name))
|
||||
end
|
||||
local noiseparams_list_str = table.concat(noiseparams_list, ",")
|
||||
|
||||
@ -763,7 +782,7 @@ local show_noise_formspec = function(player, noiseparams, profile_id)
|
||||
box[0,0;9.5,0.4;]]..FORMSPEC_HEADER_COLOR..[[]
|
||||
label[0.15,0.2;]]..F(S("Noise parameters"))..[[]
|
||||
container[0.0,0.5]
|
||||
dropdown[0.25,0;2,0.5;np_profiles;]]..noiseparams_list_str..[[;]]..profile_id..[[;true]
|
||||
dropdown[0.25,0;3,0.5;np_profiles;]]..noiseparams_list_str..[[;]]..profile_id..[[;true]
|
||||
button[3.25,0;2.0,0.5;add_np_profile;]]..F(S("Add"))..[[]
|
||||
button[5.25,0;2.0,0.5;load_np_profile;]]..F(S("Load"))..[[]
|
||||
]]..delete_btn..[[
|
||||
@ -881,6 +900,9 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
return
|
||||
end
|
||||
local profile_to_delete = tonumber(fields.np_profiles)
|
||||
if np_profiles[profile_to_delete].can_delete == false then
|
||||
return
|
||||
end
|
||||
table.remove(np_profiles, profile_to_delete)
|
||||
local new_id = math.max(1, profile_to_delete - 1)
|
||||
show_noise_formspec(player, default_noiseparams, new_id)
|
||||
@ -943,7 +965,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
-- Change NP profile selection
|
||||
elseif fields.load_np_profile and fields.np_profiles then
|
||||
local profile = tonumber(fields.np_profiles)
|
||||
local loaded_np = np_profiles[profile]
|
||||
local loaded_np = np_profiles[profile].noiseparams
|
||||
-- Load new profile
|
||||
show_noise_formspec(player, loaded_np, profile)
|
||||
minetest.log("action", "[perlin_explorer] Loaded perlin noise profile "..profile)
|
||||
|
51
noise_settings_list.lua
Normal file
51
noise_settings_list.lua
Normal file
@ -0,0 +1,51 @@
|
||||
-- List of all known noiseparameter settings in Minetest (version 5.5.0)
|
||||
return {
|
||||
"mg_biome_np_heat",
|
||||
"mg_biome_np_heat_blend",
|
||||
"mg_biome_np_humidity",
|
||||
"mg_biome_np_humidity_blend",
|
||||
"mgv5_np_filler_depth",
|
||||
"mgv5_np_factor",
|
||||
"mgv5_np_height",
|
||||
"mgv5_np_cave1",
|
||||
"mgv5_np_cave2",
|
||||
"mgv5_np_cavern",
|
||||
"mgv5_np_ground",
|
||||
"mgv5_np_dungeons",
|
||||
"mgv6_np_terrain_base",
|
||||
"mgv6_np_terrain_higher",
|
||||
"mgv6_np_steepness",
|
||||
"mgv6_np_height_select",
|
||||
"mgv6_np_mud",
|
||||
"mgv6_np_beach",
|
||||
"mgv6_np_biome",
|
||||
"mgv6_np_cave",
|
||||
"mgv6_np_humidity",
|
||||
"mgv6_np_trees",
|
||||
"mgv6_np_apple_trees",
|
||||
"mgv7_np_terrain_base",
|
||||
"mgv7_np_terrain_alt",
|
||||
"mgv7_np_persist",
|
||||
"mgv7_np_height_select",
|
||||
"mgv7_np_filler_depth",
|
||||
"mgv7_np_mount_height",
|
||||
"mgv7_np_ridge_uwater",
|
||||
"mgv7_np_mountain",
|
||||
"mgv7_np_ridge",
|
||||
"mgv7_np_floatland",
|
||||
"mgv7_np_cavern",
|
||||
"mgv7_np_cave1",
|
||||
"mgv7_np_cave2",
|
||||
"mgv7_np_dungeon",
|
||||
"mgcarpathian_np_filler_depth",
|
||||
"mgcarpathian_np_height1",
|
||||
"mgcarpathian_np_height2",
|
||||
"mgcarpathian_np_height3",
|
||||
"mgcarpathian_np_height4",
|
||||
"mgcarpathian_np_hills_terrain",
|
||||
"mgcarpathian_np_ridge_terrain",
|
||||
"mgcarpathian_np_step_terrain",
|
||||
"mgcarpathian_np_hills",
|
||||
"mgcarpathian_np_ridge_mnt",
|
||||
"mgcarpathian_np_step_mnt",
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user