Skip to content

Commit

Permalink
Artisan Benches modpack: extract workbench. Relates to #1798
Browse files Browse the repository at this point in the history
  • Loading branch information
alek13 committed Dec 5, 2024
1 parent b27ed46 commit 237276d
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 61 deletions.
2 changes: 1 addition & 1 deletion mods/lord/Blocks/ArtisanBenches/anvil/init.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


minetest.mod(function(mod)
require("anvil").init(mod)
require('anvil').init(mod)

dofile(mod.path .. '/legacy.lua')
end)
4 changes: 3 additions & 1 deletion mods/lord/Blocks/ArtisanBenches/workbench/init.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@


minetest.mod(function(mod)
--require("workbench").init(mod)
require('workbench').init(mod)

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

-- @tags: legacy

minetest.register_alias('castle:workbench', 'workbench:workbench')
minetest.register_alias('lord_artisan_benches:workbench', 'workbench:workbench')
-- DEFAULTS (Ghost blocks)
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
# textdomain: workbench

Workbench=Workbench
Source Material=Source Material
Recipe to Use=Recipe to Use
Craft Output=Craft Output
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
# textdomain: workbench

Workbench=Верстак
Source Material=Материалы:
Recipe to Use=Схема:
Craft Output=Результат:
2 changes: 1 addition & 1 deletion mods/lord/Blocks/ArtisanBenches/workbench/mod.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
name = workbench
depends = builtin
depends = builtin, default
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
local S = minetest.get_mod_translator()


minetest.register_alias('castle:workbench', 'lord_artisan_benches:workbench')


local get_recipe = function(inv)
local result, needed, input
needed = inv:get_list('rec')
Expand Down Expand Up @@ -73,31 +70,23 @@ local workbench_formspec = 'size[8,9;]' ..


minetest.register_lbm({
label = "workbench formspec replacement",
name = ":castle:workbench_formspec_replacement",
nodenames = {"lord_artisan_benches:workbench"},
label = 'workbench formspec replacement',
name = ':castle:workbench_formspec_replacement',
nodenames = {'workbench:workbench'},
run_at_every_load = true,
action = function(pos, node)
local meta = minetest.get_meta(pos)
meta:set_string('formspec', workbench_formspec)
end
})

minetest.register_node("lord_artisan_benches:workbench", {
description = S("Workbench"),
drawtype = "mesh",
mesh = "workbench.obj",
tiles = { "benches_workbench.png" },
--tiles = {
-- "benches_workbench_top.png",
-- "default_wood.png",
-- "benches_workbench_1.png",
-- "benches_workbench_1.png",
-- "benches_workbench_2.png",
-- "benches_workbench_2.png"
--},
paramtype2 = "facedir",
paramtype = "light",
minetest.register_node('workbench:workbench', {
description = S('Workbench'),
drawtype = 'mesh',
mesh = 'workbench.obj',
tiles = { 'benches_workbench.png' },
paramtype2 = 'facedir',
paramtype = 'light',
groups = { choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wooden = 1 },
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
Expand All @@ -112,48 +101,42 @@ minetest.register_node("lord_artisan_benches:workbench", {
can_dig = function(pos, player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
return inv:is_empty("src") and inv:is_empty("dst") and inv:is_empty("rec")
return inv:is_empty('src') and inv:is_empty('dst') and inv:is_empty('rec')
end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
if minetest.is_protected(pos, player:get_player_name()) then
minetest.log("action", player:get_player_name() ..
" attempt moves stuff in workbench at " .. minetest.pos_to_string(pos))
minetest.log('action', player:get_player_name() ..
' attempt moves stuff in workbench at ' .. minetest.pos_to_string(pos))
return 0
end
minetest.log("action", player:get_player_name() ..
" moves stuff in workbench at " .. minetest.pos_to_string(pos))
minetest.log('action', player:get_player_name() ..
' moves stuff in workbench at ' .. minetest.pos_to_string(pos))
return count
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then
minetest.log("action", player:get_player_name() ..
" attempt moves stuff to workbench at " .. minetest.pos_to_string(pos))
minetest.log('action', player:get_player_name() ..
' attempt moves stuff to workbench at ' .. minetest.pos_to_string(pos))
return 0
end
minetest.log("action", player:get_player_name() ..
" moves stuff to workbench at " .. minetest.pos_to_string(pos))
minetest.log('action', player:get_player_name() ..
' moves stuff to workbench at ' .. minetest.pos_to_string(pos))
return stack:get_count()
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then
minetest.log("action", player:get_player_name() ..
" attempt takes stuff from workbench at " .. minetest.pos_to_string(pos))
minetest.log('action', player:get_player_name() ..
' attempt takes stuff from workbench at ' .. minetest.pos_to_string(pos))
return 0
end
minetest.log("action", player:get_player_name() ..
" takes stuff from workbench at " .. minetest.pos_to_string(pos))
minetest.log('action', player:get_player_name() ..
' takes stuff from workbench at ' .. minetest.pos_to_string(pos))
return stack:get_count()
end,
-- allow_metadata_inventory_put = function(pos, listname, index, stack, player)
-- end,
-- allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
-- end,
-- allow_metadata_inventory_take = function(pos, listname, index, stack, player)
-- end,
})

minetest.register_abm({
nodenames = { 'lord_artisan_benches:workbench' },
nodenames = { 'workbench:workbench' },
interval = 5,
chance = 1,
action = function(pos, node)
Expand All @@ -179,10 +162,18 @@ minetest.register_abm({
})

minetest.register_craft({
output = "lord_artisan_benches:workbench",
output = 'workbench:workbench',
recipe = {
{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" },
{ "default:wood", "default:wood", "default:steel_ingot" },
{ "default:tree", "default:tree", "default:steel_ingot" },
{ 'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot' },
{ 'default:wood', 'default:wood', 'default:steel_ingot' },
{ 'default:tree', 'default:tree', 'default:steel_ingot' },
}
})


return {
--- @param mod minetest.Mod
init = function(mod)
-- all things done upper
end,
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,3 @@ Barrel=Barrel

### Laboratory ###
Laboratory=Laboratory

### Workbench ###
Workbench=Workbench
Source Material=Source Material
Recipe to Use=Recipe to Use
Craft Output=Craft Output
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,3 @@ Barrel=Бочка

### Laboratory ###
Laboratory=Лаборатория

### Workbench ###
Workbench=Верстак
Source Material=Материалы:
Recipe to Use=Схема:
Craft Output=Результат:
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ return {
require('artisan_benches.barrel')
require('artisan_benches.cauldron')
require('artisan_benches.laboratory')
require('artisan_benches.workbench')
end
}
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 237276d

Please sign in to comment.