Skip to content

Commit

Permalink
Artisan Benches: Fuel Device: Barrel: extract common nodes def & Form…
Browse files Browse the repository at this point in the history
…. Closes #1889
  • Loading branch information
alek13 committed Nov 24, 2024
1 parent 58de139 commit 948ecbf
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ One Third Filled Cauldron=One Third Filled Cauldron
Empty Cauldron=Empty Cauldron

### Barrel ###
Brewer=Brewer
Brewer Brewing=Brewer Brewing
Brewer Out Of Heat=Brewer Out Of Heat
Brewer is empty=Brewer is empty
Barrel=Barrel

### Laboratory ###
Potion Brewer=Potion Brewer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ One Third Filled Cauldron=Котёл, заполненный на 1/3
Empty Cauldron=Пустой котёл

### Barrel ###
Brewer=Бочка
Brewer Brewing=Бочка: работает
Brewer Out Of Heat=Бочка: нет топлива
Brewer is empty=Бочка: нет материала
Barrel=Бочка

### Laboratory ###
Potion Brewer=Лаборатория
Expand Down
Original file line number Diff line number Diff line change
@@ -1,104 +1,51 @@
local geometry = require('artisan_benches.barrel.nodes.geometry')
local S = minetest.get_mod_translator()
local Form = require('artisan_benches.barrel.nodes.Form')
local geometry = require('artisan_benches.barrel.nodes.geometry')
local S = minetest.get_mod_translator()


local machine_name = 'Barrel'

--- @class barrel.node.Form: fuel_device.node.Form
local Form = {
get_spec = function(type, percent, item_percent)
assert(type:is_one_of({ 'active', 'inactive' }))
percent = percent or 0
--item_percent = item_percent or 0

local bubbles_image = type == 'inactive'
and 'image[4,2;1,1;benches_barrel_form_bubble.png]'
or 'image[4,2;1,1;benches_barrel_form_bubble.png^[lowpart:' .. (percent) .. ':benches_form_bubble.png]'


return 'size[8,9]' ..
'label[0,0;' .. S(machine_name) .. ']' ..
bubbles_image ..
'image[3,2;1,1;benches_form_arrow.png]' ..
'image[5,2;1,1;benches_form_arrow.png]' ..
'label[2.9,3.2;' .. S('Fuel:') .. ']' ..
'list[current_name;fuel;4,3;1,1;]' ..
'label[1,1.5;' .. S('Ingredients:') .. ']' ..
'list[current_name;src;1,2;2,1;]' ..
'label[6,1.5;' .. S('Result:') .. ']' ..
'list[current_name;dst;6,2;1,2;]' ..
'list[current_player;main;0,5;8,4;]' ..
'listring[current_name;fuel]' ..
'listring[current_player;main]' ..
'listring[current_name;src]' ..
'listring[current_player;main]' ..
'listring[current_name;dst]' ..
'listring[current_player;main]'
end
local node_box = {
type = 'fixed',
fixed = geometry.make_pipe(
{
{ f = 0.9, h1 = -0.2, h2 = 0.2, b = 0 },
{ f = 0.75, h1 = -0.50, h2 = -0.35, b = 0 },
{ f = 0.75, h1 = 0.35, h2 = 0.5, b = 0 },
{ f = 0.82, h1 = -0.35, h2 = -0.2, b = 0 },
{ f = 0.82, h1 = 0.2, h2 = 0.35, b = 0 },
{ f = 0.75, h1 = 0.37, h2 = 0.42, b = 1 },
{ f = 0.75, h1 = -0.42, h2 = -0.37, b = 1 },
},
0
),
}
local selection_box = {
type = 'fixed',
fixed = { -0.3, -0.5, -0.3, 0.3, 0.35, 0.3 }
}
local common_node_definition = {
drawtype = 'nodebox',
tiles = { 'default_wood.png' },
node_box = node_box,
selection_box = selection_box,
paramtype = 'light',
sounds = default.node_sound_stone_defaults(),
groups = { choppy = 2, },
}

fuel_device.register(
S(machine_name),
S('Barrel'),
minetest.CraftMethod.BARREL,
{
inactive = {
node_name = ':lottpotion:brewer',
definition = {
drawtype = 'nodebox',
tiles = { 'default_wood.png' },
node_box = {
type = 'fixed',
fixed = geometry.make_pipe(
{
{ f = 0.9, h1 = -0.2, h2 = 0.2, b = 0 },
{ f = 0.75, h1 = -0.50, h2 = -0.35, b = 0 },
{ f = 0.75, h1 = 0.35, h2 = 0.5, b = 0 },
{ f = 0.82, h1 = -0.35, h2 = -0.2, b = 0 },
{ f = 0.82, h1 = 0.2, h2 = 0.35, b = 0 },
{ f = 0.75, h1 = 0.37, h2 = 0.42, b = 1 },
{ f = 0.75, h1 = -0.42, h2 = -0.37, b = 1 },
},
0
),
},
paramtype = 'light',
groups = { choppy = 2, },
sounds = default.node_sound_stone_defaults(),
selection_box = {
type = 'fixed',
fixed = { -0.3, -0.5, -0.3, 0.3, 0.35, 0.3 }
},
},
definition = table.merge(common_node_definition, {}),
},
active = {
node_name = ':lottpotion:brewer_active',
definition = {
drawtype = 'nodebox',
tiles = { 'default_wood.png' },
node_box = {
type = 'fixed',
fixed = geometry.make_pipe(
{
{ f = 0.9, h1 = -0.2, h2 = 0.2, b = 0 },
{ f = 0.75, h1 = -0.50, h2 = -0.35, b = 0 },
{ f = 0.75, h1 = 0.35, h2 = 0.5, b = 0 },
{ f = 0.82, h1 = -0.35, h2 = -0.2, b = 0 },
{ f = 0.82, h1 = 0.2, h2 = 0.35, b = 0 },
{ f = 0.75, h1 = 0.37, h2 = 0.42, b = 1 },
{ f = 0.75, h1 = -0.42, h2 = -0.37, b = 1 }
},
0
),
},
paramtype = 'light',
selection_box = {
type = 'fixed',
fixed = { -0.3, -0.5, -0.3, 0.3, 0.35, 0.3 }
},
drop = 'lottpotion:brewer',
groups = { cracky = 2, not_in_creative_inventory = 1 },
sounds = default.node_sound_stone_defaults(),
},
definition = table.merge(common_node_definition, {
drop = 'lottpotion:brewer',
groups = { not_in_creative_inventory = 1 },
}),
}
},
Form,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
local S = minetest.get_mod_translator()

--- @class barrel.node.Form: fuel_device.node.Form
local Form = {
get_spec = function(type, percent, item_percent)
assert(type:is_one_of({ 'active', 'inactive' }))
percent = percent or 0
--item_percent = item_percent or 0

local bubbles_image = type == 'inactive'
and 'image[4,2;1,1;benches_barrel_form_bubble.png]'
or 'image[4,2;1,1;benches_barrel_form_bubble.png^[lowpart:' .. (percent) .. ':benches_form_bubble.png]'


return 'size[8,9]' ..
'label[0,0;' .. S('Barrel') .. ']' ..
bubbles_image ..
'image[3,2;1,1;benches_form_arrow.png]' ..
'image[5,2;1,1;benches_form_arrow.png]' ..
'label[2.9,3.2;' .. S('Fuel:') .. ']' ..
'list[current_name;fuel;4,3;1,1;]' ..
'label[1,1.5;' .. S('Ingredients:') .. ']' ..
'list[current_name;src;1,2;2,1;]' ..
'label[6,1.5;' .. S('Result:') .. ']' ..
'list[current_name;dst;6,2;1,2;]' ..
'list[current_player;main;0,5;8,4;]' ..
'listring[current_name;fuel]' ..
'listring[current_player;main]' ..
'listring[current_name;src]' ..
'listring[current_player;main]' ..
'listring[current_name;dst]' ..
'listring[current_player;main]'
end
}


return Form

0 comments on commit 948ecbf

Please sign in to comment.