Skip to content

Commit

Permalink
Refactoring: lottpotion: extract lord_vessels; rewrite code. Closes
Browse files Browse the repository at this point in the history
  • Loading branch information
alek13 committed Oct 31, 2024
1 parent 187ffc1 commit 6a5c2a4
Show file tree
Hide file tree
Showing 28 changed files with 170 additions and 201 deletions.
4 changes: 2 additions & 2 deletions mods/lord/Blocks/lottfarming/crafting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ end
minetest.register_tool("lottfarming:bacteria_fertiliser", {
description = S("Bacteria Fertiliser"),
tiles = {"vessels_glass_bottle.png^lottfarming_bacteria_fertiliser.png"},
inventory_image = "vessels_glass_bottle_inv.png^lottfarming_bacteria_fertiliser.png",
inventory_image = "vessels_glass_bottle.png^lottfarming_bacteria_fertiliser.png",
on_use = function(itemstack, user, pointed_thing)
if decaying_wood(pointed_thing.under) or growgen(pointed_thing.under) then
itemstack:add_wear(65535/20)
Expand All @@ -125,7 +125,7 @@ minetest.register_tool("lottfarming:bacteria_fertiliser", {

minetest.register_craft({
output = "lottfarming:bacteria_fertiliser",
recipe = {{"lottpotion:glass_bottle_water", "bones:bonedust"}}
recipe = {{"lord_vessels:glass_bottle_water", "bones:bonedust"}}
})

minetest.register_craft({
Expand Down
4 changes: 2 additions & 2 deletions mods/lord/Blocks/lottfarming/other.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ minetest.register_craft({
minetest.register_craft({
type = "shapeless",
output = "lottfarming:dough",
recipe = {"lottpotion:glass_bottle_water", "farming:flour"},
replacements = {{"lottpotion:glass_bottle_water", "vessels:glass_bottle"}},
recipe = {"lord_vessels:glass_bottle_water", "farming:flour"},
replacements = {{"lord_vessels:glass_bottle_water", "vessels:glass_bottle"}},
})

minetest.register_craft({
Expand Down
2 changes: 1 addition & 1 deletion mods/lord/Entities/bees/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ local S = minetest.get_mod_translator()
'listcolors[#b3835288;#cfb29388;#201408]'..
--input
'image[1,1;1,1;bees_frame_full.png]'..
'image[1,3;1,1;vessels_glass_bottle_inv.png]'..
'image[1,3;1,1;vessels_glass_bottle.png]'..
'list[nodemeta:'.. spos ..';frames_filled;2,1;1,1;]'..
'list[nodemeta:'.. spos ..';bottles_empty;2,3;1,1;]'..
--output
Expand Down
10 changes: 5 additions & 5 deletions mods/lord/Tools/lord_books/brewing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ form.get_spec = function(page)
.. "image[6,1;1,1;books_previous_inactive.png]"
--First
.. "label[1,2.2; " .. SL("Wine") .. "]"
.. "item_image_button[4,2;1,1;lottpotion:drinking_glass_water;zcg:vessels:glass_water;]"
.. "item_image_button[4,2;1,1;lord_vessels:drinking_glass_water;zcg:vessels:glass_water;]"
.. "item_image_button[5,2;1,1;lottfarming:berries;zcg:berries;5]"
.. "image[6,2;1,1;books_craft_arrow.png]"
.. "item_image_button[7,2;1,1;lottpotion:wine;zcg:wine;]"
--Second
.. "label[1,3.2; " .. SL("Beer") .. "]"
.. "item_image_button[4,3;1,1;lottpotion:drinking_glass_water;zcg:drinking_glass_water;]"
.. "item_image_button[4,3;1,1;lord_vessels:drinking_glass_water;zcg:drinking_glass_water;]"
.. "item_image_button[5,3;1,1;farming:wheat0;zcg:wheat;3]"
.. "image[6,3;1,1;books_craft_arrow.png]"
.. "item_image_button[7,3;1,1;lottpotion:beer;zcg:beer;]"
--Third
.. "label[1,4.2; " .. SL("Mead") .. "]"
.. "item_image_button[4,4;1,1;lottpotion:drinking_glass_water;zcg:drinking_glass_water;]"
.. "item_image_button[4,4;1,1;lord_vessels:drinking_glass_water;zcg:drinking_glass_water;]"
.. "item_image_button[5,4;1,1;bees:bottle_honey;zcg:honey;6]"
.. "image[6,4;1,1;books_craft_arrow.png]"
.. "item_image_button[7,4;1,1;lottpotion:mead;zcg:mead;]"
Expand All @@ -43,13 +43,13 @@ form.get_spec = function(page)
.. "image_button[6,1;1,1;books_previous.png;brews;;false;false;books_previous_press.png]"
--First
.. "label[1,2.2; " .. SL("Cider") .. "]"
.. "item_image_button[4,2;1,1;lottpotion:drinking_glass_water;zcg:drinking_glass_water;]"
.. "item_image_button[4,2;1,1;lord_vessels:drinking_glass_water;zcg:drinking_glass_water;]"
.. "item_image_button[5,2;1,1;default:apple;zcg:apple; 5]"
.. "image[6,2;1,1;books_craft_arrow.png]"
.. "item_image_button[7,2;1,1;lottpotion:cider;zcg:cider;]"
--Second
.. "label[1,3.2; " .. SL("Ale") .. "]"
.. "item_image_button[4,3;1,1;lottpotion:drinking_glass_water;zcg:drinking_glass_water;]"
.. "item_image_button[4,3;1,1;lord_vessels:drinking_glass_water;zcg:drinking_glass_water;]"
.. "item_image_button[5,3;1,1;lottfarming:barley_seed;zcg:barley;6]"
.. "image[6,3;1,1;books_craft_arrow.png]"
.. "item_image_button[7,3;1,1;lottpotion:ale;zcg:ale;]"
Expand Down
12 changes: 6 additions & 6 deletions mods/lord/Tools/lord_books/potions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ form.get_spec = function(page)
.."label[0,1;"..SL("Base Potions:").."]"
--First potion
.."label[1,2.2; "..SL("Mese Base Potion").."]"
.."item_image_button[4,2;1,1;lottpotion:glass_bottle_water;lottpotion:glass_bottle_water;]"
.."item_image_button[4,2;1,1;lord_vessels:glass_bottle_water;lord_vessels:glass_bottle_water;]"
.."item_image_button[5,2;1,1;default:mese_crystal_fragment;zcg:mese_crystal_fragment;]"
.."image[6,2;1,1;books_craft_arrow.png]"
.."item_image_button[7,2;1,1;lottpotion:glass_bottle_mese;zcg:glass_bottle_mese;]"
--Second
.."label[1,3.2; "..SL("Geodes Base Potion").."]"
.."item_image_button[4,3;1,1;lottpotion:glass_bottle_water;lottpotion:glass_bottle_water;]"
.."item_image_button[4,3;1,1;lord_vessels:glass_bottle_water;lord_vessels:glass_bottle_water;]"
.."item_image_button[5,3;1,1;lottores:geodes_crystal_1;zcg:geodes_crystal_1;]"
.."image[6,3;1,1;books_craft_arrow.png]"
.."item_image_button[7,3;1,1;lottpotion:glass_bottle_geodes;zcg:glass_bottle_geodes;]"
--Third
.."label[1,4.2; "..SL("Seregon Base Potion").."]"
.."item_image_button[4,4;1,1;lottpotion:glass_bottle_water;lottpotion:glass_bottle_water;]"
.."item_image_button[4,4;1,1;lord_vessels:glass_bottle_water;lord_vessels:glass_bottle_water;]"
.."item_image_button[5,4;1,1;lottplants:seregon;zcg:seregon;]"
.."image[6,4;1,1;books_craft_arrow.png]"
.."item_image_button[7,4;1,1;lottpotion:glass_bottle_seregon;zcg:glass_bottle_seregon;]"
Expand Down Expand Up @@ -213,19 +213,19 @@ form.get_spec = function(page)
.."label[0,1;"..SL("Base Potions Of Negative:").."]"
--First potion
.."label[1,2.2; "..SL("Obsidian Base Potion").."]"
.."item_image_button[4,2;1,1;lottpotion:glass_bottle_water;lottpotion:glass_bottle_water;]"
.."item_image_button[4,2;1,1;lord_vessels:glass_bottle_water;lord_vessels:glass_bottle_water;]"
.."item_image_button[5,2;1,1;default:obsidian_shard;zcg:obsidian_shard;]"
.."image[6,2;1,1;books_craft_arrow.png]"
.."item_image_button[7,2;1,1;lottpotion:glass_bottle_obsidian;zcg:glass_bottle_obsidian;]"
--Second
.."label[1,3.2; "..SL("Bonedust Base Potion").."]"
.."item_image_button[4,3;1,1;lottpotion:glass_bottle_water;lottpotion:glass_bottle_water;]"
.."item_image_button[4,3;1,1;lord_vessels:glass_bottle_water;lord_vessels:glass_bottle_water;]"
.."item_image_button[5,3;1,1;bones:bonedust;zcg:bonedust;]"
.."image[6,3;1,1;books_craft_arrow.png]"
.."item_image_button[7,3;1,1;lottpotion:glass_bottle_bonedust;zcg:glass_bottle_bonedust;]"
--Third
.."label[1,4.2; "..SL("Mordor Base Potion").."]"
.."item_image_button[4,4;1,1;lottpotion:glass_bottle_water;lottpotion:glass_bottle_water;]"
.."item_image_button[4,4;1,1;lord_vessels:glass_bottle_water;lord_vessels:glass_bottle_water;]"
.."item_image_button[5,4;1,1;lottplants:brambles_of_mordor;zcg:brambles_of_mordor;]"
.."image[6,4;1,1;books_craft_arrow.png]"
.."item_image_button[7,4;1,1;lottpotion:glass_bottle_mordor;zcg:glass_bottle_mordor;]"
Expand Down
8 changes: 8 additions & 0 deletions mods/lord/Tools/lord_vessels/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@


minetest.mod(function(mod)
require('glasses')
require('bottles')

dofile(mod.path .. '/legacy.lua')
end)
8 changes: 8 additions & 0 deletions mods/lord/Tools/lord_vessels/legacy.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

-- @tags: legacy

minetest.register_alias('lottpotion:glass_bottle_water', 'lord_vessels:glass_bottle_water')
minetest.register_alias('lottpotion:drinking_glass_water', 'lord_vessels:drinking_glass_water')

-- DEFAULTS (Ghost blocks)
-- похоже не было
6 changes: 6 additions & 0 deletions mods/lord/Tools/lord_vessels/locale/lord_vessels.en.tr
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# textdomain: lord_vessels

Glass Bottle (empty)=Glass Bottle (empty)
Glass Bottle (Water)=Glass Bottle (Water)
Drinking Glass (empty)=Drinking Glass (empty)
Drinking Glass (Water)=Drinking Glass (Water)
6 changes: 6 additions & 0 deletions mods/lord/Tools/lord_vessels/locale/lord_vessels.ru.tr
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# textdomain: lord_vessels

Glass Bottle (empty)=Стеклянная бутыль
Glass Bottle (Water)=Стеклянная бутыль с водой
Drinking Glass (empty)=Стеклянный стакан
Drinking Glass (Water)=Стеклянный стакан с водой
2 changes: 2 additions & 0 deletions mods/lord/Tools/lord_vessels/mod.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name = lord_vessels
depends = builtin, default, vessels
35 changes: 35 additions & 0 deletions mods/lord/Tools/lord_vessels/src/bottles.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
local S = minetest.get_mod_translator()

local cauldron = require('cauldron.usage')


minetest.override_item('vessels:glass_bottle', {
selection_box = {
type = 'fixed',
fixed = { -0.25, -0.5, -0.25, 0.25, 0.4, 0.25 }
},
on_use = function(itemstack, user, pointed_thing)
local pos = pointed_thing.above
if pos == nil then return itemstack end
pos.y = pos.y - 1

return cauldron.fill_from(pos, itemstack, user, 'lord_vessels:glass_bottle_water')
end
})

local glass_bottle_water_texture = 'vessels_glass_bottle.png^lottpotion_water.png'
minetest.register_node('lord_vessels:glass_bottle_water', {
description = S('Glass Bottle (Water)'),
drawtype = 'plantlike',
tiles = { glass_bottle_water_texture },
inventory_image = glass_bottle_water_texture,
wield_image = glass_bottle_water_texture,
paramtype = 'light',
walkable = false,
selection_box = {
type = 'fixed',
fixed = { -0.25, -0.5, -0.25, 0.25, 0.4, 0.25 }
},
groups = { vessel = 1, dig_immediate = 3, attached_node = 1 },
sounds = default.node_sound_glass_defaults(),
})
31 changes: 31 additions & 0 deletions mods/lord/Tools/lord_vessels/src/cauldron/usage.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

local cauldron_changes = {
['lottpotion:cauldron_full'] = 'lottpotion:cauldron_two_third_full',
['lottpotion:cauldron_two_third_full'] = 'lottpotion:cauldron_one_third_full',
['lottpotion:cauldron_one_third_full'] = 'lottpotion:cauldron_empty',
}

--- @param pos Position
--- @param itemstack ItemStack
--- @param user Player
local function fill_from(pos, itemstack, user, filled_item_name)
local leftover

for from, to in pairs(cauldron_changes) do
if (minetest.get_node(pos).name == from) then
minetest.remove_node(pos)
minetest.set_node(pos, { name = to })
itemstack:take_item()
leftover = user:get_inventory():add_item('main', filled_item_name)
if leftover then
minetest.item_drop(leftover, user, pos)
end
return itemstack
end
end
end


return {
fill_from = fill_from,
}
30 changes: 30 additions & 0 deletions mods/lord/Tools/lord_vessels/src/glasses.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
local S = minetest.get_mod_translator()

local cauldron = require('cauldron.usage')


minetest.override_item('vessels:drinking_glass', {
on_use = function(itemstack, user, pointed_thing)
local pos = pointed_thing.above
if pos == nil then return itemstack end
pos.y = pos.y - 1

return cauldron.fill_from(pos, itemstack, user, 'lord_vessels:drinking_glass_water')
end
})

minetest.register_node('lord_vessels:drinking_glass_water', {
description = S('Drinking Glass (Water)'),
drawtype = 'plantlike',
tiles = { 'lottpotion_glass_water.png' },
inventory_image = 'lottpotion_glass_water.png',
wield_image = 'lottpotion_glass_water.png',
paramtype = 'light',
walkable = false,
selection_box = {
type = 'fixed',
fixed = { -0.25, -0.5, -0.25, 0.25, 0.4, 0.25 }
},
groups = { vessel = 1, dig_immediate = 3, attached_node = 1 },
sounds = default.node_sound_glass_defaults(),
})
2 changes: 2 additions & 0 deletions mods/lord/Tools/lord_vessels/src/mug.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@


10 changes: 5 additions & 5 deletions mods/lord/Tools/lottpotion/brewing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ end

local recipes = {
--Base Potion
{ "lottfarming:berries 5", "lottpotion:drinking_glass_water", "lottpotion:wine" },
{ "farming:wheat0 3", "lottpotion:drinking_glass_water", "lottpotion:beer" },
{ "bees:bottle_honey 6", "lottpotion:drinking_glass_water", "lottpotion:mead", "vessels:glass_bottle 6" },
{ "default:apple 5", "lottpotion:drinking_glass_water", "lottpotion:cider" },
{ "lottfarming:barley_seed 6", "lottpotion:drinking_glass_water", "lottpotion:ale" },
{ "lottfarming:berries 5", "lord_vessels:drinking_glass_water", "lottpotion:wine" },
{ "farming:wheat0 3", "lord_vessels:drinking_glass_water", "lottpotion:beer" },
{ "bees:bottle_honey 6", "lord_vessels:drinking_glass_water", "lottpotion:mead", "vessels:glass_bottle 6" },
{ "default:apple 5", "lord_vessels:drinking_glass_water", "lottpotion:cider" },
{ "lottfarming:barley_seed 6", "lord_vessels:drinking_glass_water", "lottpotion:ale" },
}

for _, data in pairs(recipes) do
Expand Down
Loading

0 comments on commit 6a5c2a4

Please sign in to comment.