Skip to content

Commit

Permalink
Effects Int: Potions: add ingredients for potions. Closes #1779
Browse files Browse the repository at this point in the history
  • Loading branch information
alek13 committed Nov 9, 2024
1 parent 7d03140 commit 4de4dd4
Show file tree
Hide file tree
Showing 13 changed files with 128 additions and 8 deletions.
16 changes: 14 additions & 2 deletions mods/lord/Tools/lord_potions/src/lord_potions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -23,6 +34,7 @@ return {
return
end
register_api()
register_ingredients()
register_potions()
end,
}
8 changes: 8 additions & 0 deletions mods/lord/Tools/lord_potions/src/lord_potions/api.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
local potion = require('lord_potions.api.potion')
local ingredient = require('lord_potions.api.ingredient')


return {
potion = potion,
ingredient = ingredient,
}
46 changes: 46 additions & 0 deletions mods/lord/Tools/lord_potions/src/lord_potions/api/ingredient.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
local S = minetest.get_mod_translator()
local colorize = minetest.colorize

local ingredients = {
--- @type table<string,NodeDefinition>|NodeDefinition[]
all_items = {},
}


--- default groups: default: { dig_immediate = 3, attached_node = 1, vessel = 1, ingredients = 1 }
--- @param node_name string technical item/node name (`<mod>:<node>`).
--- @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,
}
13 changes: 7 additions & 6 deletions mods/lord/Tools/lord_potions/src/lord_potions/api/potion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 (`<mod>:<node>`) 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.<CONST>` names.
Expand Down Expand Up @@ -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,
}
13 changes: 13 additions & 0 deletions mods/lord/Tools/lord_potions/src/lord_potions/config.lua
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
local S = minetest.get_mod_translator()

--- @class lord_potions.Ingredient
--- @field node_name string technical item/node name (`<mod>:<node>`).
--- @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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4de4dd4

Please sign in to comment.