2020-07-31

This commit is contained in:
Hamlet 2020-07-31 20:29:35 +02:00
parent 54dfb8bb8f
commit 49e87a1388
No known key found for this signature in database
GPG Key ID: 30C286622B0B63F9
12 changed files with 973 additions and 555 deletions

93
core/formspec.lua Normal file
View File

@ -0,0 +1,93 @@
--[[
Fate of the Gods - Adds roleplay mechanics.
Copyright © 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.
--]]
-- This is used to register the charaxter's sheet inventory tab
sfinv.register_page('fog:charsheet', {
title = fog.l10n('P.C. sheet'),
get = function(self, player, context)
local s_formspecString = fog.fn_FogMTGstats(player)
return sfinv.make_formspec(player, context,
'textlist[0,0;7.8,4.5;;' .. s_formspecString .. ']', true)
end
})
-- This is used to update the character's sheet inventory tab
fog.fn_FogMTGstats = function(a_s_player)
-- Constants
local s_LEVEL_AXE = fog.l10n(' Axe class: ');
local s_LEVEL_PICK = fog.l10n(' Pick class: ');
local s_LEVEL_SHOVEL = fog.l10n(' Shovel class: ');
local s_LEVEL_SWORD = fog.l10n(' Sword class: ');
-- Variables
local s_formspecText = '';
local s_keyword = a_s_player:get_player_name() .. '_';
local i_levelAxe, i_levelPick, i_levelShovel, i_levelSword,
i_expAxe, i_expPick, i_expShovel, i_expSword
i_levelAxe = fog.fn_ToolLVLread(s_keyword .. 'i_rank_axe');
i_levelPick = fog.fn_ToolLVLread(s_keyword .. 'i_rank_pick');
i_levelShovel = fog.fn_ToolLVLread(s_keyword .. 'i_rank_shovel');
i_levelSword = fog.fn_ToolLVLread(s_keyword .. 'i_rank_sword');
i_expAxe = fog.fn_ToolXPread(s_keyword .. 'i_xp_axe')
i_expPick = fog.fn_ToolXPread(s_keyword .. 'i_xp_pick')
i_expShovel = fog.fn_ToolXPread(s_keyword .. 'i_xp_shovel')
i_expSword = fog.fn_ToolXPread(s_keyword .. 'i_xp_sword')
s_formspecText = ',' ..
s_LEVEL_AXE .. i_levelAxe ..
' (' .. i_expAxe .. fog.l10n(' experience points)') .. ',' ..
s_LEVEL_PICK .. i_levelPick ..
' (' .. i_expPick .. fog.l10n(' experience points)') .. ',' ..
s_LEVEL_SHOVEL .. i_levelShovel ..
' (' .. i_expShovel .. fog.l10n(' experience points)') .. ',' ..
s_LEVEL_SWORD .. i_levelSword ..
' (' .. i_expSword .. fog.l10n(' experience points)')
return s_formspecText
end
-- This is used to override the character's sheet page
fog.pr_OverrideFormspec = function()
sfinv.override_page('fog:charsheet', {
title = fog.l10n('P.C. sheet'),
get = function(self, player, context)
local s_formspecString = fog.fn_FogMTGstats(player)
return sfinv.make_formspec(player, context,
'textlist[0,0;7.8,4.5;;' .. s_formspecString .. ']', true)
end
})
end

View File

@ -26,343 +26,185 @@
-- Functions
--
-- This is used to read values from the database
fog.fn_ReadDatabase = function(a_s_keyword)
local i_VALUE = fog.t_MOD_DATABASE:get_int(a_s_keyword)
return i_VALUE
-- Argument: username_tool_xp
fog.fn_ToolXPread = function(a_s_keyword)
local i_experience = fog.t_MOD_STORAGE:get_int(a_s_keyword)
if (i_experience == nil) then
i_experience = 0
end
return i_experience
end
-- This is used to check the experience level
fog.fn_LevelCheck = function(a_s_keyword)
local i_MODE = 2
local s_CLASS = ''
local i_EXPERIENCE_POINTS = fog.fn_ReadDatabase(a_s_keyword)
-- Constants
local I_CLASS_Z_UPPER_LIMIT, I_CLASS_Y_UPPER_LIMIT, I_CLASS_X_UPPER_LIMIT,
I_CLASS_W_UPPER_LIMIT, I_CLASS_V_UPPER_LIMIT, I_CLASS_U_UPPER_LIMIT,
I_CLASS_T_UPPER_LIMIT, I_CLASS_S_UPPER_LIMIT, I_CLASS_R_UPPER_LIMIT,
I_CLASS_Q_UPPER_LIMIT, I_CLASS_P_UPPER_LIMIT, I_CLASS_O_UPPER_LIMIT,
I_CLASS_N_UPPER_LIMIT, I_CLASS_M_UPPER_LIMIT, I_CLASS_L_UPPER_LIMIT,
I_CLASS_K_UPPER_LIMIT, I_CLASS_J_UPPER_LIMIT, I_CLASS_I_UPPER_LIMIT,
I_CLASS_H_UPPER_LIMIT, I_CLASS_G_UPPER_LIMIT, I_CLASS_F_UPPER_LIMIT,
I_CLASS_E_UPPER_LIMIT, I_CLASS_D_UPPER_LIMIT, I_CLASS_C_UPPER_LIMIT,
I_CLASS_B_UPPER_LIMIT
-- Class A: 75.025.000
if (i_MODE == 0) then
I_CLASS_Z_UPPER_LIMIT = 99
I_CLASS_Y_UPPER_LIMIT = 999
I_CLASS_X_UPPER_LIMIT = 1999
I_CLASS_W_UPPER_LIMIT = 2999
I_CLASS_V_UPPER_LIMIT = 4999
I_CLASS_U_UPPER_LIMIT = 7999
I_CLASS_T_UPPER_LIMIT = 12999
I_CLASS_S_UPPER_LIMIT = 20999
I_CLASS_R_UPPER_LIMIT = 33999
I_CLASS_Q_UPPER_LIMIT = 54999
I_CLASS_P_UPPER_LIMIT = 88999
I_CLASS_O_UPPER_LIMIT = 143999
I_CLASS_N_UPPER_LIMIT = 232999
I_CLASS_M_UPPER_LIMIT = 376999
I_CLASS_L_UPPER_LIMIT = 609999
I_CLASS_K_UPPER_LIMIT = 986999
I_CLASS_J_UPPER_LIMIT = 1596999
I_CLASS_I_UPPER_LIMIT = 2583999
I_CLASS_H_UPPER_LIMIT = 4180999
I_CLASS_G_UPPER_LIMIT = 6764999
I_CLASS_F_UPPER_LIMIT = 10945999
I_CLASS_E_UPPER_LIMIT = 17710999
I_CLASS_D_UPPER_LIMIT = 28656999
I_CLASS_C_UPPER_LIMIT = 46367999
I_CLASS_B_UPPER_LIMIT = 75024999
-- Class A: 1.677.721.600
elseif (i_MODE == 1) then
I_CLASS_Z_UPPER_LIMIT = 99
I_CLASS_Y_UPPER_LIMIT = 199
I_CLASS_X_UPPER_LIMIT = 399
I_CLASS_W_UPPER_LIMIT = 799
I_CLASS_V_UPPER_LIMIT = 1599
I_CLASS_U_UPPER_LIMIT = 3199
I_CLASS_T_UPPER_LIMIT = 6399
I_CLASS_S_UPPER_LIMIT = 12799
I_CLASS_R_UPPER_LIMIT = 25599
I_CLASS_Q_UPPER_LIMIT = 51199
I_CLASS_P_UPPER_LIMIT = 102399
I_CLASS_O_UPPER_LIMIT = 204799
I_CLASS_N_UPPER_LIMIT = 409599
I_CLASS_M_UPPER_LIMIT = 819199
I_CLASS_L_UPPER_LIMIT = 1638399
I_CLASS_K_UPPER_LIMIT = 3276799
I_CLASS_J_UPPER_LIMIT = 6553599
I_CLASS_I_UPPER_LIMIT = 13107199
I_CLASS_H_UPPER_LIMIT = 26214399
I_CLASS_G_UPPER_LIMIT = 52428799
I_CLASS_F_UPPER_LIMIT = 104857599
I_CLASS_E_UPPER_LIMIT = 209715199
I_CLASS_D_UPPER_LIMIT = 419430399
I_CLASS_C_UPPER_LIMIT = 838860799
I_CLASS_B_UPPER_LIMIT = 1677721599
-- Class A: 9.227.466
elseif (i_MODE == 2) then
I_CLASS_Z_UPPER_LIMIT = 89
I_CLASS_Y_UPPER_LIMIT = 144
I_CLASS_X_UPPER_LIMIT = 233
I_CLASS_W_UPPER_LIMIT = 377
I_CLASS_V_UPPER_LIMIT = 610
I_CLASS_U_UPPER_LIMIT = 987
I_CLASS_T_UPPER_LIMIT = 1597
I_CLASS_S_UPPER_LIMIT = 2584
I_CLASS_R_UPPER_LIMIT = 4181
I_CLASS_Q_UPPER_LIMIT = 6765
I_CLASS_P_UPPER_LIMIT = 10946
I_CLASS_O_UPPER_LIMIT = 17711
I_CLASS_N_UPPER_LIMIT = 28657
I_CLASS_M_UPPER_LIMIT = 46368
I_CLASS_L_UPPER_LIMIT = 75025
I_CLASS_K_UPPER_LIMIT = 121393
I_CLASS_J_UPPER_LIMIT = 196418
I_CLASS_I_UPPER_LIMIT = 317811
I_CLASS_H_UPPER_LIMIT = 514229
I_CLASS_G_UPPER_LIMIT = 832040
I_CLASS_F_UPPER_LIMIT = 1346269
I_CLASS_E_UPPER_LIMIT = 2178309
I_CLASS_D_UPPER_LIMIT = 3524578
I_CLASS_C_UPPER_LIMIT = 5702887
I_CLASS_B_UPPER_LIMIT = 9227465
-- Argument: username_tool_lvl
fog.fn_ToolLVLread = function(a_s_keyword)
local i_level = fog.t_MOD_STORAGE:get_int(a_s_keyword)
if (i_level == nil) then
i_level = 0
end
return i_level
end
if (i_EXPERIENCE_POINTS <= I_CLASS_Z_UPPER_LIMIT) then
s_CLASS = fog.l10n('class ') .. '"Z"' .. ' - ' ..
((I_CLASS_Z_UPPER_LIMIT + 1) - i_EXPERIENCE_POINTS) ..
fog.l10n('xp to the next class.')
elseif ((i_EXPERIENCE_POINTS > I_CLASS_Z_UPPER_LIMIT)
and (i_EXPERIENCE_POINTS <= I_CLASS_Y_UPPER_LIMIT))
then
-- Argument: username_tool_xp
fog.fn_ToolClassCheck = function(a_i_tool_xp)
local i_class = 0
s_CLASS = fog.l10n('class ') .. '"Y"' .. ' - ' ..
((I_CLASS_Y_UPPER_LIMIT + 1) - i_EXPERIENCE_POINTS) ..
fog.l10n('xp to the next class.')
-- Diamond capabilities
if (a_i_tool_xp > fog.i_CLASS_B) then
i_class = 1
elseif ((i_EXPERIENCE_POINTS > I_CLASS_Y_UPPER_LIMIT)
and (i_EXPERIENCE_POINTS <= I_CLASS_X_UPPER_LIMIT))
then
-- Mese capabilities
elseif (a_i_tool_xp <= fog.i_CLASS_B)
and (a_i_tool_xp > fog.i_CLASS_C) then
i_class = 2
s_CLASS = fog.l10n('class ') .. '"X"' .. ' - ' ..
((I_CLASS_X_UPPER_LIMIT + 1) - i_EXPERIENCE_POINTS) ..
fog.l10n('xp to the next class.')
-- Steel capabilities
elseif (a_i_tool_xp <= fog.i_CLASS_C)
and (a_i_tool_xp > fog.i_CLASS_D) then
i_class = 3
elseif ((i_EXPERIENCE_POINTS > I_CLASS_X_UPPER_LIMIT)
and (i_EXPERIENCE_POINTS <= I_CLASS_W_UPPER_LIMIT))
then
-- Bronze capabilities
elseif (a_i_tool_xp <= fog.i_CLASS_D)
and (a_i_tool_xp > fog.i_CLASS_E) then
i_class = 4
s_CLASS = fog.l10n('class ') .. '"W"' .. ' - ' ..
((I_CLASS_W_UPPER_LIMIT + 1) - i_EXPERIENCE_POINTS) ..
fog.l10n('xp to the next class.')
elseif ((i_EXPERIENCE_POINTS > I_CLASS_W_UPPER_LIMIT)
and (i_EXPERIENCE_POINTS <= I_CLASS_V_UPPER_LIMIT))
then
s_CLASS = fog.l10n('class ') .. '"V"' .. ' - ' ..
((I_CLASS_V_UPPER_LIMIT + 1) - i_EXPERIENCE_POINTS) ..
fog.l10n('xp to the next class.')
elseif ((i_EXPERIENCE_POINTS > I_CLASS_V_UPPER_LIMIT)
and (i_EXPERIENCE_POINTS <= I_CLASS_U_UPPER_LIMIT))
then
s_CLASS = fog.l10n('class ') .. '"U"' .. ' - ' ..
((I_CLASS_U_UPPER_LIMIT + 1) - i_EXPERIENCE_POINTS) ..
fog.l10n('xp to the next class.')
elseif ((i_EXPERIENCE_POINTS > I_CLASS_U_UPPER_LIMIT)
and (i_EXPERIENCE_POINTS <= I_CLASS_T_UPPER_LIMIT))
then
s_CLASS = fog.l10n('class ') .. '"T"' .. ' - ' ..
((I_CLASS_T_UPPER_LIMIT + 1) - i_EXPERIENCE_POINTS) ..
fog.l10n('xp to the next class.')
elseif ((i_EXPERIENCE_POINTS > I_CLASS_T_UPPER_LIMIT)
and (i_EXPERIENCE_POINTS <= I_CLASS_S_UPPER_LIMIT))
then
s_CLASS = fog.l10n('class ') .. '"S"' .. ' - ' ..
((I_CLASS_S_UPPER_LIMIT + 1) - i_EXPERIENCE_POINTS) ..
fog.l10n('xp to the next class.')
elseif ((i_EXPERIENCE_POINTS > I_CLASS_S_UPPER_LIMIT)
and (i_EXPERIENCE_POINTS <= I_CLASS_R_UPPER_LIMIT))
then
s_CLASS = fog.l10n('class ') .. '"R"' .. ' - ' ..
((I_CLASS_R_UPPER_LIMIT + 1) - i_EXPERIENCE_POINTS) ..
fog.l10n('xp to the next class.')
elseif ((i_EXPERIENCE_POINTS > I_CLASS_R_UPPER_LIMIT)
and (i_EXPERIENCE_POINTS <= I_CLASS_Q_UPPER_LIMIT))
then
s_CLASS = fog.l10n('class ') .. '"Q"' .. ' - ' ..
((I_CLASS_Q_UPPER_LIMIT + 1) - i_EXPERIENCE_POINTS) ..
fog.l10n('xp to the next class.')
elseif ((i_EXPERIENCE_POINTS > I_CLASS_Q_UPPER_LIMIT)
and (i_EXPERIENCE_POINTS <= I_CLASS_P_UPPER_LIMIT))
then
s_CLASS = fog.l10n('class ') .. '"P"' .. ' - ' ..
((I_CLASS_P_UPPER_LIMIT + 1) - i_EXPERIENCE_POINTS) ..
fog.l10n('xp to the next class.')
elseif ((i_EXPERIENCE_POINTS > I_CLASS_P_UPPER_LIMIT)
and (i_EXPERIENCE_POINTS <= I_CLASS_O_UPPER_LIMIT))
then
s_CLASS = fog.l10n('class ') .. '"O"' .. ' - ' ..
((I_CLASS_O_UPPER_LIMIT + 1) - i_EXPERIENCE_POINTS) ..
fog.l10n('xp to the next class.')
elseif ((i_EXPERIENCE_POINTS > I_CLASS_O_UPPER_LIMIT)
and (i_EXPERIENCE_POINTS <= I_CLASS_N_UPPER_LIMIT))
then
s_CLASS = fog.l10n('class ') .. '"N"' .. ' - ' ..
((I_CLASS_N_UPPER_LIMIT + 1) - i_EXPERIENCE_POINTS) ..
fog.l10n('xp to the next class.')
elseif ((i_EXPERIENCE_POINTS > I_CLASS_N_UPPER_LIMIT)
and (i_EXPERIENCE_POINTS <= I_CLASS_M_UPPER_LIMIT))
then
s_CLASS = fog.l10n('class ') .. '"M"' .. ' - ' ..
((I_CLASS_M_UPPER_LIMIT + 1) - i_EXPERIENCE_POINTS) ..
fog.l10n('xp to the next class.')
elseif ((i_EXPERIENCE_POINTS > I_CLASS_M_UPPER_LIMIT)
and (i_EXPERIENCE_POINTS <= I_CLASS_L_UPPER_LIMIT))
then
s_CLASS = fog.l10n('class ') .. '"L"' .. ' - ' ..
((I_CLASS_L_UPPER_LIMIT + 1) - i_EXPERIENCE_POINTS) ..
fog.l10n('xp to the next class.')
elseif ((i_EXPERIENCE_POINTS > I_CLASS_L_UPPER_LIMIT)
and (i_EXPERIENCE_POINTS <= I_CLASS_K_UPPER_LIMIT))
then
s_CLASS = fog.l10n('class ') .. '"K"' .. ' - ' ..
((I_CLASS_K_UPPER_LIMIT + 1) - i_EXPERIENCE_POINTS) ..
fog.l10n('xp to the next class.')
elseif ((i_EXPERIENCE_POINTS > I_CLASS_K_UPPER_LIMIT)
and (i_EXPERIENCE_POINTS <= I_CLASS_J_UPPER_LIMIT))
then
s_CLASS = fog.l10n('class ') .. '"J"' .. ' - ' ..
((I_CLASS_J_UPPER_LIMIT + 1) - i_EXPERIENCE_POINTS) ..
fog.l10n('xp to the next class.')
elseif ((i_EXPERIENCE_POINTS > I_CLASS_J_UPPER_LIMIT)
and (i_EXPERIENCE_POINTS <= I_CLASS_I_UPPER_LIMIT))
then
s_CLASS = fog.l10n('class ') .. '"I"' .. ' - ' ..
((I_CLASS_I_UPPER_LIMIT + 1) - i_EXPERIENCE_POINTS) ..
fog.l10n('xp to the next class.')
elseif ((i_EXPERIENCE_POINTS > I_CLASS_I_UPPER_LIMIT)
and (i_EXPERIENCE_POINTS <= I_CLASS_H_UPPER_LIMIT))
then
s_CLASS = fog.l10n('class ') .. '"H"' .. ' - ' ..
((I_CLASS_H_UPPER_LIMIT + 1) - i_EXPERIENCE_POINTS) ..
fog.l10n('xp to the next class.')
elseif ((i_EXPERIENCE_POINTS > I_CLASS_H_UPPER_LIMIT)
and (i_EXPERIENCE_POINTS <= I_CLASS_G_UPPER_LIMIT))
then
s_CLASS = fog.l10n('class ') .. '"G"' .. ' - ' ..
((I_CLASS_G_UPPER_LIMIT + 1) - i_EXPERIENCE_POINTS) ..
fog.l10n('xp to the next class.')
elseif ((i_EXPERIENCE_POINTS > I_CLASS_G_UPPER_LIMIT)
and (i_EXPERIENCE_POINTS <= I_CLASS_F_UPPER_LIMIT))
then
s_CLASS = fog.l10n('class ') .. '"F"' .. ' - ' ..
((I_CLASS_F_UPPER_LIMIT + 1) - i_EXPERIENCE_POINTS) ..
fog.l10n('xp to the next class.')
elseif ((i_EXPERIENCE_POINTS > I_CLASS_F_UPPER_LIMIT)
and (i_EXPERIENCE_POINTS <= I_CLASS_E_UPPER_LIMIT))
then
s_CLASS = fog.l10n('class ') .. '"E"' .. ' - ' ..
((I_CLASS_E_UPPER_LIMIT + 1) - i_EXPERIENCE_POINTS) ..
fog.l10n('xp to the next class.')
elseif ((i_EXPERIENCE_POINTS > I_CLASS_E_UPPER_LIMIT)
and (i_EXPERIENCE_POINTS <= I_CLASS_D_UPPER_LIMIT))
then
s_CLASS = fog.l10n('class ') .. '"D"' .. ' - ' ..
((I_CLASS_D_UPPER_LIMIT + 1) - i_EXPERIENCE_POINTS) ..
fog.l10n('xp to the next class.')
elseif ((i_EXPERIENCE_POINTS > I_CLASS_D_UPPER_LIMIT)
and (i_EXPERIENCE_POINTS <= I_CLASS_C_UPPER_LIMIT))
then
s_CLASS = fog.l10n('class ') .. '"C"' .. ' - ' ..
((I_CLASS_C_UPPER_LIMIT + 1) - i_EXPERIENCE_POINTS) ..
fog.l10n('xp to the next class.')
elseif ((i_EXPERIENCE_POINTS > I_CLASS_C_UPPER_LIMIT)
and (i_EXPERIENCE_POINTS <= I_CLASS_B_UPPER_LIMIT))
then
s_CLASS = fog.l10n('class ') .. '"B"' .. ' - ' ..
((I_CLASS_B_UPPER_LIMIT + 1) - i_EXPERIENCE_POINTS) ..
fog.l10n('xp to the next class.')
-- Stone capabilities
elseif (a_i_tool_xp <= fog.i_CLASS_E)
and (a_i_tool_xp > fog.i_CLASS_F) then
i_class = 5
-- Wood capabilities
else
s_CLASS = fog.l10n('class ') .. '"A"'
i_class = 6
end
return s_CLASS
print('Tool class: ' .. i_class)
return i_class
end
-- Used to determine an item's durability
fog.fn_ToolsAxesUses = function(a_t_itemstack)
local s_ITEM_NAME = a_t_itemstack:get_name()
local i_ITEM_USES = 0
-- This is used to update the character's sheet inventory tab
fog.fn_FogMTGstats = function(a_s_player)
--print("Item name: " .. s_ITEM_NAME)
-- Constants
local s_LEVEL_AXE = fog.l10n('Axe: ');
local s_LEVEL_HOE = fog.l10n('Hoe: ');
local s_LEVEL_PICK = fog.l10n('Pick: ');
local s_LEVEL_SHOVEL = fog.l10n('Shovel: ');
local s_LEVEL_SWORD = fog.l10n('Sword: ');
if (string.match(s_ITEM_NAME, 'wood') ~= nil) then
i_ITEM_USES = 10
-- Variables
local s_formspecText = '';
local s_keyword = a_s_player:get_player_name() .. '_';
elseif (string.match(s_ITEM_NAME, 'stone') ~= nil) then
i_ITEM_USES = 20
local i_levelAxe, i_levelHoe, i_levelPick, i_levelShovel, i_levelSword
elseif (string.match(s_ITEM_NAME, 'bronze') ~= nil) then
i_ITEM_USES = 20
i_levelAxe = fog.fn_LevelCheck(s_keyword .. 'i_xp_axe');
i_levelHoe = fog.fn_LevelCheck(s_keyword .. 'i_xp_hoe');
i_levelPick = fog.fn_LevelCheck(s_keyword .. 'i_xp_pick');
i_levelShovel = fog.fn_LevelCheck(s_keyword .. 'i_xp_shovel');
i_levelSword = fog.fn_LevelCheck(s_keyword .. 'i_xp_sword');
elseif (string.match(s_ITEM_NAME, 'steel') ~= nil) then
i_ITEM_USES = 20
s_formspecText = s_LEVEL_AXE .. i_levelAxe .. ',' ..
s_LEVEL_HOE .. i_levelHoe .. ',' ..
s_LEVEL_PICK .. i_levelPick .. ',' ..
s_LEVEL_SHOVEL .. i_levelShovel .. ',' ..
s_LEVEL_SWORD .. i_levelSword
elseif (string.match(s_ITEM_NAME, 'mese') ~= nil) then
i_ITEM_USES = 20
return s_formspecText
end
elseif (string.match(s_ITEM_NAME, 'diamond') ~= nil) then
i_ITEM_USES = 30
-- This is used to register the charaxter's sheet inventory tab
sfinv.register_page('fog:charsheet', {
title = fog.l10n('Character\'s sheet'),
get = function(self, player, context)
local s_formspecString = fog.fn_FogMTGstats(player)
return sfinv.make_formspec(player, context,
'textlist[0,0;7.8,4.5;;' .. s_formspecString .. ']', true)
end
})
return i_ITEM_USES
end
-- Used to determine an item's durability
fog.fn_ToolsPicksUses = function(a_t_itemstack)
local s_ITEM_NAME = a_t_itemstack:get_name()
local i_ITEM_USES = 0
--print("Item name: " .. s_ITEM_NAME)
if (string.match(s_ITEM_NAME, 'wood') ~= nil) then
i_ITEM_USES = 10
elseif (string.match(s_ITEM_NAME, 'stone') ~= nil) then
i_ITEM_USES = 20
elseif (string.match(s_ITEM_NAME, 'bronze') ~= nil) then
i_ITEM_USES = 20
elseif (string.match(s_ITEM_NAME, 'steel') ~= nil) then
i_ITEM_USES = 20
elseif (string.match(s_ITEM_NAME, 'mese') ~= nil) then
i_ITEM_USES = 20
elseif (string.match(s_ITEM_NAME, 'diamond') ~= nil) then
i_ITEM_USES = 30
end
return i_ITEM_USES
end
-- Used to determine an item's durability
fog.fn_ToolsShovelsUses = function(a_t_itemstack)
local s_ITEM_NAME = a_t_itemstack:get_name()
local i_ITEM_USES = 0
--print("Item name: " .. s_ITEM_NAME)
if (string.match(s_ITEM_NAME, 'wood') ~= nil) then
i_ITEM_USES = 10
elseif (string.match(s_ITEM_NAME, 'stone') ~= nil) then
i_ITEM_USES = 20
elseif (string.match(s_ITEM_NAME, 'bronze') ~= nil) then
i_ITEM_USES = 25
elseif (string.match(s_ITEM_NAME, 'steel') ~= nil) then
i_ITEM_USES = 30
elseif (string.match(s_ITEM_NAME, 'mese') ~= nil) then
i_ITEM_USES = 20
elseif (string.match(s_ITEM_NAME, 'diamond') ~= nil) then
i_ITEM_USES = 30
end
return i_ITEM_USES
end
-- Used to determine an item's durability
fog.fn_ToolsSwordsUses = function(a_t_itemstack)
local s_ITEM_NAME = a_t_itemstack:get_name()
local i_ITEM_USES = 0
--print("Item name: " .. s_ITEM_NAME)
if (string.match(s_ITEM_NAME, 'wood') ~= nil) then
i_ITEM_USES = 10
elseif (string.match(s_ITEM_NAME, 'stone') ~= nil) then
i_ITEM_USES = 20
elseif (string.match(s_ITEM_NAME, 'bronze') ~= nil) then
i_ITEM_USES = 25
elseif (string.match(s_ITEM_NAME, 'steel') ~= nil) then
i_ITEM_USES = 30
elseif (string.match(s_ITEM_NAME, 'mese') ~= nil) then
i_ITEM_USES = 30
elseif (string.match(s_ITEM_NAME, 'diamond') ~= nil) then
i_ITEM_USES = 40
end
return i_ITEM_USES
end

View File

@ -1,68 +0,0 @@
--[[
Fate of the Gods - Adds roleplay mechanics.
Copyright © 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.
--]]
--
-- Nodes
--
minetest.register_node('fog:test', {
description = fog.l10n('Test'),
tiles = {"default_steel_block.png^[colorize:black:200"},
groups = {dig_immediate = 2},
on_punch = function(pos, node, puncher, pointed_thing)
if (puncher:is_player() == true) then
local s_playerName = puncher:get_player_name();
local s_keyword = s_playerName .. '_hits'
local i_hitsNumber = fog.fn_ReadDatabase(s_keyword)
print(dump(i_hitsNumber));
if (i_hitsNumber == nil) then
i_hitsNumber = 0
end
i_hitsNumber = (i_hitsNumber + 1)
print(dump(i_hitsNumber));
fog.pr_WriteDatabase(s_keyword, i_hitsNumber)
sfinv.override_page('fog:charsheet', {
title = fog.l10n('Character\'s sheet'),
get = function(self, player, context)
local s_formspecString = fog.fn_FogMTGstats(player)
return sfinv.make_formspec(player, context,
'textlist[0,0;7.8,4.5;;' .. s_formspecString ..
']', true)
end
})
end
end
})

78
core/overriders_axes.lua Normal file
View File

@ -0,0 +1,78 @@
--[[
Fate of the Gods - Adds roleplay mechanics.
Copyright © 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.
--]]
--
-- Procedure
--
local pr_OverrideAxes = function()
local t_list = {
'default:axe_wood', 'default:axe_stone', 'default:axe_bronze',
'default:axe_steel', 'default:axe_mese', 'default:axe_diamond'
}
for i_element = 1, 6 do
minetest.override_item(t_list[i_element], {
after_use = function(itemstack, user, node, digparams)
itemstack:add_wear(digparams.wear)
if (user:is_player() == true) then
local s_USER_NAME = user:get_player_name()
local s_KEY_XP = s_USER_NAME .. '_i_xp_axe'
local s_KEY_RANK = s_USER_NAME .. '_i_rank_axe'
local i_CURRENT_XP = 0
local i_CURRENT_CLASS = 0
-- Add the new experience points
fog.pr_ToolXPwrite(s_KEY_XP)
-- Update the associated variable
i_CURRENT_XP = fog.fn_ToolXPread(s_KEY_XP)
-- Update the level rank
i_CURRENT_CLASS = fog.fn_ToolClassCheck(i_CURRENT_XP)
-- Save the rank for the current tool
fog.pr_ToolLVLwrite(s_KEY_RANK, i_CURRENT_CLASS)
-- Update the wield item tool capabilities
fog.pr_ToolOverrider(itemstack, i_CURRENT_CLASS, 'axe')
-- Update the character's sheet
fog.pr_OverrideFormspec()
end
return itemstack
end
})
end
end
--
-- Main body
--
pr_OverrideAxes()

78
core/overriders_picks.lua Normal file
View File

@ -0,0 +1,78 @@
--[[
Fate of the Gods - Adds roleplay mechanics.
Copyright © 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.
--]]
--
-- Procedure
--
local pr_OverridePicks = function()
local t_list = {
'default:pick_wood', 'default:pick_stone', 'default:pick_bronze',
'default:pick_steel', 'default:pick_mese', 'default:pick_diamond'
}
for i_element = 1, 6 do
minetest.override_item(t_list[i_element], {
after_use = function(itemstack, user, node, digparams)
itemstack:add_wear(digparams.wear)
if (user:is_player() == true) then
local s_USER_NAME = user:get_player_name()
local s_KEY_XP = s_USER_NAME .. '_i_xp_pick'
local s_KEY_RANK = s_USER_NAME .. '_i_rank_pick'
local i_CURRENT_XP = 0
local i_CURRENT_CLASS = 0
-- Add the new experience points
fog.pr_ToolXPwrite(s_KEY_XP)
-- Update the associated variable
i_CURRENT_XP = fog.fn_ToolXPread(s_KEY_XP)
-- Update the level rank
i_CURRENT_CLASS = fog.fn_ToolClassCheck(i_CURRENT_XP)
-- Save the rank for the current tool
fog.pr_ToolLVLwrite(s_KEY_RANK, i_CURRENT_CLASS)
-- Update the wield item tool capabilities
fog.pr_ToolOverrider(itemstack, i_CURRENT_CLASS, 'pick')
-- Update the character's sheet
fog.pr_OverrideFormspec()
end
return itemstack
end
})
end
end
--
-- Main body
--
pr_OverridePicks()

View File

@ -0,0 +1,78 @@
--[[
Fate of the Gods - Adds roleplay mechanics.
Copyright © 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.
--]]
--
-- Procedure
--
local pr_OverrideShovels = function()
local t_list = {
'default:shovel_wood', 'default:shovel_stone', 'default:shovel_bronze',
'default:shovel_steel', 'default:shovel_mese', 'default:shovel_diamond'
}
for i_element = 1, 6 do
minetest.override_item(t_list[i_element], {
after_use = function(itemstack, user, node, digparams)
itemstack:add_wear(digparams.wear)
if (user:is_player() == true) then
local s_USER_NAME = user:get_player_name()
local s_KEY_XP = s_USER_NAME .. '_i_xp_shovel'
local s_KEY_RANK = s_USER_NAME .. '_i_rank_shovel'
local i_CURRENT_XP = 0
local i_CURRENT_CLASS = 0
-- Add the new experience points
fog.pr_ToolXPwrite(s_KEY_XP)
-- Update the associated variable
i_CURRENT_XP = fog.fn_ToolXPread(s_KEY_XP)
-- Update the level rank
i_CURRENT_CLASS = fog.fn_ToolClassCheck(i_CURRENT_XP)
-- Save the rank for the current tool
fog.pr_ToolLVLwrite(s_KEY_RANK, i_CURRENT_CLASS)
-- Update the wield item tool capabilities
fog.pr_ToolOverrider(itemstack, i_CURRENT_CLASS, 'shovel')
-- Update the character's sheet
fog.pr_OverrideFormspec()
end
return itemstack
end
})
end
end
--
-- Main body
--
pr_OverrideShovels()

View File

@ -0,0 +1,78 @@
--[[
Fate of the Gods - Adds roleplay mechanics.
Copyright © 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.
--]]
--
-- Procedure
--
local pr_OverrideSwords = function()
local t_list = {
'default:sword_wood', 'default:sword_stone', 'default:sword_bronze',
'default:sword_steel', 'default:sword_mese', 'default:sword_diamond'
}
for i_element = 1, 6 do
minetest.override_item(t_list[i_element], {
after_use = function(itemstack, user, node, digparams)
itemstack:add_wear(digparams.wear)
if (user:is_player() == true) then
local s_USER_NAME = user:get_player_name()
local s_KEY_XP = s_USER_NAME .. '_i_xp_sword'
local s_KEY_RANK = s_USER_NAME .. '_i_rank_sword'
local i_CURRENT_XP = 0
local i_CURRENT_CLASS = 0
-- Add the new experience points
fog.pr_ToolXPwrite(s_KEY_XP)
-- Update the associated variable
i_CURRENT_XP = fog.fn_ToolXPread(s_KEY_XP)
-- Update the level rank
i_CURRENT_CLASS = fog.fn_ToolClassCheck(i_CURRENT_XP)
-- Save the rank for the current tool
fog.pr_ToolLVLwrite(s_KEY_RANK, i_CURRENT_CLASS)
-- Update the wield item tool capabilities
fog.pr_ToolOverrider(itemstack, i_CURRENT_CLASS, 'sword')
-- Update the character's sheet
fog.pr_OverrideFormspec()
end
return itemstack
end
})
end
end
--
-- Main body
--
pr_OverrideSwords()

View File

@ -26,150 +26,366 @@
-- Procedures
--
-- This is used to write data in the database
fog.pr_WriteDatabase = function(a_s_keyword, a_i_number)
fog.t_MOD_DATABASE:set_int(a_s_keyword, a_i_number)
-- Argument: username_tool_xp
fog.pr_ToolXPwrite = function(a_s_keyword)
local i_experience = fog.fn_ToolXPread(a_s_keyword)
i_experience = (i_experience + 1)
fog.t_MOD_STORAGE:set_int(a_s_keyword, i_experience)
end
-- This is used to override the default Minetest Game's tools and weapons
fog.pr_MTGAfterUseOverrider = function()
-- Constant
local t_MTGtools = {
-- Wooden
{"default:pick_wood", "i_xp_pick"},
{"default:shovel_wood", "i_xp_shovel"},
{"default:axe_wood", "i_xp_axe"},
{"farming:hoe_wood", "i_xp_hoe"},
-- Stone
{"default:pick_stone", "i_xp_pick"},
{"default:shovel_stone", "i_xp_shovel"},
{"default:axe_stone", "i_xp_axe"},
{"farming:hoe_stone", "i_xp_hoe"},
-- Bronze
{"default:pick_bronze", "i_xp_pick"},
{"default:shovel_bronze", "i_xp_shovel"},
{"default:axe_bronze", "i_xp_axe"},
{"farming:hoe_bronze", "i_xp_hoe"},
-- Steel
{"default:pick_steel", "i_xp_pick"},
{"default:shovel_steel", "i_xp_shovel"},
{"default:axe_steel", "i_xp_axe"},
{"farming:hoe_steel", "i_xp_hoe"},
-- Mese
{"default:pick_mese", "i_xp_pick"},
{"default:shovel_mese", "i_xp_shovel"},
{"default:axe_mese", "i_xp_axe"},
{"farming:hoe_mese", "i_xp_hoe"},
-- Diamond
{"default:pick_diamond", "i_xp_pick"},
{"default:shovel_diamond", "i_xp_shovel"},
{"default:axe_diamond", "i_xp_axe"},
{"farming:hoe_diamond", "i_xp_hoe"}
}
-- Weapons
local t_MTGswords = {
{"default:sword_wood", "i_xp_sword"},
{"default:sword_stone", "i_xp_sword"},
{"default:sword_bronze", "i_xp_sword"},
{"default:sword_steel", "i_xp_sword"},
{"default:sword_mese", "i_xp_sword"},
{"default:sword_diamond", "i_xp_sword"}
}
-- Body
-- Tools overrider
for _, value in ipairs(t_MTGtools) do
minetest.override_item(value[1], {
after_use = function(itemstack, user, node, digparams)
itemstack:add_wear(digparams.wear)
if (user:is_player() == true) then
local s_playerName = user:get_player_name();
local s_keyword = s_playerName .. '_' .. value[2]
local i_xp_type = fog.fn_ReadDatabase(s_keyword)
if (i_xp_type == nil) then
i_xp_type = 0
end
i_xp_type = (i_xp_type + 1)
fog.pr_WriteDatabase(s_keyword, i_xp_type)
sfinv.override_page('fog:charsheet', {
title = fog.l10n('Character\'s sheet'),
get = function(self, player, context)
local s_formspecString = fog.fn_FogMTGstats(player)
return sfinv.make_formspec(player, context,
'textlist[0,0;7.8,4.5;;' .. s_formspecString ..
']', true)
end
})
end
return itemstack
end
})
end
-- Weapons overrider
for _, value in ipairs(t_MTGswords) do
minetest.override_item(value[1], {
after_use = function(itemstack, user, node, digparams)
itemstack:add_wear(digparams.wear)
if (user:is_player() == true) then
local s_playerName = user:get_player_name();
local s_keyword = s_playerName .. '_' .. value[2]
local i_xp_type = fog.fn_ReadDatabase(s_keyword)
if (i_xp_type == nil) then
i_xp_type = 0
end
i_xp_type = (i_xp_type + 1)
fog.pr_WriteDatabase(s_keyword, i_xp_type)
sfinv.override_page('fog:charsheet', {
title = fog.l10n('Character\'s sheet'),
get = function(self, player, context)
local s_formspecString = fog.fn_FogMTGstats(player)
return sfinv.make_formspec(player, context,
'textlist[0,0;7.8,4.5;;' .. s_formspecString ..
']', true)
end
})
end
return itemstack
end
})
end
-- Arguments:
-- username_tool_lvl
-- i_lvl
fog.pr_ToolLVLwrite = function(a_s_keyword, a_i_lvl)
fog.t_MOD_STORAGE:set_int(a_s_keyword, a_i_lvl)
end
-- Arguments: a_t_itemstack
-- a_i_level
-- a_s_type
fog.pr_ToolOverrider = function(a_t_itemstack, a_i_level, a_s_type)
local t_TOOL_CAPABILITIES = {}
-- Diamond capabilities
if (a_i_level == 1) then
if (a_s_type == 'axe') then
local i_TOOL_USES = fog.fn_ToolsAxesUses(a_t_itemstack)
t_TOOL_CAPABILITIES = {
full_punch_interval = 0.9,
max_drop_level=1,
groupcaps={
choppy={times={[1]=2.10, [2]=0.90, [3]=0.50},
uses=i_TOOL_USES, maxlevel=3},
},
damage_groups = {fleshy=7},
}
elseif (a_s_type == 'pick') then
local i_TOOL_USES = fog.fn_ToolsPicksUses(a_t_itemstack)
t_TOOL_CAPABILITIES = {
full_punch_interval = 0.9,
max_drop_level=3,
groupcaps={
cracky = {times={[1]=2.0, [2]=1.0, [3]=0.50},
uses=i_TOOL_USES, maxlevel=3},
},
damage_groups = {fleshy=5},
}
elseif (a_s_type == 'shovel') then
local i_TOOL_USES = fog.fn_ToolsShovelsUses(a_t_itemstack)
t_TOOL_CAPABILITIES = {
full_punch_interval = 1.0,
max_drop_level=1,
groupcaps={
crumbly = {times={[1]=1.10, [2]=0.50, [3]=0.30},
uses=i_TOOL_USES, maxlevel=3},
},
damage_groups = {fleshy=4},
}
elseif (a_s_type == 'sword') then
local i_TOOL_USES = fog.fn_ToolsSwordsUses(a_t_itemstack)
t_TOOL_CAPABILITIES = {
full_punch_interval = 0.7,
max_drop_level=1,
groupcaps={
snappy={times={[1]=1.90, [2]=0.90, [3]=0.30},
uses=i_TOOL_USES, maxlevel=3},
},
damage_groups = {fleshy=8},
}
end
-- Mese capabilities
elseif (a_i_level == 2) then
if (a_s_type == 'axe') then
local i_TOOL_USES = fog.fn_ToolsAxesUses(a_t_itemstack)
t_TOOL_CAPABILITIES = {
full_punch_interval = 0.9,
max_drop_level=1,
groupcaps={
choppy={times={[1]=2.20, [2]=1.00, [3]=0.60},
uses=i_TOOL_USES, maxlevel=3},
},
damage_groups = {fleshy=6},
}
elseif (a_s_type == 'pick') then
local i_TOOL_USES = fog.fn_ToolsPicksUses(a_t_itemstack)
t_TOOL_CAPABILITIES = {
full_punch_interval = 0.9,
max_drop_level=3,
groupcaps={
cracky = {times={[1]=2.4, [2]=1.2, [3]=0.60},
uses=i_TOOL_USES, maxlevel=3},
},
damage_groups = {fleshy=5},
}
elseif (a_s_type == 'shovel') then
local i_TOOL_USES = fog.fn_ToolsShovelsUses(a_t_itemstack)
t_TOOL_CAPABILITIES = {
full_punch_interval = 1.0,
max_drop_level=3,
groupcaps={
crumbly = {times={[1]=1.20, [2]=0.60, [3]=0.30},
uses=i_TOOL_USES, maxlevel=3},
},
damage_groups = {fleshy=4},
}
elseif (a_s_type == 'sword') then
local i_TOOL_USES = fog.fn_ToolsSwordsUses(a_t_itemstack)
t_TOOL_CAPABILITIES = {
full_punch_interval = 0.7,
max_drop_level=1,
groupcaps={
snappy={times={[1]=2.0, [2]=1.00, [3]=0.35},
uses=i_TOOL_USES, maxlevel=3},
},
damage_groups = {fleshy=7},
}
end
-- Steel capabilities
elseif (a_i_level == 3) then
if (a_s_type == 'axe') then
local i_TOOL_USES = fog.fn_ToolsAxesUses(a_t_itemstack)
t_TOOL_CAPABILITIES = {
full_punch_interval = 1.0,
max_drop_level=1,
groupcaps={
choppy={times={[1]=2.50, [2]=1.40, [3]=1.00},
uses=i_TOOL_USES, maxlevel=2},
},
damage_groups = {fleshy=4},
}
elseif (a_s_type == 'pick') then
local i_TOOL_USES = fog.fn_ToolsPicksUses(a_t_itemstack)
t_TOOL_CAPABILITIES = {
full_punch_interval = 1.0,
max_drop_level=1,
groupcaps={
cracky = {times={[1]=4.00, [2]=1.60, [3]=0.80},
uses=i_TOOL_USES, maxlevel=2},
},
damage_groups = {fleshy=4},
}
elseif (a_s_type == 'shovel') then
local i_TOOL_USES = fog.fn_ToolsShovelsUses(a_t_itemstack)
t_TOOL_CAPABILITIES = {
full_punch_interval = 1.1,
max_drop_level=1,
groupcaps={
crumbly = {times={[1]=1.50, [2]=0.90, [3]=0.40},
uses=i_TOOL_USES, maxlevel=2},
},
damage_groups = {fleshy=3},
}
elseif (a_s_type == 'sword') then
local i_TOOL_USES = fog.fn_ToolsSwordsUses(a_t_itemstack)
t_TOOL_CAPABILITIES = {
full_punch_interval = 0.8,
max_drop_level=1,
groupcaps={
snappy={times={[1]=2.5, [2]=1.20, [3]=0.35},
uses=i_TOOL_USES, maxlevel=2},
},
damage_groups = {fleshy=6},
}
end
-- Bronze capabilities
elseif (a_i_level == 4) then
if (a_s_type == 'axe') then
local i_TOOL_USES = fog.fn_ToolsAxesUses(a_t_itemstack)
t_TOOL_CAPABILITIES = {
full_punch_interval = 1.0,
max_drop_level=1,
groupcaps={
choppy={times={[1]=2.75, [2]=1.70, [3]=1.15},
uses=i_TOOL_USES, maxlevel=2},
},
damage_groups = {fleshy=4},
}
elseif (a_s_type == 'pick') then
local i_TOOL_USES = fog.fn_ToolsPicksUses(a_t_itemstack)
t_TOOL_CAPABILITIES = {
full_punch_interval = 1.0,
max_drop_level=1,
groupcaps={
cracky = {times={[1]=4.50, [2]=1.80, [3]=0.90},
uses=i_TOOL_USES, maxlevel=2},
},
damage_groups = {fleshy=4},
}
elseif (a_s_type == 'shovel') then
local i_TOOL_USES = fog.fn_ToolsShovelsUses(a_t_itemstack)
t_TOOL_CAPABILITIES = {
full_punch_interval = 1.1,
max_drop_level=1,
groupcaps={
crumbly = {times={[1]=1.65, [2]=1.05, [3]=0.45},
uses=i_TOOL_USES, maxlevel=2},
},
damage_groups = {fleshy=3},
}
elseif (a_s_type == 'sword') then
local i_TOOL_USES = fog.fn_ToolsSwordsUses(a_t_itemstack)
t_TOOL_CAPABILITIES = {
full_punch_interval = 0.8,
max_drop_level=1,
groupcaps={
snappy={times={[1]=2.75, [2]=1.30, [3]=0.375},
uses=i_TOOL_USES, maxlevel=2},
},
damage_groups = {fleshy=6},
}
end
-- Stone capabilities
elseif (a_i_level == 5) then
if (a_s_type == 'axe') then
local i_TOOL_USES = fog.fn_ToolsAxesUses(a_t_itemstack)
t_TOOL_CAPABILITIES = {
full_punch_interval = 1.2,
max_drop_level=0,
groupcaps={
choppy={times={[1]=3.00, [2]=2.00, [3]=1.30},
uses=i_TOOL_USES, maxlevel=1},
},
damage_groups = {fleshy=3},
}
elseif (a_s_type == 'pick') then
local i_TOOL_USES = fog.fn_ToolsPicksUses(a_t_itemstack)
t_TOOL_CAPABILITIES = {
full_punch_interval = 1.3,
max_drop_level=0,
groupcaps={
cracky = {times={[2]=2.0, [3]=1.00},
uses=i_TOOL_USES, maxlevel=1},
},
damage_groups = {fleshy=3},
}
elseif (a_s_type == 'shovel') then
local i_TOOL_USES = fog.fn_ToolsShovelsUses(a_t_itemstack)
t_TOOL_CAPABILITIES = {
full_punch_interval = 1.4,
max_drop_level=0,
groupcaps={
crumbly = {times={[1]=1.80, [2]=1.20, [3]=0.50},
uses=i_TOOL_USES, maxlevel=1},
},
damage_groups = {fleshy=2},
}
elseif (a_s_type == 'sword') then
local i_TOOL_USES = fog.fn_ToolsSwordsUses(a_t_itemstack)
t_TOOL_CAPABILITIES = {
full_punch_interval = 1.2,
max_drop_level=0,
groupcaps={
snappy={times={[2]=1.4, [3]=0.40}, uses=i_TOOL_USES,
maxlevel=1},
},
damage_groups = {fleshy=4},
}
end
-- Wood capabilities
elseif (a_i_level == 6) then
if (a_s_type == 'axe') then
local i_TOOL_USES = fog.fn_ToolsAxesUses(a_t_itemstack)
t_TOOL_CAPABILITIES = {
full_punch_interval = 1.0,
max_drop_level=0,
groupcaps={
choppy = {times={[2]=3.00, [3]=1.60}, uses=i_TOOL_USES,
maxlevel=1},
},
damage_groups = {fleshy=2},
}
elseif (a_s_type == 'pick') then
local i_TOOL_USES = fog.fn_ToolsPicksUses(a_t_itemstack)
t_TOOL_CAPABILITIES = {
full_punch_interval = 1.2,
max_drop_level=0,
groupcaps={
cracky = {times={[3]=1.60}, uses=i_TOOL_USES, maxlevel=1},
},
damage_groups = {fleshy=2},
}
elseif (a_s_type == 'shovel') then
local i_TOOL_USES = fog.fn_ToolsShovelsUses(a_t_itemstack)
t_TOOL_CAPABILITIES = {
full_punch_interval = 1.2,
max_drop_level=0,
groupcaps={
crumbly = {times={[1]=3.00, [2]=1.60, [3]=0.60},
uses=i_TOOL_USES, maxlevel=1},
},
damage_groups = {fleshy=2},
}
elseif (a_s_type == 'sword') then
local i_TOOL_USES = fog.fn_ToolsSwordsUses(a_t_itemstack)
t_TOOL_CAPABILITIES = {
full_punch_interval = 1,
max_drop_level=0,
groupcaps={
snappy={times={[2]=1.6, [3]=0.40}, uses=i_TOOL_USES,
maxlevel=1},
},
damage_groups = {fleshy=2},
}
end
end
a_t_itemstack:get_meta():set_tool_capabilities(t_TOOL_CAPABILITIES)
end

34
core/settings.lua Normal file
View File

@ -0,0 +1,34 @@
--[[
Fate of the Gods - Adds roleplay mechanics.
Copyright © 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
--
fog.i_CLASS_F = 999 -- 0 to Class F = Wood capabilities
fog.i_CLASS_E = 9999 -- 1000 to Class E = Stone capabilities
fog.i_CLASS_D = 14999 -- 10000 to Class D = Bronze capabilities
fog.i_CLASS_C = 19999 -- 15000 to Class C = Steel capabilities
fog.i_CLASS_B = 29999 -- 20000 to Class B = Mese capabilities
-- >= 30000 = Diamond capabilities

View File

@ -22,26 +22,18 @@
--]]
--
-- Global mod's namespace
--
fog = {}
--
-- Global constants
--
-- Mod's database
fog.t_MOD_STORAGE = minetest.get_mod_storage()
-- Used for localization
fog.l10n = minetest.get_translator('fog')
-- Used to store data
fog.t_MOD_DATABASE = minetest.get_mod_storage()
--
-- Local procedures
-- Procedures
--
-- Minetest logger
@ -56,7 +48,7 @@ local pr_LogMessage = function()
or (s_LOG_LEVEL == 'info')
or (s_LOG_LEVEL == 'verbose')
then
minetest.log('action', '[Mod] Fate of the Gods [v0.1.0] loaded.')
minetest.log('action', '[Mod] Fate of The Gods [v0.1.0] loaded.')
end
end
@ -68,9 +60,14 @@ local pr_LoadSubFiles = function()
local s_MOD_PATH = minetest.get_modpath('fog')
-- Body
dofile(s_MOD_PATH .. '/core/settings.lua')
dofile(s_MOD_PATH .. '/core/functions.lua')
dofile(s_MOD_PATH .. '/core/procedures.lua')
dofile(s_MOD_PATH .. '/core/nodes.lua')
dofile(s_MOD_PATH .. '/core/formspec.lua')
dofile(s_MOD_PATH .. '/core/overriders_axes.lua')
dofile(s_MOD_PATH .. '/core/overriders_picks.lua')
dofile(s_MOD_PATH .. '/core/overriders_shovels.lua')
dofile(s_MOD_PATH .. '/core/overriders_swords.lua')
end
@ -80,8 +77,4 @@ end
--
pr_LoadSubFiles()
-- Minetest Game's tools and weapons "after use" overrider
fog.pr_MTGAfterUseOverrider()
pr_LogMessage()

View File

@ -1,10 +1,8 @@
# textdomain:fog
class =classe
xp to the next class.=p.e. alla prossima classe.
Axe: =Ascia:
Hoe: =Zappa:
Pick: =Piccone:
Shovel: =Pala:
Sword: =Spada:
Character's sheet=Scheda PG
P.C. sheet=Scheda P.G.
Axe class: = Classe ascia:
Pick class: = Classe piccone:
Shovel class: = Classe pala:
Sword class: = Classe spada:
experience points)= punti esperienza)

View File

@ -1,10 +1,8 @@
# textdomain:fog
class =
xp to the next class.=
Axe: =
Hoe: =
Pick: =
Shovel: =
Sword: =
Character's sheet=
P.C. sheet=
Axe class: =
Pick class: =
Shovel class: =
Sword class: =
experience points)=