This commit is contained in:
Hamlet 2020-07-23 11:46:18 +02:00
parent fea50b369e
commit a3c4842300
No known key found for this signature in database
GPG Key ID: 30C286622B0B63F9
9 changed files with 126 additions and 51 deletions

@ -2,20 +2,15 @@
![Ores Stats' screenshot](screenshot.png)
**_Provides informations about ores' percentages collected on map generation._**
**Version:** 0.2.0
**Version:** 1.0.0
**Source code's license:** [EUPL v1.2][1] or later.
**Dependencies:** default (found in [Minetest Game][2])
**Dependencies:** default, sfinv (found in [Minetest Game][2])
**NOTE:** To update the page's values switch to another tab.
__Advanced option:__
Settings -> All Settings -> Mods -> orestats
__How to use:__
Open the chat window, type the command /orestats help
To show ores' statistics in the chat window: /orestats chat
To show ores' statistics in the console window: /orestats console
Settings -> All Settings -> Mods -> ores_stats
### Installation

@ -10,6 +10,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
- No further features planned.
## [1.0.0] - 2020-07-23
### Added
- Inventory's page (switch tab to update).
- Ores' relative values.
- Option to change gold's value via Settings -> All settings -> Mods -> ores_stats
### Changed
- Code rewritten from scratch.
- Version updated to 1.x, non backward compatible.
### Removed
- Console and chat output.
## [0.2.0] - 2019-10-29
### Added

@ -34,42 +34,42 @@ sfinv.register_page('ores_stats:ores_stats', {
title = 'Ores\' Stats',
get = function(self, player, context)
local s_oresPerc =
',' ..
S("Ores' percentages") .. ',' ..
'========================' .. ',' ..
',' .. ' ' ..
S("Ores' percentages") .. ',' .. ' ' ..
'========================' .. ',' .. ' ' ..
S('Coal: ') .. string.format("%.3f", ores_stats.f_percCoal)
.. '%' .. ',' ..
.. '%' .. ',' .. ' ' ..
S('Copper: ') .. string.format("%.3f", ores_stats.f_percCopper)
.. '%' .. ',' ..
.. '%' .. ',' .. ' ' ..
S('Diamonds: ') .. string.format("%.3f", ores_stats.f_percDiamonds)
.. '%' .. ',' ..
.. '%' .. ',' .. ' ' ..
S('Gold: ') .. string.format("%.3f", ores_stats.f_percGold)
.. '%' .. ',' ..
.. '%' .. ',' .. ' ' ..
S('Iron: ') .. string.format("%.3f", ores_stats.f_percIron)
.. '%' .. ',' ..
.. '%' .. ',' .. ' ' ..
S('Mese: ') .. string.format("%.3f", ores_stats.f_percMese)
.. '%' .. ',' ..
.. '%' .. ',' .. ' ' ..
S('Tin: ') .. string.format("%.3f", ores_stats.f_percTin)
.. '%' .. ','
local s_oresValue =
',' ..
S("Ores' values") .. ',' ..
'========================' .. ',' ..
',' .. ' ' ..
S("Ores' values") .. ',' .. ' ' ..
'========================' .. ',' .. ' ' ..
S('Coal: ') .. string.format("%.3f", ores_stats.f_valueCoal)
.. '%' .. ',' ..
.. ',' .. ' ' ..
S('Copper: ') .. string.format("%.3f", ores_stats.f_valueCopper)
.. '%' .. ',' ..
.. ',' .. ' ' ..
S('Diamonds: ') .. string.format("%.3f", ores_stats.f_valueDiamonds)
.. '%' .. ',' ..
.. ',' .. ' ' ..
S('Gold: ') .. string.format("%.3f", ores_stats.f_valueGold)
.. '%' .. ',' ..
.. ',' .. ' ' ..
S('Iron: ') .. string.format("%.3f", ores_stats.f_valueIron)
.. '%' .. ',' ..
.. ',' .. ' ' ..
S('Mese: ') .. string.format("%.3f", ores_stats.f_valueMese)
.. '%' .. ',' ..
.. ',' .. ' ' ..
S('Tin: ') .. string.format("%.3f", ores_stats.f_valueTin)
.. '%' .. ','
.. ','
return sfinv.make_formspec(player, context,
'textlist[0,0;7.8,9.2;;' ..
@ -87,44 +87,44 @@ ores_stats.pr_UpdateFormspec = function()
title = 'Ores\' Stats',
get = function(self, player, context)
local s_oresPerc =
',' ..
S("Ores' percentages") .. ',' ..
'========================' .. ',' ..
',' .. ' ' ..
S("Ores' percentages") .. ',' .. ' ' ..
'========================' .. ',' .. ' ' ..
S('Coal: ') .. string.format("%.3f", ores_stats.f_percCoal)
.. '%' .. ',' ..
.. '%' .. ',' .. ' ' ..
S('Copper: ') .. string.format("%.3f", ores_stats.f_percCopper)
.. '%' .. ',' ..
.. '%' .. ',' .. ' ' ..
S('Diamonds: ') .. string.format("%.3f",
ores_stats.f_percDiamonds)
.. '%' .. ',' ..
.. '%' .. ',' .. ' ' ..
S('Gold: ') .. string.format("%.3f", ores_stats.f_percGold)
.. '%' .. ',' ..
.. '%' .. ',' .. ' ' ..
S('Iron: ') .. string.format("%.3f", ores_stats.f_percIron)
.. '%' .. ',' ..
.. '%' .. ',' .. ' ' ..
S('Mese: ') .. string.format("%.3f", ores_stats.f_percMese)
.. '%' .. ',' ..
.. '%' .. ',' .. ' ' ..
S('Tin: ') .. string.format("%.3f", ores_stats.f_percTin)
.. '%' .. ','
local s_oresValue =
',' ..
S("Ores' values") .. ',' ..
'========================' .. ',' ..
',' .. ' ' ..
S("Ores' values") .. ',' .. ' ' ..
'========================' .. ',' .. ' ' ..
S('Coal: ') .. string.format("%.3f", ores_stats.f_valueCoal)
.. '%' .. ',' ..
.. ',' .. ' ' ..
S('Copper: ') .. string.format("%.3f", ores_stats.f_valueCopper)
.. '%' .. ',' ..
.. ',' .. ' ' ..
S('Diamonds: ') .. string.format("%.3f",
ores_stats.f_valueDiamonds)
.. '%' .. ',' ..
.. ',' .. ' ' ..
S('Gold: ') .. string.format("%.3f", ores_stats.f_valueGold)
.. '%' .. ',' ..
.. ',' .. ' ' ..
S('Iron: ') .. string.format("%.3f", ores_stats.f_valueIron)
.. '%' .. ',' ..
.. ',' .. ' ' ..
S('Mese: ') .. string.format("%.3f", ores_stats.f_valueMese)
.. '%' .. ',' ..
.. ',' .. ' ' ..
S('Tin: ') .. string.format("%.3f", ores_stats.f_valueTin)
.. '%' .. ','
.. ','
return sfinv.make_formspec(player, context,
'textlist[0,0;7.8,9.2;;' ..

@ -36,3 +36,36 @@ ores_stats.fn_CalcPercentage = function(a_i_ore, a_i_total_ores)
return f_percentage
end
-- Used to calculate an ore's value
ores_stats.fn_CalcValue = function(a_f_ore_percentage)
-- Constants
local f_GOLD_PERC = 4.1 -- Average percentage
-- Variables
local f_goldPerc, f_goldValue, f_oreRatio, f_oreValue
f_goldPerc = ores_stats.f_percGold
if (f_goldPerc == 0) then
f_goldPerc = f_GOLD_PERC
end
f_goldValue = ores_stats.f_valueGold
if (f_goldValue == 0) then
f_goldValue = ores_stats.f_GOLD_VALUE
end
if (a_f_ore_percentage ~= 0) then
f_oreRatio = (a_f_ore_percentage / f_goldPerc)
f_oreValue = (f_goldValue / f_oreRatio)
else
f_oreValue = 0.0
end
return f_oreValue
end

@ -243,3 +243,22 @@ ores_stats.pr_MTGupdateSaveDBvalue = function()
ores_stats.t_MOD_DATABASE:set_float('f_valueTin',
ores_stats.f_valueTin)
end
-- Used to calculate the Minetest Game's ores values
ores_stats.pr_CalcValues = function()
ores_stats.f_valueCoal = ores_stats.fn_CalcValue(ores_stats.f_percCoal)
ores_stats.f_valueCopper = ores_stats.fn_CalcValue(ores_stats.f_percCopper)
ores_stats.f_valueDiamonds =
ores_stats.fn_CalcValue(ores_stats.f_percDiamonds)
ores_stats.f_valueGold = ores_stats.fn_CalcValue(ores_stats.f_percGold)
ores_stats.f_valueIron = ores_stats.fn_CalcValue(ores_stats.f_percIron)
ores_stats.f_valueMese = ores_stats.fn_CalcValue(ores_stats.f_percMese)
ores_stats.f_valueTin = ores_stats.fn_CalcValue(ores_stats.f_percTin)
end

@ -32,6 +32,11 @@ ores_stats = {}
-- Database handler
ores_stats.t_MOD_DATABASE = minetest.get_mod_storage()
-- Default ore value
ores_stats.f_GOLD_VALUE = minetest.settings:get('ores_stats_gold_value')
or 50.0
--
-- Variables
--
@ -56,7 +61,7 @@ local pr_LogMessage = function()
or (s_LOG_LEVEL == 'info')
or (s_LOG_LEVEL == 'verbose')
then
minetest.log('action', '[Mod] Ores Stats [v0.3.0] loaded.')
minetest.log('action', '[Mod] Ores Stats [v1.0.0] loaded.')
end
end
@ -84,6 +89,7 @@ pr_LoadSubFiles()
ores_stats.pr_MTGupdateFromDB()
ores_stats.pr_MTGupdateFromDBperc()
ores_stats.pr_MTGupdateFromDBvalue()
-- Voxel manipulator
minetest.register_on_generated(function()
@ -98,9 +104,11 @@ minetest.register_on_generated(function()
ores_stats.pr_CalcTotalOres()
ores_stats.pr_OresPercentages()
ores_stats.pr_CalcValues()
ores_stats.pr_MTGupdateSaveDB()
ores_stats.pr_MTGupdateSaveDBperc()
ores_stats.pr_MTGupdateSaveDBvalue()
ores_stats.pr_UpdateFormspec()

@ -8,3 +8,4 @@ Gold: =Oro:
Mese: =Mese:
Diamonds: =Diamanti:
Ores' percentages=Percentuali dei minerali
Ores' values=Valori dei minerali

@ -8,3 +8,4 @@ Gold: =
Mese: =
Diamonds: =
Ores' percentages=
Ores' values=

@ -1,4 +1,4 @@
# ENG: Enable the profiler?
# ENG: Default gold value.
#
# ITA: Abilitare le informazioni statistiche?
ores_stats_profiler (Ores' Statistics profiler) bool false
# ITA: valore predefinito dell'oro.
ores_stats_gold_value (Gold value) float 50.0