remove noise functions from atmos, snowdrift and hudinfo, and refactor
This commit is contained in:
parent
14e75ef756
commit
01b78c053c
Binary file not shown.
Before Width: | Height: | Size: 607 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.6 MiB |
Binary file not shown.
Before Width: | Height: | Size: 3.1 MiB |
Binary file not shown.
Before Width: | Height: | Size: 2.9 MiB |
Binary file not shown.
Before Width: | Height: | Size: 6.9 MiB |
Binary file not shown.
Before Width: | Height: | Size: 3.6 MiB |
@ -1,3 +1,4 @@
|
||||
lightning
|
||||
hudclock
|
||||
hudbars
|
||||
core
|
@ -403,27 +403,6 @@ minetest.register_on_joinplayer(function(player)
|
||||
|
||||
end)
|
||||
|
||||
local np_temp = {
|
||||
offset = 50,
|
||||
scale = 50,
|
||||
spread = {x = 1000, y = 1000, z = 1000},
|
||||
seed = 5349,
|
||||
octaves = 3,
|
||||
persist = 0.5,
|
||||
lacunarity = 2.0,
|
||||
--flags = ""
|
||||
}
|
||||
|
||||
local np_humid = {
|
||||
offset = 50,
|
||||
scale = 50,
|
||||
spread = {x = 1000, y = 1000, z = 1000},
|
||||
seed = 842,
|
||||
octaves = 3,
|
||||
persist = 0.5,
|
||||
lacunarity = 2.0,
|
||||
--flags = ""
|
||||
}
|
||||
|
||||
local function local_area_stamina()
|
||||
|
||||
@ -433,83 +412,8 @@ local function local_area_stamina()
|
||||
|
||||
else
|
||||
|
||||
local pos = player:get_pos()
|
||||
|
||||
local pposx = math.floor(pos.x)
|
||||
local pposz = math.floor(pos.z)
|
||||
|
||||
local nobj_temp = minetest.get_perlin(np_temp) -- paramats black magic
|
||||
local nobj_humid = minetest.get_perlin(np_humid)
|
||||
|
||||
local nval_temp = nobj_temp:get2d({x = pposx, y = pposz}) -- more noisy black magic
|
||||
local nval_humid = nobj_humid:get2d({x = pposx, y = pposz})
|
||||
|
||||
if nval_humid > 100 then -- we cap it from going over 100%
|
||||
nval_humid = 100
|
||||
elseif nval_humid < 0 then -- this includes going under 0%
|
||||
nval_humid = 0
|
||||
end
|
||||
|
||||
nval_temp = ((nval_temp / 2) - 12) + (nval_humid * 0.02) -- calculate the temparature based on local area and humidity
|
||||
|
||||
if hudclock.month == 1 then -- todo turn this into a mcore function
|
||||
nval_temp = nval_temp - 20
|
||||
elseif hudclock.month == 2 then
|
||||
nval_temp = nval_temp - 15
|
||||
elseif hudclock.month == 3 then
|
||||
nval_temp = nval_temp - 10
|
||||
elseif hudclock.month == 4 then
|
||||
nval_temp = nval_temp - 5
|
||||
elseif hudclock.month == 5 then
|
||||
nval_temp = nval_temp + 0
|
||||
elseif hudclock.month == 6 then
|
||||
nval_temp = nval_temp + 5
|
||||
elseif hudclock.month == 7 then
|
||||
nval_temp = nval_temp + 5
|
||||
elseif hudclock.month == 8 then
|
||||
nval_temp = nval_temp + 0
|
||||
elseif hudclock.month == 9 then
|
||||
nval_temp = nval_temp - 5
|
||||
elseif hudclock.month == 10 then
|
||||
nval_temp = nval_temp - 10
|
||||
elseif hudclock.month == 11 then
|
||||
nval_temp = nval_temp - 15
|
||||
elseif hudclock.month == 12 then
|
||||
nval_temp = nval_temp - 20
|
||||
end
|
||||
|
||||
-- for every 1 block 0.001c is added to the temparature gauge. any lower than -15km and heat will always be above
|
||||
-- local temparature plus 1000C
|
||||
-- for low orbit and higher, -271C is used.
|
||||
|
||||
local y = math.abs(pos.y) * 0.001
|
||||
|
||||
if pos.y < 1 then -- we do this because going over the two altitudes will add the height values on to it,
|
||||
-- as i'm not sure if uh, temps below -271C exist in this world.
|
||||
|
||||
nval_temp = nval_temp + y
|
||||
|
||||
else
|
||||
|
||||
nval_temp = nval_temp - y
|
||||
|
||||
end
|
||||
|
||||
if pos.y >= 10000 then
|
||||
|
||||
nval_temp = -271
|
||||
|
||||
nval_humid = 0
|
||||
|
||||
end
|
||||
|
||||
if pos.y < -14999 then
|
||||
|
||||
nval_humid = 0
|
||||
|
||||
nval_temp = nval_temp + 1000
|
||||
|
||||
end
|
||||
local heat, humid, latch = mcore.get_heat_humidity(player)
|
||||
|
||||
-- if the local temp is more than -15 C then decrement frostbite every now and then, if the heatstroke bar is not at 100,
|
||||
-- then start replenishing it
|
||||
@ -523,7 +427,7 @@ local function local_area_stamina()
|
||||
local frosty = meta:get_int("frostbite") -- nice combo into uppercut, just wait for the kahn.
|
||||
local toasty = meta:get_int("overheat")
|
||||
|
||||
if nval_temp < -15 then -- do frostbite bar
|
||||
if heat < -15 then -- do frostbite bar
|
||||
|
||||
if toasty > 0 then
|
||||
|
||||
@ -535,7 +439,7 @@ local function local_area_stamina()
|
||||
|
||||
end
|
||||
|
||||
elseif nval_temp > 35 then -- do the overheat bar
|
||||
elseif heat > 35 then -- do the overheat bar
|
||||
|
||||
if frosty > 0 then
|
||||
|
||||
|
1
mods/core/depends.txt
Normal file
1
mods/core/depends.txt
Normal file
@ -0,0 +1 @@
|
||||
hudclock?
|
@ -447,6 +447,135 @@ function mcore.rotate_axis(itemstack, placer, pointed_thing)
|
||||
return itemstack
|
||||
end
|
||||
|
||||
-- default noise controls:
|
||||
|
||||
local np_temp = {
|
||||
offset = 50,
|
||||
scale = 50,
|
||||
spread = {x = 1000, y = 1000, z = 1000},
|
||||
seed = 5349,
|
||||
octaves = 3,
|
||||
persist = 0.5,
|
||||
lacunarity = 2.0,
|
||||
--flags = ""
|
||||
}
|
||||
|
||||
local np_humid = {
|
||||
offset = 50,
|
||||
scale = 50,
|
||||
spread = {x = 1000, y = 1000, z = 1000},
|
||||
seed = 842,
|
||||
octaves = 3,
|
||||
persist = 0.5,
|
||||
lacunarity = 2.0,
|
||||
--flags = ""
|
||||
}
|
||||
|
||||
function mcore.get_heat_humidity(player)
|
||||
|
||||
-- let's get a temparature reading for the local area.
|
||||
|
||||
local pos = player:get_pos()
|
||||
|
||||
local pposx = math.floor(pos.x)
|
||||
local pposz = math.floor(pos.z)
|
||||
|
||||
local nobj_temp = nobj_temp or minetest.get_perlin(np_temp)
|
||||
local nobj_humid = nobj_humid or minetest.get_perlin(np_humid)
|
||||
|
||||
local nval_temp = nobj_temp:get2d({x = pposx, y = pposz})
|
||||
local nval_humid = nobj_humid:get2d({x = pposx, y = pposz})
|
||||
|
||||
local latch = false
|
||||
|
||||
if nval_humid > 100 then
|
||||
|
||||
nval_humid = 100
|
||||
|
||||
elseif nval_humid < 0 then
|
||||
|
||||
nval_humid = 0
|
||||
|
||||
end
|
||||
|
||||
nval_humid = math.floor(100 * (nval_humid/100))
|
||||
|
||||
nval_temp = math.floor(45 * (nval_temp/100)) + (nval_humid * 0.02)
|
||||
|
||||
if hudclock.month == 1 then
|
||||
nval_temp = nval_temp - 20
|
||||
elseif hudclock.month == 2 then
|
||||
nval_temp = nval_temp - 15
|
||||
elseif hudclock.month == 3 then
|
||||
nval_temp = nval_temp - 10
|
||||
elseif hudclock.month == 4 then
|
||||
nval_temp = nval_temp - 5
|
||||
elseif hudclock.month == 5 then
|
||||
nval_temp = nval_temp + 0
|
||||
elseif hudclock.month == 6 then
|
||||
nval_temp = nval_temp + 5
|
||||
elseif hudclock.month == 7 then
|
||||
nval_temp = nval_temp + 5
|
||||
elseif hudclock.month == 8 then
|
||||
nval_temp = nval_temp + 0
|
||||
elseif hudclock.month == 9 then
|
||||
nval_temp = nval_temp - 5
|
||||
elseif hudclock.month == 10 then
|
||||
nval_temp = nval_temp - 10
|
||||
elseif hudclock.month == 11 then
|
||||
nval_temp = nval_temp - 15
|
||||
elseif hudclock.month == 12 then
|
||||
nval_temp = nval_temp - 20
|
||||
end
|
||||
|
||||
local y = math.abs(pos.y) / 50000
|
||||
|
||||
-- altitude changes heat and humidity
|
||||
|
||||
if pos.y < 0.5 then -- heading into the underground increases heat
|
||||
|
||||
nval_temp = nval_temp + (10000 * y)
|
||||
|
||||
else -- going into the atmosphere reduces heat
|
||||
|
||||
nval_temp = nval_temp + (-1556 * y)
|
||||
|
||||
end
|
||||
|
||||
nval_humid = nval_humid + (-600 * y)
|
||||
|
||||
if nval_temp < -271 then
|
||||
|
||||
nval_temp = -271
|
||||
nval_humid = 0
|
||||
|
||||
elseif nval_temp > 3000 then
|
||||
|
||||
nval_temp = 3000
|
||||
nval_humid = 0
|
||||
|
||||
end
|
||||
|
||||
if nval_humid > 100 then
|
||||
|
||||
nval_humid = 100
|
||||
|
||||
elseif nval_humid < 0 then
|
||||
|
||||
nval_humid = 0
|
||||
|
||||
end
|
||||
|
||||
if nval_temp <= 4 then
|
||||
|
||||
latch = true
|
||||
|
||||
end
|
||||
|
||||
return nval_temp, nval_humid, latch
|
||||
|
||||
end
|
||||
|
||||
-- dofiles for loading files required by "core"
|
||||
dofile(minetest.get_modpath("core").."/abm_timer.lua")
|
||||
dofile(minetest.get_modpath("core").."/sounds.lua")
|
||||
|
@ -697,6 +697,27 @@ minetest.register_biome({
|
||||
|
||||
})
|
||||
|
||||
minetest.register_biome({
|
||||
|
||||
name = "highlands",
|
||||
|
||||
node_top = "core:grass",
|
||||
depth_top = 1,
|
||||
|
||||
node_filler = "core:dirt",
|
||||
depth_filler = 3,
|
||||
|
||||
y_min = 1,
|
||||
y_max = 120,
|
||||
|
||||
node_water = "core:water_source",
|
||||
node_river_water = "core:water_source",
|
||||
|
||||
heat_point = 50,
|
||||
humidity_point = 25,
|
||||
|
||||
})
|
||||
|
||||
minetest.register_biome({
|
||||
|
||||
name = "plains_forest",
|
||||
@ -713,8 +734,8 @@ minetest.register_biome({
|
||||
node_water = "core:water_source",
|
||||
node_river_water = "core:water_source",
|
||||
|
||||
heat_point = 40,
|
||||
humidity_point = 55,
|
||||
heat_point = 50,
|
||||
humidity_point = 75,
|
||||
|
||||
})
|
||||
|
||||
@ -734,8 +755,8 @@ minetest.register_biome({
|
||||
node_water = "core:water_source",
|
||||
node_river_water = "core:water_source",
|
||||
|
||||
heat_point = 60,
|
||||
humidity_point = 75,
|
||||
heat_point = 85,
|
||||
humidity_point = 50,
|
||||
|
||||
})
|
||||
|
||||
@ -756,8 +777,29 @@ minetest.register_biome({
|
||||
node_water = "core:water_source",
|
||||
node_river_water = "core:water_source",
|
||||
|
||||
heat_point = 45,
|
||||
humidity_point = 45,
|
||||
heat_point = 50,
|
||||
humidity_point = 50,
|
||||
|
||||
})
|
||||
|
||||
minetest.register_biome({
|
||||
|
||||
name = "gravel_beach",
|
||||
|
||||
node_top = "core:gravel",
|
||||
depth_top = 1,
|
||||
|
||||
node_filler = "core:gravel",
|
||||
depth_filler = 3,
|
||||
|
||||
y_min = 0,
|
||||
y_max = 4,
|
||||
|
||||
node_water = "core:water_source",
|
||||
node_river_water = "core:water_source",
|
||||
|
||||
heat_point = 50,
|
||||
humidity_point = 25,
|
||||
|
||||
})
|
||||
|
||||
@ -782,8 +824,8 @@ minetest.register_biome({
|
||||
node_water_top = "core:ice",
|
||||
depth_water_top = 1,
|
||||
|
||||
heat_point = 10,
|
||||
humidity_point = 55,
|
||||
heat_point = 15,
|
||||
humidity_point = 50,
|
||||
|
||||
})
|
||||
|
||||
@ -808,8 +850,8 @@ minetest.register_biome({
|
||||
y_min = 4,
|
||||
y_max = 150,
|
||||
|
||||
heat_point = 10,
|
||||
humidity_point = 55,
|
||||
heat_point = 15,
|
||||
humidity_point = 50,
|
||||
|
||||
})
|
||||
|
||||
@ -857,7 +899,7 @@ minetest.register_biome({
|
||||
node_water_top = "core:ice",
|
||||
depth_water_top = 1,
|
||||
|
||||
heat_point = 25,
|
||||
heat_point = 15,
|
||||
humidity_point = 75,
|
||||
|
||||
})
|
||||
@ -882,11 +924,13 @@ minetest.register_biome({
|
||||
y_min = 4,
|
||||
y_max = 1000,
|
||||
|
||||
heat_point = 75,
|
||||
heat_point = 85,
|
||||
humidity_point = 25,
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
minetest.register_biome({
|
||||
|
||||
name = "hot_beach",
|
||||
@ -903,34 +947,34 @@ minetest.register_biome({
|
||||
y_min = 0,
|
||||
y_max = 4,
|
||||
|
||||
heat_point = 75,
|
||||
humidity_point = 25,
|
||||
heat_point = 85,
|
||||
humidity_point = 50,
|
||||
|
||||
})
|
||||
|
||||
minetest.register_biome({
|
||||
|
||||
name = "desert_cacti_forest",
|
||||
name = "jungle",
|
||||
|
||||
node_top = "core:sand",
|
||||
node_top = "core:grass",
|
||||
depth_top = 1,
|
||||
|
||||
node_filler = "core:sandstone",
|
||||
node_filler = "core:dirt",
|
||||
depth_filler = 3,
|
||||
|
||||
node_water = "core:water_source",
|
||||
node_river_water = "core:water_source",
|
||||
|
||||
y_min = 4,
|
||||
y_max = 120,
|
||||
|
||||
node_stone = "core:sandstone",
|
||||
node_water = "core:water_source",
|
||||
node_river_water = "core:water_source",
|
||||
|
||||
heat_point = 75,
|
||||
humidity_point = 25,
|
||||
heat_point = 85,
|
||||
humidity_point = 75,
|
||||
|
||||
})
|
||||
|
||||
-- ocean
|
||||
|
||||
minetest.register_biome({
|
||||
name = "ocean",
|
||||
|
||||
@ -957,17 +1001,27 @@ minetest.register_decoration({
|
||||
place_on = "core:grass_snow",
|
||||
decoration = {"core:mg_pine_snowy_sapling"},
|
||||
sidelen = 16,
|
||||
fill_ratio = 0.01,
|
||||
fill_ratio = 0.02,
|
||||
biomes = {"snowy_forest"},
|
||||
height = 1,
|
||||
})
|
||||
|
||||
minetest.register_decoration({
|
||||
deco_type = "simple",
|
||||
place_on = "core:grass",
|
||||
decoration = {"core:mg_pine_sapling"},
|
||||
sidelen = 16,
|
||||
fill_ratio = 0.025,
|
||||
biomes = {"highlands"},
|
||||
height = 1,
|
||||
})
|
||||
|
||||
minetest.register_decoration({
|
||||
deco_type = "simple",
|
||||
place_on = "core:grass",
|
||||
decoration = {"core:mg_oak_sapling"},
|
||||
sidelen = 16,
|
||||
fill_ratio = 0.009,
|
||||
fill_ratio = 0.01,
|
||||
biomes = {"plains_forest"},
|
||||
height = 1,
|
||||
})
|
||||
@ -977,7 +1031,7 @@ minetest.register_decoration({
|
||||
place_on = "core:grass",
|
||||
decoration = {"core:mg_birch_sapling"},
|
||||
sidelen = 16,
|
||||
fill_ratio = 0.007,
|
||||
fill_ratio = 0.006,
|
||||
biomes = {"plains_forest"},
|
||||
height = 1,
|
||||
})
|
||||
@ -987,7 +1041,7 @@ minetest.register_decoration({
|
||||
place_on = "core:grass",
|
||||
decoration = {"core:mg_cherry_sapling"},
|
||||
sidelen = 16,
|
||||
fill_ratio = 0.001,
|
||||
fill_ratio = 0.003,
|
||||
biomes = {"plains_forest"},
|
||||
height = 1,
|
||||
})
|
||||
@ -1008,7 +1062,7 @@ minetest.register_decoration({
|
||||
decoration = {"core:grass_1", "core:grass_2", "core:grass_3"},
|
||||
sidelen = 16,
|
||||
fill_ratio = 0.2,
|
||||
biomes = {"plains", "plains_forest", "plains_floral"},
|
||||
biomes = {"plains", "plains_forest", "plains_floral", "jungle"},
|
||||
height = 1,
|
||||
param2 = mcore.options("cross", true, true, false),
|
||||
})
|
||||
@ -1054,7 +1108,7 @@ minetest.register_decoration({
|
||||
decoration = {"core:cactus"},
|
||||
sidelen = 20,
|
||||
fill_ratio = 0.0004,
|
||||
biomes = {"desert", "desert_cacti_forest"},
|
||||
biomes = {"desert"},
|
||||
height = 3,
|
||||
y_max = 4,
|
||||
})
|
||||
|
@ -1,2 +1,3 @@
|
||||
atmos
|
||||
hudclock
|
||||
hudclock
|
||||
core
|
@ -4,33 +4,6 @@ hudinfo = {} -- namespaces;
|
||||
|
||||
hudinfo.player_data = {}
|
||||
|
||||
-- paramat's snowdrift to get mapgen heat and humidity since get_heat() doesn't work?
|
||||
|
||||
local np_temp = {
|
||||
offset = 50,
|
||||
scale = 50,
|
||||
spread = {x = 1000, y = 1000, z = 1000},
|
||||
seed = 5349,
|
||||
octaves = 3,
|
||||
persist = 0.5,
|
||||
lacunarity = 2.0,
|
||||
--flags = ""
|
||||
}
|
||||
|
||||
local np_humid = {
|
||||
offset = 50,
|
||||
scale = 50,
|
||||
spread = {x = 1000, y = 1000, z = 1000},
|
||||
seed = 842,
|
||||
octaves = 3,
|
||||
persist = 0.5,
|
||||
lacunarity = 2.0,
|
||||
--flags = ""
|
||||
}
|
||||
|
||||
local nobj_temp = nil
|
||||
local nobj_humid = nil
|
||||
|
||||
function hudinfo.player_env_data(player)
|
||||
|
||||
local pos = player:get_pos()
|
||||
@ -51,7 +24,7 @@ function hudinfo.player_env_data(player)
|
||||
|
||||
locale = "Eterra Surface,"
|
||||
|
||||
elseif pos.y >= 10000 and pos.y < 26000 then
|
||||
elseif pos.y >= 12000 and pos.y < 26000 then
|
||||
|
||||
locale = "Eterra Orbit,"
|
||||
|
||||
@ -68,108 +41,12 @@ function hudinfo.player_env_data(player)
|
||||
locale = "Aetherus."
|
||||
|
||||
end
|
||||
|
||||
-- let's get a temparature reading for the local area.
|
||||
|
||||
--[[
|
||||
|
||||
some notes on temparature scaling in Solar Plains:
|
||||
|
||||
temparature grading goes from 10 (-25C) to 75 (40C) 50 sits at a cool 20C
|
||||
|
||||
humidity modifies the actual "feel" of the temparature.
|
||||
|
||||
20 + (50 * 0.02) = 21
|
||||
|
||||
]]--
|
||||
|
||||
local pposx = math.floor(pos.x)
|
||||
local pposz = math.floor(pos.z)
|
||||
|
||||
local nobj_temp = nobj_temp or minetest.get_perlin(np_temp)
|
||||
local nobj_humid = nobj_humid or minetest.get_perlin(np_humid)
|
||||
|
||||
local nval_temp = nobj_temp:get2d({x = pposx, y = pposz})
|
||||
local nval_humid = nobj_humid:get2d({x = pposx, y = pposz})
|
||||
|
||||
local latch = false
|
||||
|
||||
if nval_temp <= 40.5 then
|
||||
|
||||
latch = true
|
||||
|
||||
end
|
||||
|
||||
if nval_humid > 100 then
|
||||
|
||||
nval_humid = 100
|
||||
|
||||
elseif nval_humid < 0 then
|
||||
|
||||
nval_humid = 0
|
||||
|
||||
end
|
||||
|
||||
nval_temp = ((nval_temp / 2) - 12) + (nval_humid * 0.02)
|
||||
|
||||
if hudclock.month == 1 then
|
||||
nval_temp = nval_temp - 20
|
||||
elseif hudclock.month == 2 then
|
||||
nval_temp = nval_temp - 15
|
||||
elseif hudclock.month == 3 then
|
||||
nval_temp = nval_temp - 10
|
||||
elseif hudclock.month == 4 then
|
||||
nval_temp = nval_temp - 5
|
||||
elseif hudclock.month == 5 then
|
||||
nval_temp = nval_temp + 0
|
||||
elseif hudclock.month == 6 then
|
||||
nval_temp = nval_temp + 5
|
||||
elseif hudclock.month == 7 then
|
||||
nval_temp = nval_temp + 5
|
||||
elseif hudclock.month == 8 then
|
||||
nval_temp = nval_temp + 0
|
||||
elseif hudclock.month == 9 then
|
||||
nval_temp = nval_temp - 5
|
||||
elseif hudclock.month == 10 then
|
||||
nval_temp = nval_temp - 10
|
||||
elseif hudclock.month == 11 then
|
||||
nval_temp = nval_temp - 15
|
||||
elseif hudclock.month == 12 then
|
||||
nval_temp = nval_temp - 20
|
||||
end
|
||||
|
||||
local y = math.abs(pos.y) * 0.001
|
||||
|
||||
if pos.y < 1 then
|
||||
|
||||
nval_temp = nval_temp + y
|
||||
|
||||
else
|
||||
|
||||
nval_temp = nval_temp - y
|
||||
|
||||
end
|
||||
|
||||
|
||||
if pos.y >= 10000 then
|
||||
|
||||
nval_temp = -271
|
||||
|
||||
nval_humid = 0
|
||||
|
||||
end
|
||||
|
||||
if pos.y < -14999 then
|
||||
|
||||
nval_humid = 0
|
||||
|
||||
nval_temp = nval_temp + 1000
|
||||
|
||||
end
|
||||
local heat, temp, latch = mcore.get_heat_humidity(player)
|
||||
|
||||
-- let's understand the current weather from atmos:
|
||||
|
||||
local weather_str, weather_icon
|
||||
local weather_str = ""
|
||||
|
||||
local atmw = atmos.current_weather
|
||||
|
||||
@ -194,8 +71,8 @@ function hudinfo.player_env_data(player)
|
||||
elseif atmw == 9 then
|
||||
weather_str = "Hailstorm,"
|
||||
end
|
||||
|
||||
return locale, nval_temp, nval_humid, weather_str
|
||||
|
||||
return locale, heat, temp, weather_str
|
||||
|
||||
end
|
||||
|
||||
|
@ -115,17 +115,24 @@ inventory_plus.get_formspec = function(player, page)
|
||||
formspec = formspec ..
|
||||
"button[0,0;3,1;main;Return to Inventory]" ..
|
||||
"button[0,1;3,1;main;Save Slot Modes]" ..
|
||||
"label[4,0;punch = item acts as if punched]"..
|
||||
"label[4,0.3;use = item acts as if used]" ..
|
||||
"label[4,0.6;place = item acts as if placed]" ..
|
||||
"dropdown[0.95,2.85;1;slot1;Use,Punch,Place;1]" ..
|
||||
--"field[1.28,3;1,1;slot1;;use]" ..
|
||||
"field[2.28,3;1,1;slot2;;use]" ..
|
||||
"field[3.28,3;1,1;slot3;;use]" ..
|
||||
"field[4.28,3;1,1;slot4;;use]" ..
|
||||
"field[5.28,3;1,1;slot5;;use]" ..
|
||||
"field[6.28,3;1,1;slot6;;use]" ..
|
||||
"list[current_player;quickslots;1,2;6,1]" ..
|
||||
"label[0,2;Punch = item acts as if punched]"..
|
||||
"label[0,2.3;Use = item acts as if used]" ..
|
||||
"label[0,2.6;Place = item acts as if placed]" ..
|
||||
"label[0,2.9;Note, Place will be used automatically for blocks]" ..
|
||||
|
||||
"dropdown[3.95,0.15;1;slot1;Use,Punch,Place;1]" ..
|
||||
"dropdown[3.95,1.15;1;slot1;Use,Punch,Place;1]" ..
|
||||
"dropdown[3.95,2.15;1;slot1;Use,Punch,Place;1]" ..
|
||||
"dropdown[5.95,0.15;1;slot1;Use,Punch,Place;1]" ..
|
||||
"dropdown[5.95,1.15;1;slot1;Use,Punch,Place;1]" ..
|
||||
"dropdown[5.95,2.15;1;slot1;Use,Punch,Place;1]" ..
|
||||
|
||||
"list[current_player;quickslots;3,0;1,1;0]" ..
|
||||
"list[current_player;quickslots;3,1;1,1;1]" ..
|
||||
"list[current_player;quickslots;3,2;1,1;2]" ..
|
||||
"list[current_player;quickslots;7,0;1,1;3]" ..
|
||||
"list[current_player;quickslots;7,1;1,1;4]" ..
|
||||
"list[current_player;quickslots;7,2;1,1;5]" ..
|
||||
"background[-0.45,-0.5;8.9,10;core_inv_plus_guide.png]"
|
||||
|
||||
end
|
||||
|
@ -75,59 +75,27 @@ function quickslots.get_quick_slots(player)
|
||||
--print(dump(pkeys))
|
||||
|
||||
if pkeys.sneak then
|
||||
|
||||
if pkeys.aux1 then
|
||||
|
||||
if pkeys.LMB then
|
||||
|
||||
print("left mouse, sneak and aux1")
|
||||
|
||||
return 6
|
||||
|
||||
else
|
||||
|
||||
print("right mouse, sneak and aux1")
|
||||
|
||||
return 3
|
||||
|
||||
return 3 -- right mouse
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
if pkeys.LMB then
|
||||
|
||||
print("left mouse, sneak")
|
||||
|
||||
return 4
|
||||
|
||||
else
|
||||
|
||||
print("right mouse, sneak")
|
||||
|
||||
return 1
|
||||
|
||||
return 1 -- right mouse
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
elseif pkeys.aux1 then
|
||||
|
||||
if pkeys.LMB then
|
||||
|
||||
print("left mouse, aux1")
|
||||
|
||||
return 5
|
||||
|
||||
else
|
||||
|
||||
print("right mouse, aux1")
|
||||
|
||||
return 2
|
||||
|
||||
return 2 -- right mouse
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--[[
|
||||
@ -157,11 +125,11 @@ end
|
||||
|
||||
Support using sneak and right mouse, alongside using the on_use function.
|
||||
|
||||
Use quicktools.on_use(quicktools.player_controls(), user, pointed_thing) for on_use.
|
||||
Use quicktools.on_use(quicktools.get_quick_slots(user), user, pointed_thing) for on_use.
|
||||
|
||||
Use quicktools.on_sec_use(quicktools.player_controls(), user, pointed_thing) for on_secondary_use.
|
||||
Use quicktools.on_sec_use(quicktools.get_quick_slots(user), user, pointed_thing) for on_secondary_use.
|
||||
|
||||
Use quicktools.on_place(quicktools.player_controls(), user, pointed_thing) for on_place.
|
||||
Use quicktools.on_place(quicktools.get_quick_slots(user), user, pointed_thing) for on_place.
|
||||
|
||||
See the below example for implementing this yourself. If the tool has an alternate mode that requires sneak or aux1,
|
||||
perform the action and do not process quicktools.
|
||||
@ -182,7 +150,7 @@ minetest.register_craftitem("quickslots:test", {
|
||||
-- get our player's settings for the current slot, if it's in on_use, on_place or on_sec_use
|
||||
--placer:get_int("quickslots_slot_" .. slotnum)
|
||||
|
||||
|
||||
|
||||
|
||||
end,
|
||||
|
||||
@ -198,4 +166,43 @@ minetest.register_craftitem("quickslots:test", {
|
||||
|
||||
end,
|
||||
|
||||
})
|
||||
|
||||
minetest.register_craftitem("quickslots:test_use", {
|
||||
|
||||
description = "Tests the on_use function",
|
||||
inventory_image = "core_water.png",
|
||||
|
||||
_quickslots_use_l = function(itemstack, placer, pointed_thing)
|
||||
|
||||
minetest.chat_send_all("on_use quickslots test used")
|
||||
|
||||
end,
|
||||
|
||||
})
|
||||
|
||||
minetest.register_craftitem("quickslots:test_use_r", {
|
||||
|
||||
description = "Tests the on_sec_use function",
|
||||
inventory_image = "core_lava.png",
|
||||
|
||||
_quickslots_use_r = function(itemstack, placer, pointed_thing)
|
||||
|
||||
minetest.chat_send_all("on_sec_use quickslots test used")
|
||||
|
||||
end,
|
||||
|
||||
})
|
||||
|
||||
minetest.register_craftitem("quickslots:test_place", {
|
||||
|
||||
description = "Tests the on_place function",
|
||||
inventory_image = "core_cobble.png",
|
||||
|
||||
_quickslots_place = function(itemstack, placer, pointed_thing)
|
||||
|
||||
minetest.chat_send_all("on_place quickslots test used")
|
||||
|
||||
end,
|
||||
|
||||
})
|
@ -1,66 +1,13 @@
|
||||
-- Parameters
|
||||
|
||||
local YLIMIT = 1 -- Set to world's water level or level of lowest open area,
|
||||
local YLIMIT = 0 -- Set to world's water level or level of lowest open area,
|
||||
-- calculations are disabled below this y.
|
||||
local PRECSPR = 6 -- Time scale for precipitation variation in minutes
|
||||
local PRECOFF = -0.4 -- Precipitation offset, higher = rains more often
|
||||
|
||||
local GSCYCLE = 0.5 -- Globalstep cycle (seconds)
|
||||
local FLAKES = 32 -- Snowflakes per cycle
|
||||
local DROPS = 96 -- Raindrops per cycle
|
||||
local RAINGAIN = 0.12 -- Rain sound volume
|
||||
local COLLIDE = true -- Whether particles collide with nodes
|
||||
local NISVAL = 39 -- Clouds RGB value at night
|
||||
local DASVAL = 175 -- Clouds RGB value in daytime
|
||||
|
||||
local np_prec = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = {x = PRECSPR, y = PRECSPR, z = PRECSPR},
|
||||
seed = 813,
|
||||
octaves = 1,
|
||||
persist = 0,
|
||||
lacunarity = 2.0,
|
||||
--flags = ""
|
||||
}
|
||||
|
||||
-- These 2 must match biome heat and humidity noise parameters for a world
|
||||
|
||||
local np_temp = {
|
||||
offset = 50,
|
||||
scale = 50,
|
||||
spread = {x = 1000, y = 1000, z = 1000},
|
||||
seed = 5349,
|
||||
octaves = 3,
|
||||
persist = 0.5,
|
||||
lacunarity = 2.0,
|
||||
--flags = ""
|
||||
}
|
||||
|
||||
local np_humid = {
|
||||
offset = 50,
|
||||
scale = 50,
|
||||
spread = {x = 1000, y = 1000, z = 1000},
|
||||
seed = 842,
|
||||
octaves = 3,
|
||||
persist = 0.5,
|
||||
lacunarity = 2.0,
|
||||
--flags = ""
|
||||
}
|
||||
|
||||
|
||||
-- Stuff
|
||||
|
||||
local difsval = DASVAL - NISVAL
|
||||
local grad = 14 / 95
|
||||
local yint = 1496 / 95
|
||||
|
||||
|
||||
-- Initialise noise objects to nil
|
||||
|
||||
local nobj_temp = nil
|
||||
local nobj_humid = nil
|
||||
local nobj_prec = nil
|
||||
|
||||
|
||||
-- Globalstep function
|
||||
|
||||
@ -76,55 +23,13 @@ minetest.register_globalstep(function(dtime)
|
||||
timer = 0
|
||||
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
|
||||
local player_name = player:get_player_name()
|
||||
local ppos = player:getpos()
|
||||
local heat, humid, latch = mcore.get_heat_humidity(player)
|
||||
local ppos = player:get_pos()
|
||||
local pposy = math.floor(ppos.y) + 2 -- Precipitation when swimming
|
||||
|
||||
if pposy >= YLIMIT then
|
||||
local pposx = math.floor(ppos.x)
|
||||
local pposz = math.floor(ppos.z)
|
||||
local ppos = {x = pposx, y = pposy, z = pposz}
|
||||
|
||||
local nobj_temp = nobj_temp or minetest.get_perlin(np_temp)
|
||||
local nobj_humid = nobj_humid or minetest.get_perlin(np_humid)
|
||||
local nobj_prec = nobj_prec or minetest.get_perlin(np_prec)
|
||||
|
||||
local nval_temp = nobj_temp:get2d({x = pposx, y = pposz})
|
||||
local nval_humid = nobj_humid:get2d({x = pposx, y = pposz})
|
||||
local nval_prec = nobj_prec:get2d({x = os.clock() / 60, y = 0})
|
||||
|
||||
-- Biome system: Frozen biomes below heat 35,
|
||||
-- deserts below line 14 * t - 95 * h = -1496
|
||||
-- h = (14 * t + 1496) / 95
|
||||
-- h = 14/95 * t + 1496/95
|
||||
-- where 14/95 is gradient and 1496/95 is y intersection
|
||||
-- h - 14/95 t = 1496/95 y intersection
|
||||
-- so area above line is
|
||||
-- h - 14/95 t > 1496/95
|
||||
--local freeze = nval_temp < 35
|
||||
--local precip = nval_prec < (nval_humid - 50) / 50 + PRECOFF and
|
||||
--nval_humid - grad * nval_temp > yint
|
||||
|
||||
-- solar plains biomes to rain in;
|
||||
|
||||
--[[
|
||||
|
||||
plains
|
||||
forests
|
||||
beach?
|
||||
|
||||
min temp to rain
|
||||
|
||||
40
|
||||
|
||||
max temp to rain
|
||||
|
||||
60
|
||||
|
||||
max humidity to rain
|
||||
|
||||
|
||||
|
||||
]]--
|
||||
|
||||
local precip = false
|
||||
|
||||
@ -132,12 +37,7 @@ minetest.register_globalstep(function(dtime)
|
||||
|
||||
local hail = false
|
||||
|
||||
-- debug info, uncomment to make use of for debugging temp and humidity scales for rain, snow and hail
|
||||
|
||||
--minetest.chat_send_player(player_name, "temp: " .. nval_temp)
|
||||
--minetest.chat_send_player(player_name, "humid: " ..nval_humid)
|
||||
|
||||
if atmos.current_weather == 6 and nval_temp <= 40.5 then
|
||||
if atmos.current_weather == 6 and heat <= 4 then
|
||||
|
||||
precip = true
|
||||
|
||||
@ -147,7 +47,7 @@ minetest.register_globalstep(function(dtime)
|
||||
|
||||
elseif atmos.current_weather == 6 or atmos.current_weather == 7 then
|
||||
|
||||
if nval_humid > 25 and nval_temp < 74 then
|
||||
if humid > 5 and heat < 35 then
|
||||
|
||||
precip = true
|
||||
|
||||
@ -157,7 +57,7 @@ minetest.register_globalstep(function(dtime)
|
||||
|
||||
end
|
||||
|
||||
elseif atmos.current_weather == 9 and nval_humid > 25 and nval_temp < 74 then
|
||||
elseif atmos.current_weather == 9 and humid > 5 and heat < 1 then
|
||||
|
||||
precip = true
|
||||
|
||||
@ -165,7 +65,7 @@ minetest.register_globalstep(function(dtime)
|
||||
|
||||
hail = true
|
||||
|
||||
elseif atmos.current_weather == 8 and nval_humid > 25 and nval_temp < 74 then
|
||||
elseif atmos.current_weather == 8 and humid > 5 and heat < 4 then
|
||||
|
||||
precip = true
|
||||
|
||||
@ -201,9 +101,9 @@ minetest.register_globalstep(function(dtime)
|
||||
for flake = 1, FLAKES do
|
||||
minetest.add_particle({
|
||||
pos = {
|
||||
x = pposx - 24 + math.random(0, 47),
|
||||
y = pposy + 8 + math.random(0, 1),
|
||||
z = pposz - 20 + math.random(0, 47)
|
||||
x = ppos.x - 24 + math.random(0, 47),
|
||||
y = ppos.y + 8 + math.random(0, 1),
|
||||
z = ppos.z - 20 + math.random(0, 47)
|
||||
},
|
||||
vel = {
|
||||
x = 0.0,
|
||||
@ -226,9 +126,9 @@ minetest.register_globalstep(function(dtime)
|
||||
for flake = 1, DROPS-48 do
|
||||
minetest.add_particle({
|
||||
pos = {
|
||||
x = pposx - 8 + math.random(0, 16),
|
||||
y = pposy + 8 + math.random(0, 5),
|
||||
z = pposz - 8 + math.random(0, 16)
|
||||
x = ppos.x - 8 + math.random(0, 16),
|
||||
y = ppos.y + 8 + math.random(0, 5),
|
||||
z = ppos.z - 8 + math.random(0, 16)
|
||||
},
|
||||
vel = {
|
||||
x = 0.0,
|
||||
@ -251,9 +151,9 @@ minetest.register_globalstep(function(dtime)
|
||||
for flake = 1, DROPS do
|
||||
minetest.add_particle({
|
||||
pos = {
|
||||
x = pposx - 8 + math.random(0, 16),
|
||||
y = pposy + 8 + math.random(0, 5),
|
||||
z = pposz - 8 + math.random(0, 16)
|
||||
x = ppos.x - 8 + math.random(0, 16),
|
||||
y = ppos.y + 8 + math.random(0, 5),
|
||||
z = ppos.z - 8 + math.random(0, 16)
|
||||
},
|
||||
vel = {
|
||||
x = 0.0,
|
||||
|
Loading…
x
Reference in New Issue
Block a user