From 4de4dd46efaea5b63fac3c7e5bb7d98159e9278f Mon Sep 17 00:00:00 2001 From: alek13 Date: Sat, 9 Nov 2024 06:39:33 +0300 Subject: [PATCH] Effects Int: Potions: add ingredients for potions. Closes #1779 --- .../Tools/lord_potions/src/lord_potions.lua | 16 +++++- .../lord_potions/src/lord_potions/api.lua | 8 +++ .../src/lord_potions/api/ingredient.lua | 46 ++++++++++++++++++ .../src/lord_potions/api/potion.lua | 13 ++--- .../lord_potions/src/lord_potions/config.lua | 13 +++++ .../src/lord_potions/config/ingredients.lua | 40 +++++++++++++++ .../lord_potions_ingredient_bonedust.png | Bin 0 -> 238 bytes .../lord_potions_ingredient_geodes.png | Bin 0 -> 343 bytes .../lord_potions_ingredient_mese.png | Bin 0 -> 303 bytes .../lord_potions_ingredient_mordor.png | Bin 0 -> 233 bytes .../lord_potions_ingredient_obsidian.png | Bin 0 -> 225 bytes .../lord_potions_ingredient_seregon.png | Bin 0 -> 277 bytes .../lord_potions_bottle_content_mask.png | Bin 169 -> 167 bytes 13 files changed, 128 insertions(+), 8 deletions(-) create mode 100644 mods/lord/Tools/lord_potions/src/lord_potions/api.lua create mode 100644 mods/lord/Tools/lord_potions/src/lord_potions/api/ingredient.lua create mode 100644 mods/lord/Tools/lord_potions/src/lord_potions/config.lua create mode 100644 mods/lord/Tools/lord_potions/src/lord_potions/config/ingredients.lua create mode 100644 mods/lord/Tools/lord_potions/textures/ingredients/lord_potions_ingredient_bonedust.png create mode 100644 mods/lord/Tools/lord_potions/textures/ingredients/lord_potions_ingredient_geodes.png create mode 100644 mods/lord/Tools/lord_potions/textures/ingredients/lord_potions_ingredient_mese.png create mode 100644 mods/lord/Tools/lord_potions/textures/ingredients/lord_potions_ingredient_mordor.png create mode 100644 mods/lord/Tools/lord_potions/textures/ingredients/lord_potions_ingredient_obsidian.png create mode 100644 mods/lord/Tools/lord_potions/textures/ingredients/lord_potions_ingredient_seregon.png diff --git a/mods/lord/Tools/lord_potions/src/lord_potions.lua b/mods/lord/Tools/lord_potions/src/lord_potions.lua index 431a301bd..6b7f4fccd 100644 --- a/mods/lord/Tools/lord_potions/src/lord_potions.lua +++ b/mods/lord/Tools/lord_potions/src/lord_potions.lua @@ -8,9 +8,20 @@ local function register_api() _G.potions = api end +local function register_ingredients() + for _, ingredient in pairs(config.ingredients) do + api.ingredient.register( + ingredient.node_name, + ingredient.title, + ingredient.description, + ingredient.groups + ) + end +end + local function register_potions() - for _, potion_group in pairs(config) do - api.register_potion_group(potion_group) + for _, potion_group in pairs(config.potions) do + api.potion.register_group(potion_group) end end @@ -23,6 +34,7 @@ return { return end register_api() + register_ingredients() register_potions() end, } diff --git a/mods/lord/Tools/lord_potions/src/lord_potions/api.lua b/mods/lord/Tools/lord_potions/src/lord_potions/api.lua new file mode 100644 index 000000000..6995c4be8 --- /dev/null +++ b/mods/lord/Tools/lord_potions/src/lord_potions/api.lua @@ -0,0 +1,8 @@ +local potion = require('lord_potions.api.potion') +local ingredient = require('lord_potions.api.ingredient') + + +return { + potion = potion, + ingredient = ingredient, +} diff --git a/mods/lord/Tools/lord_potions/src/lord_potions/api/ingredient.lua b/mods/lord/Tools/lord_potions/src/lord_potions/api/ingredient.lua new file mode 100644 index 000000000..6e859eaab --- /dev/null +++ b/mods/lord/Tools/lord_potions/src/lord_potions/api/ingredient.lua @@ -0,0 +1,46 @@ +local S = minetest.get_mod_translator() +local colorize = minetest.colorize + +local ingredients = { + --- @type table|NodeDefinition[] + all_items = {}, +} + + +--- default groups: default: { dig_immediate = 3, attached_node = 1, vessel = 1, ingredients = 1 } +--- @param node_name string technical item/node name (`:`). +--- @param title string prefix to description of item or will extracted from `item_name` (`title`.." ingredient"). +--- @param description string some words you want to displayed in tooltip. +--- @param groups table additional or overwrite groups for item definition groups. +local function register_ingredient(node_name, title, description, groups) + local item_name = node_name + local sub_name = item_name:split(':')[2] + local texture = node_name:replace(':', '_') .. '.png^lord_potions_bottle.png' + title = title and title:first_to_upper() or sub_name:first_to_upper() + + minetest.register_node(item_name, { + description = S('Ingredient "@1"', colorize('#aa8', title)), + _tt_help = description and colorize('#aaa', '\n' .. description), + inventory_image = texture, + wield_image = texture, + drawtype = 'plantlike', + use_texture_alpha = 'blend', + tiles = { texture .. '^[opacity:160' }, + selection_box = { type = 'fixed', fixed = { -0.25, -0.5, -0.25, 0.25, 0.4, 0.25 } }, + walkable = false, + paramtype = 'light', + groups = table.overwrite( + { vessel = 1, dig_immediate = 3, attached_node = 1, ingredients = 1 }, + groups or {} + ), + sounds = default.node_sound_glass_defaults(), + }) + + ingredients.all_items[item_name] = minetest.registered_nodes[item_name] +end + + +return { + register = register_ingredient, + get_all = function() return ingredients.all_items end, +} diff --git a/mods/lord/Tools/lord_potions/src/lord_potions/api/potion.lua b/mods/lord/Tools/lord_potions/src/lord_potions/api/potion.lua index c57096d3d..f8c34aa72 100644 --- a/mods/lord/Tools/lord_potions/src/lord_potions/api/potion.lua +++ b/mods/lord/Tools/lord_potions/src/lord_potions/api/potion.lua @@ -25,7 +25,7 @@ end --- default groups: default: { dig_immediate = 3, attached_node = 1, vessel = 1, potions = 1 } --- @param name_prefix string technical item/node name (`:`) prefix (will be name_prefix..'_'..power_abs). ---- @param title string prefix to description of item or will extracted from `item_name` (`title`.." Potion"). +--- @param title string prefix to description of item or will extracted from `item_name` ("Potion:"..`title`). --- @param description string some words you want to displayed in tooltip before properties of power. --- @param color string color of potion liquid (bottle contents). --- @param effect string one of registered `lord_effects.` names. @@ -91,9 +91,10 @@ end return { - add_existing = add_existing, - register_potion = register_potion, - register_potion_group = register_potion_group, - get_all_potions = function() return potions.all_items end, - get_lord_potions = function() return potions.lord_items end, + add_existing = add_existing, + register = register_potion, + register_group = register_potion_group, + get_all = function() return potions.all_items end, + --- returns only lord internal registered potions. + get_lord = function() return potions.lord_items end, } diff --git a/mods/lord/Tools/lord_potions/src/lord_potions/config.lua b/mods/lord/Tools/lord_potions/src/lord_potions/config.lua new file mode 100644 index 000000000..4c9d60227 --- /dev/null +++ b/mods/lord/Tools/lord_potions/src/lord_potions/config.lua @@ -0,0 +1,13 @@ +local potions = require('lord_potions.config.potions') +local ingredients = require('lord_potions.config.ingredients') + +--- @class lord_potions.config +--- @field potions lord_potions.PotionGroup[] +--- @field ingredients lord_potions.Ingredient[] +local config = { + potions = potions, + ingredients = ingredients, +} + + +return config diff --git a/mods/lord/Tools/lord_potions/src/lord_potions/config/ingredients.lua b/mods/lord/Tools/lord_potions/src/lord_potions/config/ingredients.lua new file mode 100644 index 000000000..927ceb43f --- /dev/null +++ b/mods/lord/Tools/lord_potions/src/lord_potions/config/ingredients.lua @@ -0,0 +1,40 @@ +local S = minetest.get_mod_translator() + +--- @class lord_potions.Ingredient +--- @field node_name string technical item/node name (`:`). +--- @field title string prefix to description of item or will extracted from `item_name` (`title`.." ingredient"). +--- @field description string some words you want to displayed in tooltip. +--- @field groups table additional or overwrite groups for item definition groups. + + +--- @type lord_potions.Ingredient[] +local config = { + -- Base Ingredients + { + node_name = "lord_potions:ingredient_mese", + description = S("Glass Bottle (Mese Water)"), + }, + { + node_name = "lord_potions:ingredient_geodes", + description = S("Glass Bottle (Geodes Crystal Water)"), + }, + { + node_name = "lord_potions:ingredient_seregon", + description = S("Glass Bottle (Seregon Water)"), + }, + -- Negative Base Ingredients + { + node_name = "lord_potions:ingredient_obsidian", + description = S("Glass Bottle (Obsidian Water)"), + }, + { + node_name = "lord_potions:ingredient_bonedust", + description = S("Glass Bottle (Bonedust Water)"), + }, + { + node_name = "lord_potions:ingredient_mordor", + description = S("Glass Bottle (Mordor Water)"), + }, +} + +return config diff --git a/mods/lord/Tools/lord_potions/textures/ingredients/lord_potions_ingredient_bonedust.png b/mods/lord/Tools/lord_potions/textures/ingredients/lord_potions_ingredient_bonedust.png new file mode 100644 index 0000000000000000000000000000000000000000..b50e3dab55547b10bbefc5b9341f28d665a7de42 GIT binary patch literal 238 zcmeAS@N?(olHy`uVBq!ia0vp^{6H+g!3HExhN-duDb50q$YKTtz5^i4n02j_6DYXA z)5S4F-6lJs+PWN_(@dXjnx{;f zy)Y=tX5F<}6}FkdGKR-2#FkH4QF)j3thVLzJ~v(Y?w2iFzX{3b-8;P9aH&XDtNbVB k^z%K2ZF|1o|I1zOaBaRt^;?a0pj#O{UHx3vIVCg!02*srHUIzs literal 0 HcmV?d00001 diff --git a/mods/lord/Tools/lord_potions/textures/ingredients/lord_potions_ingredient_geodes.png b/mods/lord/Tools/lord_potions/textures/ingredients/lord_potions_ingredient_geodes.png new file mode 100644 index 0000000000000000000000000000000000000000..47b14c7cf4701d37457a6478392a223525efb7d9 GIT binary patch literal 343 zcmV-d0jU0oP)<{A2}wjjR4C75U>F5M1Tf-~Xg&6yfe9%4`yT_ti!Tfe)7&wYGGWtL zbLc79!i z_&Asu)U~4+1QnSXuAlqF@ciX>{La>w7h-sG`zM2}QV_$ZZ@(E{eEi9#Gg*}|h9{4=0X;8HII6teH~jzg`wxQ-&=pr6 pzGGnc^Mm1xl_BH%4sGfs5&)n*US|{wd?Ww>002ovPDHLkV1n>=m4pBQ literal 0 HcmV?d00001 diff --git a/mods/lord/Tools/lord_potions/textures/ingredients/lord_potions_ingredient_mese.png b/mods/lord/Tools/lord_potions/textures/ingredients/lord_potions_ingredient_mese.png new file mode 100644 index 0000000000000000000000000000000000000000..a04eae9851332d75ec617ab5bce9e5f2829d68a0 GIT binary patch literal 303 zcmV+~0nq-5P)K`>%7)|K4-z2=R{}3F*}ZkmFNkEM_4jDgRI- zKR0GYqcMUIDMn`8oXdP>7GjNb+Qr&u63m7lFr4S8)q?<%7>{GNYFd~zjw>Qe^u1X> zd$2zeOiRVd@W8sLXtn)VZwSj3y*C@C52dnV7vFU-3}JU56p9KuU2fgbJLGJO4+ft=ly)6nje3;j~b<%l{m+i zdFj%I)E_@y*&VKT%-k?z&JLwb;vBbi4xD1!Cc5O~#nZo!SW4eyNV(1sd#FS1mIxz5 YD4WsJM(M_1K<6=dy85}Sb4q9e01B90YXATM literal 0 HcmV?d00001 diff --git a/mods/lord/Tools/lord_potions/textures/ingredients/lord_potions_ingredient_seregon.png b/mods/lord/Tools/lord_potions/textures/ingredients/lord_potions_ingredient_seregon.png new file mode 100644 index 0000000000000000000000000000000000000000..cb7935c4fc0eebd3d9633199c6b448b1bb3ea312 GIT binary patch literal 277 zcmeAS@N?(olHy`uVBq!ia0vp^{6H+g!3HExhN-duDb50q$YKTtzJnmlxMO1WTcF@^ zPZ!4!jq}MOLPALj;s%BR3~r0k#A1Z@?AfF7=lpzo;q{fPXGw6~fA=Q+(VV@3@r@7v z&fovP(MKZ9B4v%woM-0y4@gOV+xw3}_*cKLta26C>yW8`>fc`uXVd3gquGD)|0Cu< zX0tgz8s}7h>}&LPocZv??EVBp0r?k7hZxIV-F4r<*q?Vd>BpDn`iK29S=o#i95b)~ z_u%{I*6;Hrr~KF<`E5@ffBDhpzsn6xlCJLgb5`6`+00$e8JQ=3SGEq??FVfS+F+}5ha)Jb_ zvecC6)BoESK4Ou09CWzF_rlGalCI2p%n}h{fsT1PRu~ z4E!4U`v2=69pN-Mw!DvX_JYlujl0xp+6MA!Gw*Tsvj7~8!d@PpBoEje?2(*sD)78&qol`;+ E0KPRg{{R30