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

Throw nodes when not placing #40

Open
CasimirKaPazi opened this issue May 25, 2017 · 1 comment
Open

Throw nodes when not placing #40

CasimirKaPazi opened this issue May 25, 2017 · 1 comment

Comments

@CasimirKaPazi
Copy link
Owner

See forum.

@CasimirKaPazi
Copy link
Owner Author

CasimirKaPazi commented May 25, 2017

Put this into default/init.lua before loading the nodes.

minetest.nodedef_default.on_secondary_use = function(itemstack, user)
	local pos = user:get_pos()
	local dir = user:get_look_dir()
	pos = {x=pos.x+(dir.x*2), y=pos.y+(dir.y*2)+1, z=pos.z+(dir.z*2)}
	if minetest.get_node(pos).name ~= "air" then return end
	local n_name = itemstack:get_name()
	local obj = core.add_entity(pos, "__builtin:falling_node")
	if obj then
		obj:get_luaentity():set_node({name = n_name})
		obj:setvelocity({x=dir.x*2, y=dir.y*2, z=dir.z*2})
	end
	if not minetest.setting_getbool("creative_mode") then
		itemstack:take_item()
	end
	return itemstack
end

To do next:

  • respect protection
  • have a privilege or setting to turn of on servers
  • maybe a sound effect

edit:

  • pick up chests and furnaces with all metadata and inventory intact

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant