add option to re-enable legacy recipe changes

This commit is contained in:
flux 2022-08-22 12:31:08 -07:00
parent 40dcd14b6f
commit 5ae6dfeb34
No known key found for this signature in database
GPG Key ID: 9333B27816848A15
9 changed files with 206 additions and 14 deletions

View File

@ -12,23 +12,11 @@ jobs:
- name: Install pre-commit
run: pip3 install pre-commit
- name: Run pre-commit
run: pre-commit run --all-files
- name: install luarocks
run: sudo apt-get install -qq luarocks
- name: install luacheck via luarocks
run: luarocks install --local luacheck
- name: luacheck invsaw
run: $HOME/.luarocks/bin/luacheck --config ./invsaw/.luacheckrc -q ./invsaw
- name: luacheck moreblocks
run: $HOME/.luarocks/bin/luacheck --config ./moreblocks/.luacheckrc -q ./moreblocks
- name: luacheck stairsplus
run: $HOME/.luarocks/bin/luacheck --config ./stairsplus/.luacheckrc -q ./stairsplus
- name: luacheck stairsplus_legacy
run: $HOME/.luarocks/bin/luacheck --config ./stairsplus_legacy/.luacheckrc -q ./stairsplus_legacy
- name: Run pre-commit
run: pre-commit run --all-files

View File

@ -8,3 +8,36 @@ repos:
- id: mixed-line-ending
args: [ --fix=lf ]
- repo: local
hooks:
- id: luacheck_invsaw
name: luacheck_invsaw
language: system
entry: luacheck
pass_filenames: false
args: [--config,./invsaw/.luacheckrc,-q,./invsaw]
- id: luacheck_moreblocks
name: luacheck_moreblocks
language: system
entry: luacheck
pass_filenames: false
args: [--config,./moreblocks/.luacheckrc,-q,./moreblocks]
- id: luacheck_moreblocks_legacy_recipes
name: luacheck_moreblocks_legacy_recipes
language: system
entry: luacheck
pass_filenames: false
args: [--config,./moreblocks_legacy_recipes/.luacheckrc,-q,./moreblocks_legacy_recipes]
- id: luacheck_stairsplus
name: luacheck_stairsplus
language: system
entry: luacheck
pass_filenames: false
args: [--config,./stairsplus/.luacheckrc,-q,./stairsplus]
- id: luacheck_stairsplus_legacy
name: luacheck_stairsplus_legacy
language: system
entry: luacheck
pass_filenames: false
args: [--config,./stairsplus_legacy/.luacheckrc,-q,./stairsplus_legacy]

View File

@ -62,6 +62,9 @@ The 3.0.0 release of moreblocks introduces a "legacy" mode, which is on by defau
allow new servers to not commit to creating as many nodes as older versions, while not breaking anything
on existing servers. See `settingtypes.txt` for available settings.
By defaulthe 3.0.0 release disables certain recipe overrides that were part of moreblocks 2.*. To re-enable
them, set `moreblocks_legacy_recipes.enabled = true`.
### Settings
See `settingtypes.txt` for available settings.

View File

@ -0,0 +1,29 @@
std = "lua51+luajit+minetest+moreblocks_legacy_recipes"
unused_args = false
max_line_length = 120
stds.minetest = {
read_globals = {
"DIR_DELIM",
"minetest",
"core",
"dump",
"vector",
"nodeupdate",
"VoxelManip",
"VoxelArea",
"PseudoRandom",
"ItemStack",
"default",
"table",
"math",
"string",
}
}
stds.moreblocks_legacy_recipes = {
globals = {
},
read_globals = {
},
}

View File

@ -0,0 +1,13 @@
# zlib license
Copyright © 2011-2020 Hugo Locurcio and contributors
**This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.**
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.

View File

@ -0,0 +1,18 @@
code to increase the productivity of some recipes which was originally part of
[moreblocks](https://github.com/minetest-mods/moreblocks/) but has since been removed.
copied directly from
https://github.com/minetest-mods/moreblocks/blob/1a03b041dd49cf52e8d5d84e72206718055b1455/redefinitions.lua
## License
Copyright © 2011-2020 Hugo Locurcio and contributors
- More Blocks code is licensed under the zlib license, see
[`LICENSE.md`](LICENSE.md) for details.
- Unless otherwise specified, More Blocks textures are licensed under
[CC BY-SA 3.0 Unported](https://creativecommons.org/licenses/by-sa/3.0/).
`moreblocks_copperpatina.png` was created by pithydon, and is licensed under
[CC0 1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/).

View File

@ -0,0 +1,102 @@
-- disabled by default
if not minetest.settings:get_bool("moreblocks_legacy_recipes.enabled", false) then
return
end
--[[
More Blocks: redefinitions of default stuff
Copyright © 2011-2020 Hugo Locurcio and contributors.
Licensed under the zlib license. See LICENSE.md for more information.
--]]
local modname = minetest.get_current_modname()
-- Redefine some of the default crafting recipes to be more productive
-- Auxiliary function: take a recipe as returned by get_all_craft_recipes
-- and turn it into a table that can be used to clear a craft or declare a new one
local reconstruct_internal_craft = function(recipe)
local recp = {
{ "", "", "" },
{ "", "", "" },
{ "", "", "" },
}
local width = recipe.width
for idx, item in pairs(recipe.items) do
local row = math.ceil(idx / width)
local col = idx - (row-1)*width
recp[row][col] = item
end
return recp
end
-- Change the amount produced by recipe by apply func to the old amount
local change_recipe_amount = function(product, recipe, func)
-- if width == 0, this is a shapeless recipe, for which the
-- internal and Lua API recipe table is the same.
-- Otherwise we need to reconstruct the table for the shaped recipe.
local shapeless = (recipe.width == 0)
local recp = shapeless and recipe.items or reconstruct_internal_craft(recipe)
local oldamount = tonumber(recipe.output:match(" [0-9]+$") or "1")
local newamount = func(oldamount)
-- remove old crafting recipe
local redo = { recipe = recp }
-- preserve shapelessness
if shapeless then
redo.type = "shapeless"
end
minetest.clear_craft(redo)
-- new output
redo.output = ("%s %d"):format(product, newamount)
minetest.register_craft(redo)
minetest.log("action", ("[MOD]%s: recipe for %s production: %d => %d"):format(
modname, product, oldamount, newamount
))
end
local increase_craft_production = function(product, func)
local recipes = minetest.get_all_craft_recipes(product)
for _, r in pairs(recipes) do
if r.type == "normal" or r.method == "normal" then
change_recipe_amount(product, r, func)
end
end
end
-- Increase the crafting production according to the rules from the table, which is in the form:
-- {
-- { detector, amount changing function }
-- { detector, amount changing function }
-- }
-- TODO: consider exporting this function to other mods
local increase_craft_production_table = function(map_table)
for product, _ in pairs(minetest.registered_items) do
for _, tab in pairs(map_table) do
local detector = tab[1]
local func = tab[2]
if detector(product) then
increase_craft_production(product, func)
-- only apply one boost
break
end
end
end
end
increase_craft_production_table({
{ function(n) return n:match('^default:sign_wall') end, function(old) return old + 1 end },
{ function(n) return n == 'default:paper' end, function(old) return old*4 end },
{ function(n) return n:match('^carts:.*rail$') or n:match('^default:.*rail$') end,
function(old) return old + old/2 end },
})
minetest.register_craft({
type = "toolrepair",
additional_wear = -0.10, -- Tool repair buff (10% bonus instead of 2%).
})

View File

@ -0,0 +1,3 @@
name = moreblocks_legacy_recipes
description = adds back recipe changes that used to be part of moreblocks
optional_depends = carts, default

View File

@ -7,6 +7,9 @@ invsaw.creative_priv (Priv to use the inventory saw w/out a saw item) string cre
# The item that a normal player has to have to use the saw in inventory
invsaw.saw_item (Saw item) string stairsplus:circular_saw
# whether to increase the yield of certain crafting recipes as in moreblocks 2.*
moreblocks_legacy_recipes.enabled (Enable legacy recipes) bool false
# Add a yellow outline around trap nodes, to make them visibly distinct
moreblocks.outline_trap_nodes (Outline trap nodes) bool true