Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[no squash] CAO 'node' visual #15683

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

sfan5
Copy link
Collaborator

@sfan5 sfan5 commented Jan 15, 2025

implements #10722

To do

This PR is Ready for Review.

How to test

This code gives you a tool that duplicates an arbitrary node as entity:

minetest.register_entity("test2:cloned", {
	initial_properties = {
		physical = true,
		collide_with_objects = false,
		collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
		static_save = false,
	},
})

minetest.register_tool("test2:clone_tool", {
	description = "Clone Node",
	inventory_image = "plus.png",
	liquids_pointable = true,

	on_use = function(itemstack, placer, pt)
		if placer == nil or pt == nil or pt.type ~= "node" then
			return
		end
		local pos = vector.offset(pt.under, 0, 1.25, 0)
		local entity = minetest.add_entity(pos, "test2:cloned")
		if entity then
			entity:set_properties({
				visual = "node",
				node = core.get_node(pt.under),
			})
		end
		return itemstack
	end,
})

And this one gives you a tool that can make any node fall:

core.register_tool(core.get_current_modname() .. ":fall_tool", {
	description = "Falling Tool",
	inventory_image = "end_icon.png^[transform3",
	liquids_pointable = true,

	on_use = function(itemstack, placer, pt)
		if placer == nil or pt == nil or pt.type ~= "node" then
			return
		end
		local node = core.get_node(pt.under)
		local def = core.registered_nodes[node.name]
		if def and def.drawtype ~= "airlike" then
			local was = def.groups.falling_node
			def.groups.falling_node = 1
			core.check_for_falling(pt.under)
			def.groups.falling_node = was
		end
		return itemstack
	end,
})

@sfan5 sfan5 added @ Script API @ Client / Audiovisuals Feature ✨ PRs that add or enhance a feature labels Jan 15, 2025
@kromka-chleba
Copy link
Contributor

Is this going to support scale? (making the node bigger/smaller)
The origin point is going to be in the center of the node entity?

@sfan5
Copy link
Collaborator Author

sfan5 commented Jan 15, 2025

It will support visual_size like anything else.

@sfan5 sfan5 changed the title CAO 'node' visual [manual merge] CAO 'node' visual Jan 17, 2025
@sfan5 sfan5 marked this pull request as ready for review January 17, 2025 15:29
@lhofhansl
Copy link
Contributor

Tried with random falling nodes and have observed no difference in behavior, with simpler code. Cool.

@sfan5 sfan5 added the Rebase needed The PR needs to be rebased by its author label Jan 19, 2025
@sfan5 sfan5 changed the title [manual merge] CAO 'node' visual [no squash] CAO 'node' visual Jan 20, 2025
@sfan5 sfan5 added Rebase needed The PR needs to be rebased by its author and removed Rebase needed The PR needs to be rebased by its author labels Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@ Client / Audiovisuals Feature ✨ PRs that add or enhance a feature Rebase needed The PR needs to be rebased by its author @ Script API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants