Giter Site home page Giter Site logo

Comments (2)

Calinou avatar Calinou commented on September 22, 2024

Adding

if not cost then
    return 0
end

before line 261 (if (incost + cost) > maxcost then in circular_saw.allow_metadata_inventory_put) prevents crash from occurring, but a better approach would be to keep track of aliased nodes in aliases.lua try mapping old node into a new one to consistently calculate cost.

Maybe we should return an extremely high cost in this case? We should avoid introducing a duplication bug while fixing this 🙂

from moreblocks.

Caellian avatar Caellian commented on September 22, 2024

Maybe we should return an extremely high cost in this case? We should avoid introducing a duplication bug while fixing this

Returning 0 from circular_saw.allow_metadata_inventory_put prevents the item from being inserted.
Returning a high cost from circular_saw:get_cost is logically worse than returning nil. Cost for an unhandled item does not exist, thus it makes sense for circular_saw:get_cost to return nil.

I suggested using aliases instead of simply returning 0 as it would result in expected behaviour instead of preventing players from recycling default stairs which might be confusing if they don't know what's going on.

So something along the lines of:

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() == name then
			return circular_saw.cost_in_microblocks[i]
		end
	end
end

Right, that fixes the problem. I'll submit a PR.

from moreblocks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.