How can I stop items from dropping when a node (isn't) broken?

bbqroast
New member
 
Posts: 4
Joined: Thu Oct 10, 2013 01:44

How can I stop items from dropping when a node (isn't) broken?

by bbqroast » Thu Oct 10, 2013 20:33

Hey,

I'm writing a mod in which some nodes will not break. Right now I have done this by catching the on node break event and placing the old node back in it's original position. This works except the node still drops an item. Is their a better way to stop a node from breaking?

The nodes can be of all types and placed anywhere in the world
 

User avatar
Topywo
Member
 
Posts: 1718
Joined: Fri May 18, 2012 20:27

by Topywo » Thu Oct 10, 2013 21:21

bbqroast wrote:Hey,

I'm writing a mod in which some nodes will not break. Right now I have done this by catching the on node break event and placing the old node back in it's original position. This works except the node still drops an item. Is their a better way to stop a node from breaking?

The nodes can be of all types and placed anywhere in the world


drop = '', (or drop = "", ) causes no item to be dropped.


Removing the dig type (don't know the proper name) from groups, for example:
groups = {crumbly=3,soil=1}, --> groups = {soil=1},
makes them unbreakable.

Search in this file: minetest/doc/lua_api.txt 'groups' to learn more of them.
 

bbqroast
New member
 
Posts: 4
Joined: Thu Oct 10, 2013 01:44

by bbqroast » Thu Oct 10, 2013 22:19

I'm not creating new node types. Rather I'm trying to prevent specific nodes in the world from dropping items when they are broken, the nodes that don't drop things could be pretty much anything.

I'm writing a protection plugin.
 

User avatar
Menche
Member
 
Posts: 994
Joined: Sat Jul 02, 2011 00:43

by Menche » Fri Oct 11, 2013 00:06

See this code from node_ownership. Basically what it does is back up the built-in node_dig, item_place, and node_punch functions, then override them. The permission check is done in the overridden function, and the original function is called only if a player is allowed to dig.
Last edited by Menche on Fri Oct 11, 2013 00:06, edited 1 time in total.
An innocent kitten dies every time you top-post.
I am on the Voxelands Forums more often than here.
Try Voxelands (forked from Minetest 0.3) by darkrose
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 5 guests

cron