Skip to content

[no squash] CAO 'node' visual#15683

Merged
sfan5 merged 5 commits into
luanti-org:masterfrom
sfan5:caonodevisual
Feb 22, 2025
Merged

[no squash] CAO 'node' visual#15683
sfan5 merged 5 commits into
luanti-org:masterfrom
sfan5:caonodevisual

Conversation

@sfan5

@sfan5 sfan5 commented Jan 15, 2025

Copy link
Copy Markdown
Member

implements, closes #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
Copy Markdown
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

sfan5 commented Jan 15, 2025

Copy link
Copy Markdown
Member Author

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
Copy Markdown
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 added a commit to sfan5/luanti that referenced this pull request 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
sfan5 added a commit to sfan5/luanti that referenced this pull request Feb 15, 2025
@sfan5 sfan5 removed the Rebase needed The PR needs to be rebased by its author label Feb 15, 2025
sfan5 added a commit to sfan5/luanti that referenced this pull request Feb 15, 2025
sfan5 added a commit to sfan5/luanti that referenced this pull request Feb 15, 2025
@SmallJoker
SmallJoker self-requested a review February 15, 2025 14:15

@SmallJoker SmallJoker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested drawtypes:

  • degrotate rooted plantlike
  • normal
  • wallmounted
  • facedir
  • 4dir
  • color4dir
  • colorfacedir
  • colorwallmounted
  • colordegrotate

Works well.

Comment thread doc/lua_api.md
Comment thread src/client/content_cao.cpp
Comment thread builtin/game/falling.lua
Comment thread src/client/content_cao.cpp Outdated
@Zughy Zughy added the Action / change needed Code still needs changes (PR) / more information requested (Issues) label Feb 21, 2025
@sfan5 sfan5 removed the Action / change needed Code still needs changes (PR) / more information requested (Issues) label Feb 22, 2025

@SmallJoker SmallJoker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works.

@sfan5
sfan5 merged commit d12ce68 into luanti-org:master Feb 22, 2025
sfan5 added a commit that referenced this pull request Feb 22, 2025
@sfan5
sfan5 deleted the caonodevisual branch February 22, 2025 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add “node” entity visual

5 participants