2021-03-11 14:28:53 -08:00
local S = minetest.get_translator ( " arena_lib " )
2022-01-07 14:14:41 -08:00
local function fill_tempsky ( ) end
local function get_celvault_formspec ( ) end
local function get_sky_params ( ) end
local function get_sun_params ( ) end
local function get_moon_params ( ) end
local function get_stars_params ( ) end
local function get_clouds_params ( ) end
local function colstr ( ) end
local function get_palette_col_and_sorted_table ( ) end
local function compare_elem ( ) end
2021-03-11 14:28:53 -08:00
local temp_sky_settings = { } -- KEY = p_name; VALUE = {all the sky settings}
local sky_tools = {
" arena_lib:sky " ,
" " ,
" " ,
" " ,
" " ,
" " ,
" " ,
2022-01-07 14:14:41 -08:00
" " ,
2021-03-11 14:28:53 -08:00
" arena_lib:editor_return " ,
" arena_lib:editor_quit " ,
}
minetest.register_tool ( " arena_lib:editor_sky " , {
description = S ( " Set sky " ) ,
inventory_image = " arenalib_editor_sky.png " ,
groups = { not_in_creative_inventory = 1 , oddly_breakable_by_hand = " 2 " } ,
on_place = function ( ) end ,
on_drop = function ( ) end ,
on_use = function ( itemstack , user , pointed_thing )
local mod = user : get_meta ( ) : get_string ( " arena_lib_editor.mod " )
local arena_name = user : get_meta ( ) : get_string ( " arena_lib_editor.arena " )
local id , arena = arena_lib.get_arena_by_name ( mod , arena_name )
local p_name = user : get_player_name ( )
2022-01-07 14:14:41 -08:00
fill_tempsky ( p_name , arena )
2021-03-11 14:28:53 -08:00
2022-01-07 14:14:41 -08:00
minetest.show_formspec ( p_name , " arena_lib:settings_sky " , get_celvault_formspec ( p_name , " sky " ) )
2021-03-11 14:28:53 -08:00
end
} )
function arena_lib . give_sky_tools ( player )
player : get_inventory ( ) : set_list ( " main " , sky_tools )
end
----------------------------------------------
---------------FUNZIONI LOCALI----------------
----------------------------------------------
2022-01-07 14:14:41 -08:00
function fill_tempsky ( p_name , arena )
temp_sky_settings [ p_name ] = table.copy ( arena.celestial_vault )
2021-03-11 14:28:53 -08:00
2022-01-07 14:14:41 -08:00
if not temp_sky_settings [ p_name ] . sky then
temp_sky_settings [ p_name ] . sky = { sky_color = { } , textures = { } }
end
if not temp_sky_settings [ p_name ] . sun then
temp_sky_settings [ p_name ] . sun = { }
end
if not temp_sky_settings [ p_name ] . moon then
temp_sky_settings [ p_name ] . moon = { }
end
if not temp_sky_settings [ p_name ] . stars then
temp_sky_settings [ p_name ] . stars = { }
end
if not temp_sky_settings [ p_name ] . clouds then
temp_sky_settings [ p_name ] . clouds = { speed = { } }
end
end
2021-03-11 14:28:53 -08:00
2022-01-07 14:14:41 -08:00
function get_celvault_formspec ( p_name , section )
2021-03-11 14:28:53 -08:00
local formspec = {
" formspec_version[4] " ,
2022-01-07 14:14:41 -08:00
" size[9.72,10] " ,
2021-03-11 14:28:53 -08:00
" position[0.5,0.5] " ,
" no_prepend[] " ,
2022-01-07 14:14:41 -08:00
" style_type[image_button;border=false] " ,
2021-03-11 14:28:53 -08:00
-- bottoni
" container[1,1] " ,
2022-01-07 14:14:41 -08:00
" tooltip[sky_btn; " .. S ( " Sky " ) .. " ] " ,
" tooltip[sun_btn; " .. S ( " Sun " ) .. " ] " ,
" tooltip[moon_btn; " .. S ( " Moon " ) .. " ] " ,
" tooltip[stars_btn; " .. S ( " Stars " ) .. " ] " ,
" tooltip[clouds_btn; " .. S ( " Clouds " ) .. " ] " ,
" image_button[0,0;1,1;arenalib_sky_sky.png;sky_btn;] " ,
" image_button[1.6,0;1,1;arenalib_sky_sun.png;sun_btn;] " ,
" image_button[3.2,0;1,1;arenalib_sky_moon.png;moon_btn;] " ,
" image_button[4.8,0;1,1;arenalib_sky_stars.png;stars_btn;] " ,
" image_button[6.4,0;1,1;arenalib_sky_cloud.png;clouds_btn;] " ,
2021-03-11 14:28:53 -08:00
" container_end[] " ,
" container[1,2.2] " ,
2022-01-07 14:14:41 -08:00
-- <dove saranno i vari campi a seconda del tipo>
" button[2,6.7;1.9,0.7;reset; " .. S ( " Reset " ) .. " ] " ,
" button[4,6.7;1.9,0.7;apply; " .. S ( " Apply " ) .. " ] " ,
2021-03-11 14:28:53 -08:00
" container_end[] " ,
}
2022-01-07 14:14:41 -08:00
local fields = { }
if section == " sky " then
fields = get_sky_params ( p_name )
elseif section == " sun " then
fields = get_sun_params ( p_name )
elseif section == " moon " then
fields = get_moon_params ( p_name )
elseif section == " stars " then
fields = get_stars_params ( p_name )
else
fields = get_clouds_params ( p_name )
end
for k , v in pairs ( fields ) do
table.insert ( formspec , # formspec - 2 , v )
end
return table.concat ( formspec , " " )
end
function get_sky_params ( p_name )
local temp_sky = temp_sky_settings [ p_name ] . sky
local clouds = true
local sky_type = 1
if temp_sky.clouds ~= nil and temp_sky.clouds == false then
clouds = false
end
if temp_sky.type == " skybox " then
sky_type = 2
elseif temp_sky.type == " plain " then
sky_type = 3
end
local temp_sky_col = temp_sky.sky_color
local palette_str , palette_id = get_palette_col_and_sorted_table ( ) -- palette id KEY = hex value, VALUE = id
local sky_params = { }
local sky = {
" label[0,0.25; " .. S ( " Type " ) .. " ] " ,
" dropdown[0,0.5;3.75,0.6;sky_type;regular,skybox,plain; " .. sky_type .. " ;] " ,
" checkbox[4.2,0.78;sky_clouds; " .. S ( " Clouds " ) .. " ; " .. tostring ( clouds ) .. " ] "
}
if sky_type == 1 then
sky_params = {
" container[0,1.6] " ,
" label[0,0; " .. S ( " Day sky " ) .. " ] " ,
" dropdown[0,0.2;2.5,0.6;day_sky; " .. palette_str .. " ; " .. ( palette_id [ colstr ( temp_sky_col.day_sky ) ] or 1 ) .. " ] " ,
" label[2.6,0; " .. S ( " Dawn sky " ) .. " ] " ,
" dropdown[2.6,0.2;2.5,0.6;dawn_sky; " .. palette_str .. " ; " .. ( palette_id [ colstr ( temp_sky_col.dawn_sky ) ] or 1 ) .. " ] " ,
" label[5.2,0; " .. S ( " Night sky " ) .. " ] " ,
" dropdown[5.2,0.2;2.5,0.6;night_sky; " .. palette_str .. " ; " .. ( palette_id [ colstr ( temp_sky_col.night_sky ) ] or 1 ) .. " ] " ,
" label[0,1.05; " .. S ( " Day horizon " ) .. " ] " ,
" dropdown[0,1.25;2.5,0.6;day_horizon; " .. palette_str .. " ; " .. ( palette_id [ colstr ( temp_sky_col.day_horizon ) ] or 1 ) .. " ] " ,
" label[2.6,1.05; " .. S ( " Dawn horizon " ) .. " ] " ,
" dropdown[2.6,1.25;2.5,0.6;dawn_horizon; " .. palette_str .. " ; " .. ( palette_id [ colstr ( temp_sky_col.dawn_horizon ) ] or 1 ) .. " ] " ,
" label[5.2,1.05; " .. S ( " Night horizon " ) .. " ] " ,
" dropdown[5.2,1.25;2.5,0.6;night_horizon; " .. palette_str .. " ; " .. ( palette_id [ colstr ( temp_sky_col.night_horizon ) ] or 1 ) .. " ] " ,
" label[0,2.1; " .. S ( " Indoors " ) .. " ] " ,
" dropdown[0,2.3;2.5,0.6;indoors; " .. palette_str .. " ; " .. ( palette_id [ colstr ( temp_sky_col.indoors ) ] or 1 ) .. " ] " ,
" container_end[] " ,
" checkbox[0,5.5;custom_fog_tint; " .. S ( " Custom fog tint " ) .. " ; " .. ( temp_sky_col.fog_tint_type == " custom " and " true " or " false " ) .. " ] "
}
if temp_sky_col.fog_tint_type == " custom " then
local fog_params = {
" label[2.6,2.1; " .. S ( " Fog sun tint " ) .. " ] " ,
" dropdown[2.6,2.3;2.5,0.6;fog_sun_tint; " .. palette_str .. " ; " .. ( palette_id [ colstr ( temp_sky_col.fog_sun_tint ) ] or 1 ) .. " ] " ,
" label[5.2,2.1; " .. S ( " Fog moon tint " ) .. " ] " ,
" dropdown[5.2,2.3;2.5,0.6;fog_moon_tint; " .. palette_str .. " ; " .. ( palette_id [ colstr ( temp_sky_col.fog_moon_tint ) ] or 1 ) .. " ] "
}
for k , v in pairs ( fog_params ) do
table.insert ( sky_params , # sky_params - 3 , v )
end
end
else
sky_params = {
" container[0,4.5] " ,
" label[2.2,0.25; " .. S ( " Base colour " ) .. " ] " ,
" dropdown[2.2,0.5;3.75,0.6;base_color; " .. palette_str .. " ; " .. ( palette_id [ temp_sky.base_color ] or 1 ) .. " ] " ,
" container_end[] "
}
if sky_type == 2 then
2021-03-11 14:28:53 -08:00
local skybox = {
2022-01-07 14:14:41 -08:00
" container[0,1.6] " ,
" field[0,0;3.75,0.6;top; " .. S ( " Top " ) .. " ; " .. ( temp_sky.textures [ 1 ] or " " ) .. " ] " ,
" field[4.15,0;3.75,0.6;bottom; " .. S ( " Bottom " ) .. " ; " .. ( temp_sky.textures [ 2 ] or " " ) .. " ] " ,
" field[0,1;3.75,0.6;west; " .. S ( " West " ) .. " ; " .. ( temp_sky.textures [ 3 ] or " " ) .. " ] " ,
" field[4.15,1;3.75,0.6;east; " .. S ( " East " ) .. " ; " .. ( temp_sky.textures [ 4 ] or " " ) .. " ] " ,
" field[0,2;3.75,0.6;north; " .. S ( " North " ) .. " ; " .. ( temp_sky.textures [ 5 ] or " " ) .. " ] " ,
" field[4.15,2;3.75,0.6;south; " .. S ( " South " ) .. " ; " .. ( temp_sky.textures [ 6 ] or " " ) .. " ] " ,
2021-03-11 14:28:53 -08:00
" container_end[] " ,
}
for k , v in pairs ( skybox ) do
2022-01-07 14:14:41 -08:00
table.insert ( sky_params , # sky_params - 3 , v )
2021-03-11 14:28:53 -08:00
end
end
end
2022-01-07 14:14:41 -08:00
for k , v in pairs ( sky_params ) do
table.insert ( sky , # sky , v )
end
return sky
2021-03-11 14:28:53 -08:00
end
2022-01-07 14:14:41 -08:00
function get_sun_params ( p_name )
2021-03-11 14:28:53 -08:00
2022-01-07 14:14:41 -08:00
local temp_sun = temp_sky_settings [ p_name ] . sun
local is_sun_visible = temp_sun.visible ~= false
local is_sunrise_visible = temp_sun.sunrise_visible ~= false
2021-03-11 14:28:53 -08:00
2022-01-07 14:14:41 -08:00
local sun = {
" checkbox[0,0.78;sun_visible; " .. S ( " Visible sun " ) .. " ; " .. tostring ( is_sun_visible ) .. " ] " ,
" checkbox[4,0.78;sunrise_visible; " .. S ( " Visible sunrise " ) .. " ; " .. tostring ( is_sunrise_visible ) .. " ] " ,
" container[0,1.6] " ,
" container_end[] "
2021-03-11 14:28:53 -08:00
}
2022-01-07 14:14:41 -08:00
if is_sun_visible then
local sun_params = {
" field[0,0;3.75,0.6;sun_texture; " .. S ( " Texture " ) .. " ; " .. ( temp_sun.texture or " sun.png " ) .. " ] " ,
" field[0,1;3.75,0.6;sun_tonemap; " .. S ( " Tonemap " ) .. " ; " .. ( temp_sun.tonemap or " sun_tonemap.png " ) .. " ] " ,
" field[0,2;1,0.6;sun_size; " .. S ( " Size " ) .. " ; " .. ( temp_sun.scale or 1 ) .. " ] "
}
for k , v in pairs ( sun_params ) do
table.insert ( sun , # sun , v )
end
end
if is_sunrise_visible then
local sunrise_params = {
" field[4.15,0;3.75,0.6;sunrise_texture; " .. S ( " Sunrise texture " ) .. " ; " .. ( temp_sun.sunrise or " sunrisebg.png " ) .. " ] " ,
}
for k , v in pairs ( sunrise_params ) do
table.insert ( sun , # sun , v )
end
end
return sun
end
function get_moon_params ( p_name )
local temp_moon = temp_sky_settings [ p_name ] . moon
local is_moon_visible = temp_moon.visible ~= false
local moon = {
" checkbox[0,0.78;moon_visible; " .. S ( " Visible moon " ) .. " ; " .. tostring ( is_moon_visible ) .. " ] " ,
}
if is_moon_visible then
local moon_params = {
" container[0,1.6] " ,
" field[0,0;3.75,0.6;moon_texture; " .. S ( " Texture " ) .. " ; " .. ( temp_moon.texture or " moon.png " ) .. " ] " ,
" field[0,1;3.75,0.6;moon_tonemap; " .. S ( " Tonemap " ) .. " ; " .. ( temp_moon.tonemap or " moon_tonemap.png " ) .. " ] " ,
" field[0,2;1,0.6;moon_size; " .. S ( " Size " ) .. " ; " .. ( temp_moon.scale or 1 ) .. " ] " ,
" container_end[] "
}
for k , v in pairs ( moon_params ) do
table.insert ( moon , # moon , v )
end
end
return moon
end
function get_stars_params ( p_name )
local temp_stars = temp_sky_settings [ p_name ] . stars
local are_stars_visible = temp_stars.visible ~= false
local stars = {
" checkbox[0,0.78;stars_visible; " .. S ( " Visible stars " ) .. " ; " .. tostring ( are_stars_visible ) .. " ] " ,
}
if are_stars_visible then
local palette_str , palette_id = get_palette_col_and_sorted_table ( )
local stars_params = {
" field[6.9,0.7;1,0.6;stars_size; " .. S ( " Size " ) .. " ; " .. ( temp_stars.scale or 1 ) .. " ] " ,
" container[0,1.6] " ,
" label[0,-0.2; " .. S ( " Colour " ) .. " ] " ,
" dropdown[0,0;3.75,0.6;stars_color; " .. palette_str .. " ; " .. ( palette_id [ temp_stars.star_color ] or 1 ) .. " ] " ,
" field[4.15,0;3.75,0.6;stars_count; " .. S ( " Count " ) .. " ; " .. ( temp_stars.count or 1000 ) .. " ] " ,
" container_end[] "
}
for k , v in pairs ( stars_params ) do
table.insert ( stars , # stars , v )
end
end
return stars
end
function get_clouds_params ( p_name )
local temp_clouds = temp_sky_settings [ p_name ] . clouds
local are_clouds_visible = temp_sky_settings [ p_name ] . sky.clouds ~= false
local clouds = { }
if not are_clouds_visible then
clouds = {
" hypertext[0,0.85;7,1;name; <global size=18 font=mono halign=center color=#e6482e><b> " .. S ( " Clouds must be enabled first to change their parameters " ) .. " </b>] " ,
}
else
local palette_str , palette_id = get_palette_col_and_sorted_table ( )
clouds = {
" container[0,0.5] " ,
" label[0,0; " .. S ( " Density " ) .. " ] " ,
" label[0,0.5;0] " ,
" label[7.6,0.5;1] " ,
" scrollbaroptions[min=0;max=100;arrows=hide] " ,
" scrollbar[0.3,0.35;7.15,0.3;horizontal;clouds_density; " .. ( ( temp_clouds.density or 0.4 ) * 100 ) .. " ] " ,
" label[0,1.2; " .. S ( " Colour " ) .. " ] " ,
" dropdown[0,1.4;3.75,0.6;clouds_color; " .. palette_str .. " ; " .. ( palette_id [ temp_clouds.color ] or 1 ) .. " ] " ,
" label[4.15,1.2; " .. S ( " Ambient " ) .. " ] " ,
" dropdown[4.15,1.4;3.75,0.6;clouds_ambient; " .. palette_str .. " ; " .. ( palette_id [ temp_clouds.ambient ] or 1 ) .. " ] " ,
" label[0,2.25; " .. S ( " Thickness " ) .. " ] " ,
" field[0,2.45;1,0.6;clouds_thickness;; " .. ( temp_clouds.thickness or 16 ) .. " ] " ,
" label[1.7,2.25; " .. S ( " Height " ) .. " ] " ,
" field[1.7,2.45;1,0.6;clouds_height;; " .. ( temp_clouds.height or 120 ) .. " ] " ,
" label[4.15,2.25; " .. S ( " Speed " ) .. " ] " ,
" label[4.15,2.75;X] " ,
" field[4.45,2.45;1,0.6;clouds_speed_x;; " .. ( temp_clouds.speed . x or 0 ) .. " ] " ,
" label[5.8,2.75;Z] " ,
" field[6.1,2.45;1,0.6;clouds_speed_z;; " .. ( temp_clouds.speed . x or - 2 ) .. " ] " ,
" container_end[] "
}
end
return clouds
end
function colstr ( col )
if type ( col ) == " table " then
return minetest.rgba ( col.r , col.g , col.b )
else
return col
end
2021-03-11 14:28:53 -08:00
end
2022-01-07 14:14:41 -08:00
function get_palette_col_and_sorted_table ( )
-- inverto chiavi con valori
local inverted = { }
for k in pairs ( arena_lib.PALETTE ) do
table.insert ( inverted , k )
end
table.sort ( inverted , function ( a , b ) return a : lower ( ) < b : lower ( ) end )
local palette = " "
local palette_table = { }
local i = 1
for _ , col in pairs ( inverted ) do
palette = palette .. col .. " , "
palette_table [ arena_lib.PALETTE [ col ] ] = i
i = i + 1
end
return palette : sub ( 1 , - 2 ) , palette_table
end
function compare_elem ( t1 , t2 )
return minetest.serialize ( t1 ) == minetest.serialize ( t2 )
end
2021-03-11 14:28:53 -08:00
----------------------------------------------
---------------GESTIONE CAMPI-----------------
----------------------------------------------
minetest.register_on_player_receive_fields ( function ( player , formname , fields )
if formname ~= " arena_lib:settings_sky " then return end
local p_name = player : get_player_name ( )
2022-01-07 14:14:41 -08:00
local temp_sky = temp_sky_settings [ p_name ] . sky
local temp_sky_col = temp_sky.sky_color
local temp_sun = temp_sky_settings [ p_name ] . sun
local temp_moon = temp_sky_settings [ p_name ] . moon
local temp_stars = temp_sky_settings [ p_name ] . stars
local temp_clouds = temp_sky_settings [ p_name ] . clouds
local mod = player : get_meta ( ) : get_string ( " arena_lib_editor.mod " )
local arena_name = player : get_meta ( ) : get_string ( " arena_lib_editor.arena " )
local id , arena = arena_lib.get_arena_by_name ( mod , arena_name )
local celvault = arena.celestial_vault
-- se abbandona...
2021-03-11 14:28:53 -08:00
if fields.quit then
2022-01-07 14:14:41 -08:00
if next ( celvault ) then
if celvault.sky then player : set_sky ( celvault.sky ) end
if celvault.sun then player : set_sun ( celvault.sun ) end
if celvault.moon then player : set_moon ( celvault.moon ) end
if celvault.stars then player : set_stars ( celvault.stars ) end
if celvault.clouds then player : set_clouds ( celvault.clouds ) end
else
arena_lib.temp . reset_celestial_vault ( player )
end
2021-03-11 14:28:53 -08:00
temp_sky_settings [ p_name ] = nil
return
2022-01-07 14:14:41 -08:00
-- ...o se ripristina, non c'è bisogno di andare oltre
elseif fields.reset then
arena_lib.set_celestial_vault ( p_name , mod , arena_name , " all " , nil , true )
arena_lib.temp . reset_celestial_vault ( player )
fill_tempsky ( p_name , arena )
-- TODO: there is some Minetest related bug that doesn't allow to instantly update dropdown fields.
-- Too tired to backtrack for now and open an issue, maybe one day
minetest.close_formspec ( p_name , " arena_lib:settings_sky " )
-- riapro il formspec sul quale mi trovavo
minetest.after ( 0.1 , function ( )
if fields.day_sky then
minetest.show_formspec ( p_name , " arena_lib:settings_sky " , get_celvault_formspec ( p_name , " sky " ) )
elseif fields.sun_size then
minetest.show_formspec ( p_name , " arena_lib:settings_sky " , get_celvault_formspec ( p_name , " sun " ) )
elseif fields.moon_size then
minetest.show_formspec ( p_name , " arena_lib:settings_sky " , get_celvault_formspec ( p_name , " moon " ) )
elseif fields.stars_count then
minetest.show_formspec ( p_name , " arena_lib:settings_sky " , get_celvault_formspec ( p_name , " stars " ) )
else
minetest.show_formspec ( p_name , " arena_lib:settings_sky " , get_celvault_formspec ( p_name , " clouds " ) )
end
end )
return
end
-- se cambia sezione, non c'è bisogno di controllare il resto (dato che viene automatico cambiare
-- e poi premere "Applica")
if fields.sky_btn then
minetest.show_formspec ( p_name , " arena_lib:settings_sky " , get_celvault_formspec ( p_name , " sky " ) )
return
elseif fields.sun_btn then
minetest.show_formspec ( p_name , " arena_lib:settings_sky " , get_celvault_formspec ( p_name , " sun " ) )
return
elseif fields.moon_btn then
minetest.show_formspec ( p_name , " arena_lib:settings_sky " , get_celvault_formspec ( p_name , " moon " ) )
return
elseif fields.stars_btn then
minetest.show_formspec ( p_name , " arena_lib:settings_sky " , get_celvault_formspec ( p_name , " stars " ) )
return
elseif fields.clouds_btn then
minetest.show_formspec ( p_name , " arena_lib:settings_sky " , get_celvault_formspec ( p_name , " clouds " ) )
return
end
local palette = arena_lib.PALETTE
--
-- aggiorna i vari parametri
--
-- cielo
if fields.base_color then
temp_sky.base_color = palette [ fields.base_color ]
end
if fields.day_sky then
temp_sky_col.day_sky = palette [ fields.day_sky ]
end
if fields.day_horizon then
temp_sky_col.day_horizon = palette [ fields.day_horizon ]
end
if fields.dawn_sky then
temp_sky_col.dawn_sky = palette [ fields.dawn_sky ]
end
if fields.dawn_horizon then
temp_sky_col.dawn_horizon = palette [ fields.dawn_horizon ]
end
if fields.night_sky then
temp_sky_col.night_sky = palette [ fields.night_sky ]
end
if fields.night_horizon then
temp_sky_col.night_horizon = palette [ fields.night_horizon ]
2021-03-11 14:28:53 -08:00
end
2022-01-07 14:14:41 -08:00
if fields.indoors then
temp_sky_col.indoors = palette [ fields.indoors ]
end
if fields.fog_sun_tint then
temp_sky_col.fog_sun_tint = palette [ fields.fog_sun_tint ]
end
2021-03-11 14:28:53 -08:00
2022-01-07 14:14:41 -08:00
if fields.fog_moon_tint then
temp_sky_col.fog_moon_tint = palette [ fields.fog_moon_tint ]
2021-03-11 14:28:53 -08:00
end
2022-01-07 14:14:41 -08:00
if fields.sky_type == " skybox " and fields.top then
2021-03-11 14:28:53 -08:00
temp_sky.textures [ 1 ] = fields.top
temp_sky.textures [ 2 ] = fields.bottom
temp_sky.textures [ 3 ] = fields.west
temp_sky.textures [ 4 ] = fields.east
temp_sky.textures [ 5 ] = fields.north
temp_sky.textures [ 6 ] = fields.south
end
2022-01-07 14:14:41 -08:00
-- sole
if fields.sun_texture then
temp_sun.texture = fields.sun_texture
end
if fields.sun_tonemap then
temp_sun.tonemap = fields.sun_tonemap
end
if fields.sunrise_texture then
temp_sun.sunrise = fields.sunrise_texture
end
if fields.sun_size then
temp_sun.scale = tonumber ( fields.sun_size ) or temp_sun.scale
end
-- luna
if fields.moon_texture then
temp_moon.texture = fields.moon_texture
end
if fields.moon_tonemap then
temp_moon.tonemap = fields.moon_tonemap
end
if fields.moon_size then
temp_moon.scale = tonumber ( fields.moon_size ) or temp_moon.scale
end
-- stelle
if fields.stars_color then
temp_stars.star_color = palette [ fields.stars_color ]
end
if fields.stars_count then
temp_stars.count = tonumber ( fields.stars_count ) or temp_stars.count
end
if fields.stars_size then
temp_stars.scale = tonumber ( fields.stars_size ) or temp_stars.scale
end
-- nuvole
if fields.clouds_density then
temp_clouds.density = minetest.explode_scrollbar_event ( fields.clouds_density ) . value / 100
end
2021-03-11 14:28:53 -08:00
2022-01-07 14:14:41 -08:00
if fields.clouds_color then
temp_clouds.color = palette [ fields.clouds_color ]
2021-03-11 14:28:53 -08:00
end
2022-01-07 14:14:41 -08:00
if fields.clouds_ambient then
temp_clouds.ambient = palette [ fields.clouds_ambient ]
end
if fields.clouds_thickness then
temp_clouds.thickness = tonumber ( fields.clouds_thickness ) or temp_clouds.thickness
end
if fields.clouds_height then
temp_clouds.height = tonumber ( fields.clouds_height ) or temp_clouds.height
end
if fields.clouds_speed_x then
temp_clouds.speed . x = tonumber ( fields.clouds_speed_x ) or temp_clouds.speed . x
end
if fields.clouds_speed_z then
temp_clouds.speed . z = tonumber ( fields.clouds_speed_z ) or temp_clouds.speed . z
end
-- controlla i vari campi che aggiornano il formspec
if fields.sky_clouds then
temp_sky.clouds = fields.sky_clouds == " true " and true or false
elseif fields.custom_fog_tint then
temp_sky_col.fog_tint_type = fields.custom_fog_tint == " true " and " custom " or " default "
minetest.show_formspec ( p_name , " arena_lib:settings_sky " , get_celvault_formspec ( p_name , " sky " ) )
elseif fields.sky_type then
temp_sky.type = fields.sky_type
minetest.show_formspec ( p_name , " arena_lib:settings_sky " , get_celvault_formspec ( p_name , " sky " ) )
elseif fields.sun_visible then
temp_sun.visible = fields.sun_visible == " true " and true or false
minetest.show_formspec ( p_name , " arena_lib:settings_sky " , get_celvault_formspec ( p_name , " sun " ) )
elseif fields.sunrise_visible then
temp_sun.sunrise_visible = fields.sunrise_visible == " true " and true or false
minetest.show_formspec ( p_name , " arena_lib:settings_sky " , get_celvault_formspec ( p_name , " sun " ) )
elseif fields.moon_visible then
temp_moon.visible = fields.moon_visible == " true " and true or false
minetest.show_formspec ( p_name , " arena_lib:settings_sky " , get_celvault_formspec ( p_name , " moon " ) )
elseif fields.stars_visible then
temp_stars.visible = fields.stars_visible == " true " and true or false
minetest.show_formspec ( p_name , " arena_lib:settings_sky " , get_celvault_formspec ( p_name , " stars " ) )
end
-- applica
if fields.apply then
local same_sky = compare_elem ( arena.celestial_vault . sky or { textures = { } , sky_color = { } } , temp_sky_settings [ p_name ] . sky )
local same_sun = compare_elem ( arena.celestial_vault . sun or { } , temp_sky_settings [ p_name ] . sun )
local same_moon = compare_elem ( arena.celestial_vault . moon or { } , temp_sky_settings [ p_name ] . moon )
local same_stars = compare_elem ( arena.celestial_vault . stars or { } , temp_sky_settings [ p_name ] . stars )
local same_clouds = compare_elem ( arena.celestial_vault . clouds or { speed = { } } , temp_sky_settings [ p_name ] . clouds )
if not same_sky then arena_lib.set_celestial_vault ( p_name , mod , arena_name , " sky " , temp_sky_settings [ p_name ] . sky , true ) end
if not same_sun then arena_lib.set_celestial_vault ( p_name , mod , arena_name , " sun " , temp_sky_settings [ p_name ] . sun , true ) end
if not same_moon then arena_lib.set_celestial_vault ( p_name , mod , arena_name , " moon " , temp_sky_settings [ p_name ] . moon , true ) end
if not same_stars then arena_lib.set_celestial_vault ( p_name , mod , arena_name , " stars " , temp_sky_settings [ p_name ] . stars , true ) end
if not same_clouds then arena_lib.set_celestial_vault ( p_name , mod , arena_name , " clouds " , temp_sky_settings [ p_name ] . clouds , true ) end
end
player : set_sky ( temp_sky )
player : set_sun ( temp_sun )
player : set_moon ( temp_moon )
player : set_stars ( temp_stars )
player : set_clouds ( temp_clouds )
2021-03-11 14:28:53 -08:00
end )