Allow excess items in recipe stacks (by default), eject excess.
This makes it a little easier to discover recipes, since you now generally don't have to get the exact count right anymore; just make sure you at least have enough.
This commit is contained in:
parent
1f6239f101
commit
bd0f201469
@ -9,16 +9,15 @@ ISSUES: Bugs, Cleanup and Refinements
|
||||
# # # # # # # # # # # #
|
||||
#### # #### # ###### ###### # # ####
|
||||
|
||||
- buildable_to issues.
|
||||
- Needs to explicitly check for ignores.
|
||||
- Needs to be used in repose logic (check for other places it's
|
||||
not used).
|
||||
|
||||
- Clean up registered_* lookups everywhere.
|
||||
- Be consistent about registered_items vs registered_nodes (or
|
||||
any other builtin registered_*)
|
||||
- Guard against unregistered stuff, e.g. reg[name] or {}
|
||||
|
||||
- New content needs hints!
|
||||
- Go thru github commits to see what.
|
||||
- Definitely includes optics.
|
||||
|
||||
- Stuff in mid-soak (esp. metallurgy) doesn't stack due to metadata
|
||||
- Clean up metadata somehow...?
|
||||
- "Active" node stacks with cleanup abm?
|
||||
@ -27,7 +26,6 @@ ISSUES: Bugs, Cleanup and Refinements
|
||||
- Grass growing ABM needs rethunk.
|
||||
|
||||
- API Cleanup
|
||||
- Guard minetest, nodecore, etc. against : calls instead of . calls.
|
||||
- Utils
|
||||
- Box mueller and exporand
|
||||
- Break up the nc_api monstrosity.
|
||||
@ -45,10 +43,6 @@ ISSUES: Bugs, Cleanup and Refinements
|
||||
- Unify nc_items and visinv API.
|
||||
- Stack nodes are "special", get first-class support.
|
||||
|
||||
- New content needs hints!
|
||||
- Go thru github commits to see what.
|
||||
- Definitely includes optics.
|
||||
|
||||
- Separate punch and tool HUDs?
|
||||
- Use waypoints for punches?
|
||||
- Use 2 text lines above/below?
|
||||
|
@ -45,8 +45,7 @@ end
|
||||
local function check_empty(pos, dx, dy, dz)
|
||||
for ndy = dy, 1 do
|
||||
local p = {x = pos.x + dx, y = pos.y + ndy, z = pos.z + dz}
|
||||
local node = minetest.get_node(p)
|
||||
if not minetest.registered_nodes[node.name].buildable_to then return end
|
||||
if not nodecore.buildable_to(p) then return end
|
||||
end
|
||||
return {x = pos.x + dx, y = pos.y, z = pos.z + dz}
|
||||
end
|
||||
|
@ -10,6 +10,7 @@ local match_skip = {
|
||||
groups = true,
|
||||
stack = true,
|
||||
count = true,
|
||||
excess = true,
|
||||
wear = true
|
||||
}
|
||||
|
||||
@ -45,7 +46,8 @@ function nodecore.match(thing, crit)
|
||||
if crit.name and thing.name ~= crit.name then return end
|
||||
if crit.param2 and thing.param2 ~= crit.param2 then return end
|
||||
if crit.param and thing.param ~= crit.param then return end
|
||||
if crit.count and thing.count ~= crit.count then return end
|
||||
if crit.count and thing.count < crit.count then return end
|
||||
if crit.count and (not crit.excess) and thing.count > crit.count then return end
|
||||
if crit.count == nil and thing.count ~= 1 then return end
|
||||
if crit.wear then
|
||||
if crit.wear < 1 then crit.wear = crit.wear * 65535 end
|
||||
|
@ -1,8 +1,13 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local nodecore
|
||||
= nodecore
|
||||
local minetest, nodecore
|
||||
= minetest, nodecore
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
function nodecore.buildable_to(node_or_pos)
|
||||
return nodecore.match(node_or_pos, {buildable_to = true})
|
||||
function nodecore.buildable_to(thing)
|
||||
if not thing.name then
|
||||
thing = nodecore.underride(thing, minetest.get_node(thing))
|
||||
end
|
||||
if thing.name == "ignore" then return end
|
||||
local def = minetest.registered_items[thing.name] or {}
|
||||
return def.buildable_to
|
||||
end
|
||||
|
@ -1,6 +1,8 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local ItemStack, ipairs, minetest, nodecore, pairs, type
|
||||
= ItemStack, ipairs, minetest, nodecore, pairs, type
|
||||
local ItemStack, ipairs, math, minetest, nodecore, pairs, type
|
||||
= ItemStack, ipairs, math, minetest, nodecore, pairs, type
|
||||
local math_ceil
|
||||
= math.ceil
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local function craftcheck(recipe, pos, node, data, xx, xz, zx, zz)
|
||||
@ -58,6 +60,17 @@ local function craftcheck(recipe, pos, node, data, xx, xz, zx, zz)
|
||||
if r and type(r) == "string" then
|
||||
r = {name = r}
|
||||
end
|
||||
if v.match.excess then
|
||||
local s = nodecore.stack_get(p)
|
||||
local x = s:get_count() - (v.match.count or 1)
|
||||
local n = math_ceil(x / 4)
|
||||
while x > 0 do
|
||||
if n > x then n = x end
|
||||
x = x - n
|
||||
s:set_count(n)
|
||||
nodecore.item_eject(p, s, 5)
|
||||
end
|
||||
end
|
||||
if r then minetest.set_node(p, r) end
|
||||
end
|
||||
end
|
||||
|
@ -18,6 +18,9 @@ function nodecore.register_craft(recipe)
|
||||
v.x = v.x or 0
|
||||
v.y = v.y or 0
|
||||
v.z = v.z or 0
|
||||
if type(v.match) == "table" and v.match.count then
|
||||
v.match.excess = v.match.excess or true
|
||||
end
|
||||
canrot = canrot or v.x ~= 0 or v.z ~= 0
|
||||
if v.x == 0 and v.y == 0 and v.z == 0 then
|
||||
recipe.root = v
|
||||
|
Loading…
x
Reference in New Issue
Block a user