ores_stats/init.lua

110 lines
2.2 KiB
Lua
Raw Normal View History

2018-06-04 19:03:44 +02:00
--[[
Ores' Statistics - Provides informations about ores' percentages
2020-07-23 00:53:00 +02:00
Copyright © 2018, 2020 Hamlet and contributors.
2018-06-04 19:03:44 +02:00
2019-10-29 11:31:40 +01:00
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:
2018-06-04 19:03:44 +02:00
2019-10-29 11:31:40 +01:00
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.
2018-06-04 19:03:44 +02:00
--]]
--
2020-07-23 00:53:00 +02:00
-- Constants
2018-06-04 19:03:44 +02:00
--
2020-07-23 00:53:00 +02:00
-- Global mod's namespace
ores_stats = {}
2019-10-29 11:31:40 +01:00
2020-07-23 00:53:00 +02:00
-- Database handler
ores_stats.t_MOD_DATABASE = minetest.get_mod_storage()
2019-10-29 11:31:40 +01:00
2018-06-04 19:03:44 +02:00
--
2020-07-23 00:53:00 +02:00
-- Variables
2018-06-04 19:03:44 +02:00
--
2020-07-23 00:53:00 +02:00
ores_stats.i_TotalOres = 0
2018-06-04 19:03:44 +02:00
--
2020-07-23 00:53:00 +02:00
-- Procedures
2018-06-04 19:03:44 +02:00
--
2020-07-23 00:53:00 +02:00
-- Minetest logger
local pr_LogMessage = function()
2018-06-04 19:03:44 +02:00
2020-07-23 00:53:00 +02:00
-- Constant
local s_LOG_LEVEL = minetest.settings:get('debug_log_level')
2018-06-04 19:03:44 +02:00
2020-07-23 00:53:00 +02:00
-- Body
if (s_LOG_LEVEL == nil)
or (s_LOG_LEVEL == 'action')
or (s_LOG_LEVEL == 'info')
or (s_LOG_LEVEL == 'verbose')
then
minetest.log('action', '[Mod] Ores Stats [v0.3.0] loaded.')
2018-06-04 19:03:44 +02:00
end
end
2020-07-23 00:53:00 +02:00
-- Subfiles loader
local pr_LoadSubFiles = function()
2018-06-04 19:03:44 +02:00
2020-07-23 00:53:00 +02:00
-- Constant
local s_MOD_PATH = minetest.get_modpath('ores_stats')
2018-06-04 19:03:44 +02:00
2020-07-23 00:53:00 +02:00
-- Body
dofile(s_MOD_PATH .. '/core/functions.lua')
dofile(s_MOD_PATH .. '/core/procedures.lua')
dofile(s_MOD_PATH .. '/core/minetest_game.lua')
dofile(s_MOD_PATH .. '/core/formspec.lua')
2018-06-04 19:03:44 +02:00
end
--
2020-07-23 00:53:00 +02:00
-- Main body
2018-06-04 19:03:44 +02:00
--
2020-07-23 00:53:00 +02:00
pr_LoadSubFiles()
2018-06-04 19:03:44 +02:00
2020-07-23 00:53:00 +02:00
ores_stats.pr_MTGupdateFromDB()
ores_stats.pr_MTGupdateFromDBperc()
2018-06-04 19:03:44 +02:00
-- Voxel manipulator
minetest.register_on_generated(function()
local vm, emin, emax = minetest.get_mapgen_object"voxelmanip"
local data = vm:get_data()
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
for i in area:iterp(emin, emax) do
2020-07-23 00:53:00 +02:00
ores_stats.pr_OresScanner(data[i])
2018-06-04 19:03:44 +02:00
end
2020-07-23 00:53:00 +02:00
ores_stats.pr_CalcTotalOres()
ores_stats.pr_OresPercentages()
2018-06-04 19:03:44 +02:00
2020-07-23 00:53:00 +02:00
ores_stats.pr_MTGupdateSaveDB()
ores_stats.pr_MTGupdateSaveDBperc()
2018-06-04 19:03:44 +02:00
2020-07-23 00:53:00 +02:00
ores_stats.pr_UpdateFormspec()
2018-06-04 19:03:44 +02:00
2020-07-23 00:53:00 +02:00
end)
2018-06-04 19:03:44 +02:00
2020-07-23 00:53:00 +02:00
pr_LogMessage()