forked from minetest-mods/moreblocks
Compare commits
15 Commits
b93949c266
...
v2.2.0
Author | SHA1 | Date | |
---|---|---|---|
1f1959ba54 | |||
3b97ea5697 | |||
bcd1a5688b | |||
1a03b041dd | |||
b39bb31295 | |||
ddf8b39f5a | |||
ff7e85094f | |||
0c2c3ad4ef | |||
8a14250127 | |||
cf0f875709 | |||
c3b45149b0 | |||
ab91ad967a | |||
5aacb05b14 | |||
87e27d9f20 | |||
26ca7af997 |
@ -1,7 +1,8 @@
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v2.3.0
|
||||
rev: v3.3.0
|
||||
hooks:
|
||||
- id: fix-byte-order-marker
|
||||
- id: end-of-file-fixer
|
||||
- id: trailing-whitespace
|
||||
|
||||
|
51
CHANGELOG.md
51
CHANGELOG.md
@ -7,20 +7,49 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [2.2.0] - 2021-06-28
|
||||
|
||||
### Changed
|
||||
|
||||
- Refactored recipe override mechanism to avoid re-coding recipes
|
||||
when we only want to change the amount produced.
|
||||
- [Realigned rail recipe to the changes made in Minetest Game.](https://github.com/minetest-mods/moreblocks/pull/169)
|
||||
- All rail recipes (standard, power, break) were boosted by 50%.
|
||||
|
||||
### Fixed
|
||||
|
||||
- [Shapeless crafting recipes are now handled in redefinitions.](https://github.com/minetest-mods/moreblocks/pull/171)
|
||||
- [Aliases are now resolved in Stairs+ circular saw cost calculation.](https://github.com/minetest-mods/moreblocks/pull/175)
|
||||
- [Fixed strange placement behavior for non-default Stairs+ nodes.](https://github.com/minetest-mods/moreblocks/pull/168)
|
||||
- [Fixed stairs placement over oddly-shaped nodes.](https://github.com/minetest-mods/moreblocks/pull/166)
|
||||
|
||||
## [2.1.0] - 2020-12-14
|
||||
|
||||
### Added
|
||||
|
||||
- Clean Glass versions of Trap and (Super) Glowing Glass.
|
||||
- Compressed desert cobblestone.
|
||||
|
||||
### Changed
|
||||
|
||||
- Revised placing strategy that takes into account which side of the face
|
||||
(top/bottom for horizontal, left/right for vertical placement) is being clicked.
|
||||
Aux (sprint/special, default E) key can be used to place the node with the orientation
|
||||
it would have if placed from the other side.
|
||||
When placing nodes next to nodes of the same gategory (e.g.slab to slab) the other
|
||||
node's orientation is copied, flipping it placing on top or below an upright or
|
||||
upside-down node. In this case the aux key will disable the special processing of
|
||||
same-category nodes.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Revised minetest_game crafting recipe overrides to match Minetest 5.0.0 and later.
|
||||
|
||||
### Removed
|
||||
|
||||
- Legacy Stairs+ conversion code.
|
||||
- It was only required to import worlds last edited before Q3 2013.
|
||||
|
||||
### Changed
|
||||
|
||||
- Switch to GitHub Actions.
|
||||
- Benefits include faster responses.
|
||||
|
||||
### Added
|
||||
|
||||
- Compressed desert cobblestone.
|
||||
|
||||
## [2.0.0] - 2019-11-25
|
||||
|
||||
### Added
|
||||
@ -104,7 +133,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
|
||||
- Initial versioned release.
|
||||
|
||||
[Unreleased]: https://github.com/minetest-mods/moreblocks/compare/v2.0.0...HEAD
|
||||
[Unreleased]: https://github.com/minetest-mods/moreblocks/compare/v2.2.0...HEAD
|
||||
[2.2.0]: https://github.com/minetest-mods/moreblocks/compare/v2.1.0...v2.2.0
|
||||
[2.1.0]: https://github.com/minetest-mods/moreblocks/compare/v2.0.0...v2.1.0
|
||||
[2.0.0]: https://github.com/minetest-mods/moreblocks/compare/v1.3.0...v2.0.0
|
||||
[1.3.0]: https://github.com/minetest-mods/moreblocks/compare/v1.2.0...v1.3.0
|
||||
[1.2.0]: https://github.com/minetest-mods/moreblocks/compare/v1.1.0...v1.2.0
|
||||
|
@ -58,7 +58,7 @@ on that line.
|
||||
|
||||
## Version compatibility
|
||||
|
||||
More Blocks is currently primarily tested with Minetest 5.1.0.
|
||||
More Blocks is currently primarily tested with Minetest 5.3.0.
|
||||
It may or may not work with newer or older versions. Issues arising in older
|
||||
versions than 5.0.0 will generally not be fixed.
|
||||
|
||||
|
@ -89,8 +89,9 @@ circular_saw.names = {
|
||||
}
|
||||
|
||||
function circular_saw:get_cost(inv, stackname)
|
||||
local name = minetest.registered_aliases[stackname] or stackname
|
||||
for i, item in pairs(inv:get_list("output")) do
|
||||
if item:get_name() == stackname then
|
||||
if item:get_name() == name then
|
||||
return circular_saw.cost_in_microblocks[i]
|
||||
end
|
||||
end
|
||||
|
88
crafting.lua
88
crafting.lua
@ -348,12 +348,36 @@ minetest.register_craft({
|
||||
recipe = {"moreblocks:sweeper", "default:glass"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:trap_clean_glass",
|
||||
type = "shapeless",
|
||||
recipe = {"default:mese_crystal_fragment", "moreblocks:clean_glass"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:trap_clean_glass",
|
||||
type = "shapeless",
|
||||
recipe = {"moreblocks:sweeper", "moreblocks:trap_glass"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:glow_glass",
|
||||
type = "shapeless",
|
||||
recipe = {"default:torch", "default:glass"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:clean_glow_glass",
|
||||
type = "shapeless",
|
||||
recipe = {"default:torch", "moreblocks:clean_glass"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:clean_glow_glass",
|
||||
type = "shapeless",
|
||||
recipe = {"moreblocks:sweeper", "moreblocks:glow_glass"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:trap_glow_glass",
|
||||
type = "shapeless",
|
||||
@ -366,6 +390,26 @@ minetest.register_craft({
|
||||
recipe = {"default:mese_crystal_fragment", "moreblocks:glow_glass"},
|
||||
})
|
||||
|
||||
-- several recipes are possible for the trap+clean+glow, we only present 3 of them
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:trap_clean_glow_glass",
|
||||
type = "shapeless",
|
||||
recipe = {"default:mese_crystal_fragment", "moreblocks:clean_glow_glass"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:trap_clean_glow_glass",
|
||||
type = "shapeless",
|
||||
recipe = {"default:mese_crystal_fragment", "moreblocks:clean_glass", "default:torch"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:trap_clean_glow_glass",
|
||||
type = "shapeless",
|
||||
recipe = {"moreblocks:sweeper", "moreblocks:trap_glow_glass" },
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:super_glow_glass",
|
||||
type = "shapeless",
|
||||
@ -378,6 +422,24 @@ minetest.register_craft({
|
||||
recipe = {"default:torch", "moreblocks:glow_glass"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:clean_super_glow_glass",
|
||||
type = "shapeless",
|
||||
recipe = {"default:torch", "default:torch", "moreblocks:clean_glass"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:clean_super_glow_glass",
|
||||
type = "shapeless",
|
||||
recipe = {"default:torch", "moreblocks:clean_glow_glass"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:clean_super_glow_glass",
|
||||
type = "shapeless",
|
||||
recipe = {"moreblocks:sweeper", "moreblocks:super_glow_glass"},
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:trap_super_glow_glass",
|
||||
@ -391,6 +453,32 @@ minetest.register_craft({
|
||||
recipe = {"default:mese_crystal_fragment", "moreblocks:super_glow_glass"},
|
||||
})
|
||||
|
||||
-- several recipes are possible for the trap+clean+glow, we only present 4 of them
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:trap_clean_super_glow_glass",
|
||||
type = "shapeless",
|
||||
recipe = {"default:mese_crystal_fragment", "moreblocks:clean_super_glow_glass"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:trap_clean_super_glow_glass",
|
||||
type = "shapeless",
|
||||
recipe = {"default:mese_crystal_fragment", "moreblocks:clean_glow_glass", "default:torch"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:trap_clean_super_glow_glass",
|
||||
type = "shapeless",
|
||||
recipe = {"default:mese_crystal_fragment", "moreblocks:clean_glass", "default:torch", "default:torch"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:trap_clean_super_glow_glass",
|
||||
type = "shapeless",
|
||||
recipe = {"moreblocks:sweeper", "moreblocks:trap_super_glow_glass" },
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:coal_stone",
|
||||
type = "shapeless",
|
||||
|
3
init.lua
3
init.lua
@ -20,7 +20,6 @@ dofile(modpath .. "/config.lua")
|
||||
dofile(modpath .. "/circular_saw.lua")
|
||||
dofile(modpath .. "/stairsplus/init.lua")
|
||||
dofile(modpath .. "/nodes.lua")
|
||||
dofile(modpath .. "/redefinitions.lua")
|
||||
dofile(modpath .. "/crafting.lua")
|
||||
dofile(modpath .. "/aliases.lua")
|
||||
|
||||
minetest.log("action", "[moreblocks] loaded.")
|
||||
|
83
nodes.lua
83
nodes.lua
@ -194,7 +194,7 @@ local nodes = {
|
||||
description = S("Iron Glass"),
|
||||
drawtype = "glasslike_framed_optional",
|
||||
tiles = {"default_glass.png^[colorize:#DEDEDE", "default_glass_detail.png^[colorize:#DEDEDE"},
|
||||
use_texture_alpha = true,
|
||||
use_texture_alpha = "clip",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
@ -205,7 +205,7 @@ local nodes = {
|
||||
description = S("Coal Glass"),
|
||||
drawtype = "glasslike_framed_optional",
|
||||
tiles = {"default_glass.png^[colorize:#828282", "default_glass_detail.png^[colorize:#828282"},
|
||||
use_texture_alpha = true,
|
||||
use_texture_alpha = "clip",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
@ -216,7 +216,7 @@ local nodes = {
|
||||
description = S("Clean Glass"),
|
||||
drawtype = "glasslike_framed_optional",
|
||||
tiles = {"moreblocks_clean_glass.png", "moreblocks_clean_glass_detail.png"},
|
||||
use_texture_alpha = true,
|
||||
use_texture_alpha = "clip",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
@ -316,7 +316,7 @@ local nodes = {
|
||||
description = S("Trap Glass"),
|
||||
drawtype = "glasslike_framed_optional",
|
||||
tiles = {"default_glass.png^moreblocks_trap_box_glass.png", "default_glass_detail.png"},
|
||||
use_texture_alpha = true,
|
||||
use_texture_alpha = "clip",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
@ -329,7 +329,7 @@ local nodes = {
|
||||
description = S("Trap Obsidian Glass"),
|
||||
drawtype = "glasslike_framed_optional",
|
||||
tiles = {"default_obsidian_glass.png^moreblocks_trap_box_glass.png", "default_obsidian_glass_detail.png"},
|
||||
use_texture_alpha = true,
|
||||
use_texture_alpha = "clip",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
@ -349,6 +349,19 @@ local nodes = {
|
||||
sounds = sound_stone,
|
||||
no_stairs = true,
|
||||
},
|
||||
["trap_clean_glass"] = {
|
||||
description = S("Trap Clean Glass"),
|
||||
drawtype = "glasslike_framed_optional",
|
||||
tiles = {"moreblocks_clean_glass.png^moreblocks_trap_box_glass.png", "moreblocks_clean_glass_detail.png"},
|
||||
use_texture_alpha = "clip",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
walkable = false,
|
||||
groups = {cracky = 3, oddly_breakable_by_hand = 3},
|
||||
sounds = sound_glass,
|
||||
no_stairs = true,
|
||||
},
|
||||
["trap_sandstone"] = {
|
||||
description = S("Trap Sandstone"),
|
||||
drawtype = "glasslike_framed",
|
||||
@ -399,7 +412,19 @@ local nodes = {
|
||||
description = S("Glow Glass"),
|
||||
drawtype = "glasslike_framed_optional",
|
||||
tiles = {"default_glass.png^[colorize:#E9CD61", "default_glass_detail.png^[colorize:#E9CD61"},
|
||||
use_texture_alpha = true,
|
||||
use_texture_alpha = "clip",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
light_source = 11,
|
||||
groups = {cracky = 3, oddly_breakable_by_hand = 3},
|
||||
sounds = sound_glass,
|
||||
},
|
||||
["clean_glow_glass"] = {
|
||||
description = S("Clean Glow Glass"),
|
||||
drawtype = "glasslike_framed_optional",
|
||||
tiles = {"moreblocks_clean_glass.png^[colorize:#E9CD61", "moreblocks_clean_glass_detail.png^[colorize:#E9CD61"},
|
||||
use_texture_alpha = "clip",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
@ -411,7 +436,21 @@ local nodes = {
|
||||
description = S("Trap Glow Glass"),
|
||||
drawtype = "glasslike_framed_optional",
|
||||
tiles = {"default_glass.png^[colorize:#E9CD61^moreblocks_trap_box_glass.png", "default_glass_detail.png^[colorize:#E9CD61"},
|
||||
use_texture_alpha = true,
|
||||
use_texture_alpha = "clip",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
light_source = 11,
|
||||
walkable = false,
|
||||
groups = {cracky = 3, oddly_breakable_by_hand = 3},
|
||||
sounds = sound_glass,
|
||||
no_stairs = true,
|
||||
},
|
||||
["trap_clean_glow_glass"] = {
|
||||
description = S("Trap Clean Glow Glass"),
|
||||
drawtype = "glasslike_framed_optional",
|
||||
tiles = {"moreblocks_clean_glass.png^[colorize:#E9CD61^moreblocks_trap_box_glass.png", "moreblocks_clean_glass_detail.png^[colorize:#E9CD61"},
|
||||
use_texture_alpha = "clip",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
@ -425,7 +464,19 @@ local nodes = {
|
||||
description = S("Super Glow Glass"),
|
||||
drawtype = "glasslike_framed_optional",
|
||||
tiles = {"default_glass.png^[colorize:#FFFF78", "default_glass_detail.png^[colorize:#FFFF78"},
|
||||
use_texture_alpha = true,
|
||||
use_texture_alpha = "clip",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
light_source = default.LIGHT_MAX,
|
||||
groups = {cracky = 3, oddly_breakable_by_hand = 3},
|
||||
sounds = sound_glass,
|
||||
},
|
||||
["clean_super_glow_glass"] = {
|
||||
description = S("Clean Super Glow Glass"),
|
||||
drawtype = "glasslike_framed_optional",
|
||||
tiles = {"moreblocks_clean_glass.png^[colorize:#FFFF78", "moreblocks_clean_glass_detail.png^[colorize:#FFFF78"},
|
||||
use_texture_alpha = "clip",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
@ -437,7 +488,21 @@ local nodes = {
|
||||
description = S("Trap Super Glow Glass"),
|
||||
drawtype = "glasslike_framed_optional",
|
||||
tiles = {"default_glass.png^[colorize:#FFFF78^moreblocks_trap_box_glass.png", "default_glass_detail.png^[colorize:#FFFF78"},
|
||||
use_texture_alpha = true,
|
||||
use_texture_alpha = "clip",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
light_source = default.LIGHT_MAX,
|
||||
walkable = false,
|
||||
groups = {cracky = 3, oddly_breakable_by_hand = 3},
|
||||
sounds = sound_glass,
|
||||
no_stairs = true,
|
||||
},
|
||||
["trap_clean_super_glow_glass"] = {
|
||||
description = S("Trap Clean Super Glow Glass"),
|
||||
drawtype = "glasslike_framed_optional",
|
||||
tiles = {"moreblocks_clean_glass.png^[colorize:#FFFF78^moreblocks_trap_box_glass.png", "moreblocks_clean_glass_detail.png^[colorize:#FFFF78"},
|
||||
use_texture_alpha = "clip",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
|
94
redefinitions.lua
Normal file
94
redefinitions.lua
Normal file
@ -0,0 +1,94 @@
|
||||
--[[
|
||||
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%).
|
||||
})
|
@ -15,6 +15,109 @@ local descriptions = {
|
||||
["stair"] = S("%s Stairs"),
|
||||
}
|
||||
|
||||
-- Extends the standad rotate_node placement so that it takes into account
|
||||
-- the side (top/bottom or left/right) of the face being pointed at.
|
||||
-- As with the standard rotate_node, sneak can be used to force the perpendicular
|
||||
-- placement (wall placement on floor/ceiling, floor/ceiling placement on walls).
|
||||
-- Additionally, the aux / sprint / special key can be used to place the node
|
||||
-- as if from the opposite side.
|
||||
--
|
||||
-- When placing a node next to one of the same category (e.g. slab to slab or
|
||||
-- stair to stair), the default placement (regardless of sneak) is to copy the
|
||||
-- under node's param2, flipping if placed above or below it. The aux key disable
|
||||
-- this behavior.
|
||||
local wall_right_dirmap = {9, 18, 7, 12}
|
||||
local wall_left_dirmap = {11, 16, 5, 14}
|
||||
local ceil_dirmap = {20, 23, 22, 21}
|
||||
|
||||
-- extract the stairsplus category from a node name
|
||||
-- assumes the name is in the form mod_name:category_original_ndoe_name
|
||||
local function name_to_category(name)
|
||||
local colon = name:find(":") or 0
|
||||
colon = colon + 1
|
||||
local under = name:find("_", colon)
|
||||
return name:sub(colon, under)
|
||||
end
|
||||
|
||||
stairsplus.rotate_node_aux = function(itemstack, placer, pointed_thing)
|
||||
local sneak = placer and placer:get_player_control().sneak
|
||||
local aux = placer and placer:get_player_control().aux1
|
||||
|
||||
-- category for what we are placing
|
||||
local item_prefix = name_to_category(itemstack:get_name())
|
||||
-- category for what we are placing against
|
||||
local under = pointed_thing.under
|
||||
local under_node = minetest.get_node(under)
|
||||
local under_prefix = under_node and name_to_category(under_node.name)
|
||||
|
||||
local same_cat = item_prefix == under_prefix
|
||||
|
||||
-- standard (floor) facedir, also used for sneak placement against the lower half of the wall
|
||||
local p2 = placer and minetest.dir_to_facedir(placer:get_look_dir()) or 0
|
||||
|
||||
-- check which face and which quadrant we are interested in
|
||||
-- this is used both to check if we're handling parallel placement in the same-category case,
|
||||
-- and in general for sneak placement
|
||||
local face_pos = minetest.pointed_thing_to_face_pos(placer, pointed_thing)
|
||||
local face_off = vector.subtract(face_pos, under)
|
||||
|
||||
-- we cannot trust face_off to tell us the correct directionif the
|
||||
-- under node has a non-standard shape, so use the distance between under and above
|
||||
local wallmounted = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.above, under))
|
||||
|
||||
if same_cat and not aux then
|
||||
p2 = under_node.param2
|
||||
-- flip if placing above or below an upright or upside-down node
|
||||
-- TODO should we also flip when placing next to a side-mounted node?
|
||||
if wallmounted < 2 then
|
||||
if p2 < 4 then
|
||||
p2 = (p2 + 2) % 4
|
||||
p2 = ceil_dirmap[p2 + 1]
|
||||
elseif p2 > 19 then
|
||||
p2 = ceil_dirmap[p2 - 19] - 20
|
||||
p2 = (p2 + 2) % 4
|
||||
end
|
||||
end
|
||||
else
|
||||
-- for same-cat placement, aux is used to disable param2 copying
|
||||
if same_cat then
|
||||
aux = not aux
|
||||
end
|
||||
|
||||
local remap = nil
|
||||
|
||||
-- standard placement against the wall
|
||||
local use_wallmap = (wallmounted > 1 and not sneak) or (wallmounted < 2 and sneak)
|
||||
|
||||
-- standard placement against the ceiling, or sneak placement against the upper half of the wall
|
||||
local use_ceilmap = wallmounted == 1 and not sneak
|
||||
use_ceilmap = use_ceilmap or (wallmounted > 1 and sneak and face_off.y > 0)
|
||||
|
||||
if use_wallmap then
|
||||
local left = (p2 == 0 and face_off.x < 0) or
|
||||
(p2 == 1 and face_off.z > 0) or
|
||||
(p2 == 2 and face_off.x > 0) or
|
||||
(p2 == 3 and face_off.z < 0)
|
||||
if aux then
|
||||
left = not left
|
||||
end
|
||||
remap = left and wall_left_dirmap or wall_right_dirmap
|
||||
elseif use_ceilmap then
|
||||
remap = ceil_dirmap
|
||||
end
|
||||
|
||||
if aux then
|
||||
p2 = (p2 + 2) % 4
|
||||
end
|
||||
|
||||
if remap then
|
||||
p2 = remap[p2 + 1]
|
||||
end
|
||||
end
|
||||
|
||||
return minetest.item_place(itemstack, placer, pointed_thing, p2)
|
||||
end
|
||||
|
||||
stairsplus.register_single = function(category, alternate, info, modname, subname, recipeitem, fields)
|
||||
local src_def = minetest.registered_nodes[recipeitem] or {}
|
||||
local desc_base = descriptions[category]:format(fields.description)
|
||||
@ -42,7 +145,7 @@ stairsplus.register_single = function(category, alternate, info, modname, subnam
|
||||
-- Darken light sources slightly to make up for their smaller visual size
|
||||
def.light_source = math.max(0, (def.light_source or 0) - 1)
|
||||
|
||||
def.on_place = minetest.rotate_node
|
||||
def.on_place = stairsplus.rotate_node_aux
|
||||
def.groups = stairsplus:prepare_groups(fields.groups)
|
||||
|
||||
if category == "slab" then
|
||||
|
@ -25,7 +25,7 @@ function stairsplus:prepare_groups(groups)
|
||||
local result = {}
|
||||
if groups then
|
||||
for k, v in pairs(groups) do
|
||||
if k ~= "wood" and k ~= "stone" then
|
||||
if k ~= "wood" and k ~= "stone" and k ~= "wool" and k ~= "tree" then
|
||||
result[k] = v
|
||||
end
|
||||
end
|
||||
|
@ -61,8 +61,6 @@ for _, name in pairs(default_nodes) do
|
||||
-- Stone and desert_stone drop cobble and desert_cobble respectively.
|
||||
if type(ndef.drop) == "string" then
|
||||
ndef.drop = ndef.drop:gsub(".+:", "")
|
||||
elseif name == "desert_stone" then
|
||||
ndef.drop = ndef.drop.items[1].items[1]:gsub(".+:", "")
|
||||
end
|
||||
|
||||
-- Use the primary tile for all sides of cut glasslike nodes and disregard paramtype2.
|
||||
@ -108,9 +106,6 @@ if minetest.get_modpath("wool") then
|
||||
local ndef = table.copy(minetest.registered_nodes[nodename])
|
||||
ndef.sunlight_propagates = true
|
||||
|
||||
-- Prevent dye+cut wool recipy from creating a full wool block.
|
||||
ndef.groups.wool = nil
|
||||
|
||||
stairsplus:register_all(mod, name, nodename, ndef)
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user