This commit is contained in:
Hamlet 2020-08-19 23:31:10 +02:00
parent a3c4842300
commit c3d3348dcc
No known key found for this signature in database
GPG Key ID: 30C286622B0B63F9
10 changed files with 264 additions and 2 deletions

@ -2,10 +2,11 @@
![Ores Stats' screenshot](screenshot.png) ![Ores Stats' screenshot](screenshot.png)
**_Provides informations about ores' percentages collected on map generation._** **_Provides informations about ores' percentages collected on map generation._**
**Version:** 1.0.0 **Version:** 1.1.0
**Source code's license:** [EUPL v1.2][1] or later. **Source code's license:** [EUPL v1.2][1] or later.
**Dependencies:** default, sfinv (found in [Minetest Game][2]) **Dependencies:** default, sfinv (found in [Minetest Game][2])
**Supported:** [More Ores][3]
**NOTE:** To update the page's values switch to another tab. **NOTE:** To update the page's values switch to another tab.
@ -31,3 +32,4 @@ https://wiki.minetest.net/Help:Installing_Mods
[1]: https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX:32017D0863 [1]: https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX:32017D0863
[2]: https://github.com/minetest/minetest_game [2]: https://github.com/minetest/minetest_game
[3]: https://forum.minetest.net/viewtopic.php?f=11&t=549

@ -10,6 +10,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
- No further features planned. - No further features planned.
## [1.1.0] - 2020-08-19
### Added
- Support for More Ores
## [1.0.0] - 2020-07-23 ## [1.0.0] - 2020-07-23
### Added ### Added

@ -71,6 +71,24 @@ sfinv.register_page('ores_stats:ores_stats', {
S('Tin: ') .. string.format("%.3f", ores_stats.f_valueTin) S('Tin: ') .. string.format("%.3f", ores_stats.f_valueTin)
.. ',' .. ','
-- Support for More Ores' nodes
if (ores_stats.b_MORE_ORES == true) then
s_oresPerc = s_oresPerc .. ' ' ..
S('Mithril: ') .. string.format("%.3f",
ores_stats.f_percMithril)
.. '%' .. ',' .. ' ' ..
S('Silver: ') .. string.format("%.3f", ores_stats.f_percSilver)
.. '%' .. ','
s_oresValue = s_oresValue .. ' ' ..
S('Mithril: ') .. string.format("%.3f",
ores_stats.f_valueMithril)
.. ',' .. ' ' ..
S('Silver: ') .. string.format("%.3f", ores_stats.f_valueSilver)
.. ','
end
return sfinv.make_formspec(player, context, return sfinv.make_formspec(player, context,
'textlist[0,0;7.8,9.2;;' .. 'textlist[0,0;7.8,9.2;;' ..
s_oresPerc .. s_oresValue .. ']', false) s_oresPerc .. s_oresValue .. ']', false)
@ -126,6 +144,26 @@ ores_stats.pr_UpdateFormspec = function()
S('Tin: ') .. string.format("%.3f", ores_stats.f_valueTin) S('Tin: ') .. string.format("%.3f", ores_stats.f_valueTin)
.. ',' .. ','
-- Support for More Ores' nodes
if (ores_stats.b_MORE_ORES == true) then
s_oresPerc = s_oresPerc .. ' ' ..
S('Mithril: ') .. string.format("%.3f",
ores_stats.f_percMithril)
.. '%' .. ',' .. ' ' ..
S('Silver: ') .. string.format("%.3f",
ores_stats.f_percSilver)
.. '%' .. ','
s_oresValue = s_oresValue .. ' ' ..
S('Mithril: ') .. string.format("%.3f",
ores_stats.f_valueMithril)
.. ',' .. ' ' ..
S('Silver: ') .. string.format("%.3f",
ores_stats.f_valueSilver)
.. ','
end
return sfinv.make_formspec(player, context, return sfinv.make_formspec(player, context,
'textlist[0,0;7.8,9.2;;' .. 'textlist[0,0;7.8,9.2;;' ..
s_oresPerc .. s_oresValue .. ']', false) s_oresPerc .. s_oresValue .. ']', false)

44
core/moreores.lua Normal file

@ -0,0 +1,44 @@
--[[
Ores' Statistics - Provides informations about ores' percentages
Copyright © 2018, 2020 Hamlet and contributors.
Licensed under the EUPL, Version 1.2 or as soon they will be
approved by the European Commission subsequent versions of the
EUPL (the "Licence");
You may not use this work except in compliance with the Licence.
You may obtain a copy of the Licence at:
https://joinup.ec.europa.eu/software/page/eupl
https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX:32017D0863
Unless required by applicable law or agreed to in writing,
software distributed under the Licence is distributed on an
"AS IS" basis,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
See the Licence for the specific language governing permissions
and limitations under the Licence.
--]]
--
-- Constants
--
ores_stats.id_mithril = minetest.get_content_id('moreores:mineral_mithril')
ores_stats.id_silver = minetest.get_content_id('moreores:mineral_silver')
--
-- Variables
--
ores_stats.i_foundMithril = 0
ores_stats.i_foundSilver = 0
ores_stats.f_percMithril = 0.0
ores_stats.f_percSilver = 0.0
ores_stats.f_valueMithril = 0.0
ores_stats.f_valueSilver = 0.0

@ -0,0 +1,97 @@
--[[
Ores' Statistics - Provides informations about ores' percentages
Copyright © 2018, 2020 Hamlet and contributors.
Licensed under the EUPL, Version 1.2 or as soon they will be
approved by the European Commission subsequent versions of the
EUPL (the "Licence");
You may not use this work except in compliance with the Licence.
You may obtain a copy of the Licence at:
https://joinup.ec.europa.eu/software/page/eupl
https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX:32017D0863
Unless required by applicable law or agreed to in writing,
software distributed under the Licence is distributed on an
"AS IS" basis,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
See the Licence for the specific language governing permissions
and limitations under the Licence.
--]]
--
-- Procedures
--
-- Used to update the More Ores' variables
ores_stats.pr_MOupdateFromDB = function()
ores_stats.i_foundMithril =
ores_stats.t_MOD_DATABASE:get_int('i_found_mithril') or 0
ores_stats.i_foundSilver =
ores_stats.t_MOD_DATABASE:get_int('i_found_silver') or 0
end
-- Used to save the More Ores' variables
ores_stats.pr_MOupdateSaveDB = function()
ores_stats.t_MOD_DATABASE:set_int('i_found_mithril',
ores_stats.i_foundMithril)
ores_stats.t_MOD_DATABASE:set_int('i_found_silver',
ores_stats.i_foundSilver)
end
-- Used to update the More Ores' percentages variables
ores_stats.pr_MOupdateFromDBperc = function()
ores_stats.f_percMithril =
ores_stats.t_MOD_DATABASE:get_float('f_percMithril') or 0.0
ores_stats.f_percSilver =
ores_stats.t_MOD_DATABASE:get_float('f_percSilver') or 0.0
end
-- Used to save the More Ores' percentages variables
ores_stats.pr_MOupdateSaveDBperc = function()
ores_stats.t_MOD_DATABASE:set_float('f_percMithril',
ores_stats.f_percMithril)
ores_stats.t_MOD_DATABASE:set_float('f_percSilver',
ores_stats.f_percSilver)
end
-- Used to update the More Ores' value variables
ores_stats.pr_MOupdateFromDBvalue = function()
ores_stats.f_valueMithril =
ores_stats.t_MOD_DATABASE:get_float('f_valueMithril') or 0.0
ores_stats.f_valueSilver =
ores_stats.t_MOD_DATABASE:get_float('f_valueSilver') or 0.0
end
-- Used to save the More Ores' value variables
ores_stats.pr_MOupdateSaveDBvalue = function()
ores_stats.t_MOD_DATABASE:set_float('f_valueMithril',
ores_stats.f_valueMithril)
ores_stats.t_MOD_DATABASE:set_float('f_valueSilver',
ores_stats.f_valueSilver)
end
-- Used to calculate the More Ores' ores values
ores_stats.pr_MOCalcValues = function()
ores_stats.f_valueMithril =
ores_stats.fn_CalcValue(ores_stats.f_percMithril)
ores_stats.f_valueSilver = ores_stats.fn_CalcValue(ores_stats.f_percSilver)
end

@ -119,12 +119,22 @@ end
-- Used to update the total ores found variable -- Used to update the total ores found variable
ores_stats.pr_CalcTotalOres = function() ores_stats.pr_CalcTotalOres = function()
ores_stats.i_TotalOres = ( ores_stats.i_TotalOres = (
ores_stats.i_foundCoal + ores_stats.i_foundCopper + ores_stats.i_foundCoal + ores_stats.i_foundCopper +
ores_stats.i_foundDiamonds + ores_stats.i_foundGold + ores_stats.i_foundDiamonds + ores_stats.i_foundGold +
ores_stats.i_foundIron + ores_stats.i_foundMese + ores_stats.i_foundIron + ores_stats.i_foundMese +
ores_stats.i_foundTin ores_stats.i_foundTin
) )
-- Support for More Ores' nodes
if (ores_stats.b_MORE_ORES == true) then
ores_stats.i_TotalOres = (
ores_stats.i_TotalOres +
ores_stats.i_foundMithril +
ores_stats.i_foundSilver
)
end
end end
-- Used to update the amounts of the ores found -- Used to update the amounts of the ores found
@ -155,6 +165,17 @@ ores_stats.pr_OresScanner = function(a_s_node_id)
ores_stats.i_foundTin = (ores_stats.i_foundTin + 1) ores_stats.i_foundTin = (ores_stats.i_foundTin + 1)
end end
-- Support for More Ores' nodes
if (ores_stats.b_MORE_ORES == true) then
if (a_s_node_id == ores_stats.id_mithril) then
ores_stats.i_foundMithril = (ores_stats.i_foundMithril + 1)
elseif (a_s_node_id == ores_stats.id_silver) then
ores_stats.i_foundSilver = (ores_stats.i_foundSilver + 1)
end
end
end end
-- Used to update the amounts of the ores found -- Used to update the amounts of the ores found
@ -191,6 +212,17 @@ ores_stats.pr_OresPercentages = function()
ores_stats.f_percTin = ores_stats.f_percTin =
ores_stats.fn_CalcPercentage(ores_stats.i_foundTin, ores_stats.fn_CalcPercentage(ores_stats.i_foundTin,
ores_stats.i_TotalOres) ores_stats.i_TotalOres)
-- Support for More Ores' nodes
if (ores_stats.b_MORE_ORES == true) then
ores_stats.f_percMithril =
ores_stats.fn_CalcPercentage(ores_stats.i_foundMithril,
ores_stats.i_TotalOres)
ores_stats.f_percSilver =
ores_stats.fn_CalcPercentage(ores_stats.i_foundSilver,
ores_stats.i_TotalOres)
end
end end
-- Used to update the Minetest Game's value variables -- Used to update the Minetest Game's value variables

@ -36,6 +36,13 @@ ores_stats.t_MOD_DATABASE = minetest.get_mod_storage()
ores_stats.f_GOLD_VALUE = minetest.settings:get('ores_stats_gold_value') ores_stats.f_GOLD_VALUE = minetest.settings:get('ores_stats_gold_value')
or 50.0 or 50.0
-- Support for More Ores
ores_stats.b_MORE_ORES = false
if (minetest.get_modpath('moreores') ~= nil) then
ores_stats.b_MORE_ORES = true
end
-- --
-- Variables -- Variables
@ -61,7 +68,7 @@ local pr_LogMessage = function()
or (s_LOG_LEVEL == 'info') or (s_LOG_LEVEL == 'info')
or (s_LOG_LEVEL == 'verbose') or (s_LOG_LEVEL == 'verbose')
then then
minetest.log('action', '[Mod] Ores Stats [v1.0.0] loaded.') minetest.log('action', '[Mod] Ores Stats [v1.1.0] loaded.')
end end
end end
@ -76,6 +83,13 @@ local pr_LoadSubFiles = function()
dofile(s_MOD_PATH .. '/core/functions.lua') dofile(s_MOD_PATH .. '/core/functions.lua')
dofile(s_MOD_PATH .. '/core/procedures.lua') dofile(s_MOD_PATH .. '/core/procedures.lua')
dofile(s_MOD_PATH .. '/core/minetest_game.lua') dofile(s_MOD_PATH .. '/core/minetest_game.lua')
-- Support for More Ores' nodes
if (ores_stats.b_MORE_ORES == true) then
dofile(s_MOD_PATH .. '/core/moreores_procedures.lua')
dofile(s_MOD_PATH .. '/core/moreores.lua')
end
dofile(s_MOD_PATH .. '/core/formspec.lua') dofile(s_MOD_PATH .. '/core/formspec.lua')
end end
@ -91,6 +105,13 @@ ores_stats.pr_MTGupdateFromDB()
ores_stats.pr_MTGupdateFromDBperc() ores_stats.pr_MTGupdateFromDBperc()
ores_stats.pr_MTGupdateFromDBvalue() ores_stats.pr_MTGupdateFromDBvalue()
-- Support for More Ores' nodes
if (ores_stats.b_MORE_ORES == true) then
ores_stats.pr_MOupdateFromDB()
ores_stats.pr_MOupdateFromDBperc()
ores_stats.pr_MOupdateFromDBvalue()
end
-- Voxel manipulator -- Voxel manipulator
minetest.register_on_generated(function() minetest.register_on_generated(function()
@ -106,10 +127,24 @@ minetest.register_on_generated(function()
ores_stats.pr_OresPercentages() ores_stats.pr_OresPercentages()
ores_stats.pr_CalcValues() ores_stats.pr_CalcValues()
-- Support for More Ores' nodes
if (ores_stats.b_MORE_ORES == true) then
ores_stats.pr_MOCalcValues()
end
ores_stats.pr_MTGupdateSaveDB() ores_stats.pr_MTGupdateSaveDB()
ores_stats.pr_MTGupdateSaveDBperc() ores_stats.pr_MTGupdateSaveDBperc()
ores_stats.pr_MTGupdateSaveDBvalue() ores_stats.pr_MTGupdateSaveDBvalue()
-- Support for More Ores' nodes
if (ores_stats.b_MORE_ORES == true) then
ores_stats.pr_MOupdateSaveDB()
ores_stats.pr_MOupdateSaveDBperc()
ores_stats.pr_MOupdateSaveDBvalue()
end
ores_stats.pr_UpdateFormspec() ores_stats.pr_UpdateFormspec()
end) end)

@ -9,3 +9,6 @@ Mese: =Mese:
Diamonds: =Diamanti: Diamonds: =Diamanti:
Ores' percentages=Percentuali dei minerali Ores' percentages=Percentuali dei minerali
Ores' values=Valori dei minerali Ores' values=Valori dei minerali
Mithril: =Mithril:
Silver: =Argento:

@ -9,3 +9,5 @@ Mese: =
Diamonds: = Diamonds: =
Ores' percentages= Ores' percentages=
Ores' values= Ores' values=
Mithril: =
Silver: =

@ -1,3 +1,4 @@
name = ores_stats name = ores_stats
description = Provides informations about ores' percentages collected on map generation. description = Provides informations about ores' percentages collected on map generation.
depends = default depends = default
optional_depends = moreores