on_construct is not called when using VoxelManip

User avatar
ArguablySane
Member
 
Posts: 116
Joined: Sun Oct 12, 2014 21:29

on_construct is not called when using VoxelManip

by ArguablySane » Sun Jan 18, 2015 11:27

I'm trying to set metadata for some nodes when they are generated. The dev wiki suggests using the on_construct callback, but unfortunately that doesn't seem to work if I generate them using a VoxelManip during mapgen. For now I'm having to set the metadata manually in the mapgen code.

Is this by design, and is there a nicer way to solve the problem?
The above post and any ideas expressed therein are released to the public domain under a Creative Commons CC0 license.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: on_construct is not called when using VoxelManip

by rubenwardy » Sun Jan 18, 2015 11:59

This is by design as the VoxelManipulator needs to be fast, and so doesn't call callbacks. In order to solve this, you could manually call the on_construct from the manip loop. minetest.registered_items["name"].on_construct(pos, minetest.get_node()), but you should try to minimise this. Running the code in the loop rather than calling on_construct would be better, or running it at a later date.
 

User avatar
ArguablySane
Member
 
Posts: 116
Joined: Sun Oct 12, 2014 21:29

Re: on_construct is not called when using VoxelManip

by ArguablySane » Sun Jan 18, 2015 19:34

Yeah, I suspected that might be the case. Thanks for letting me know anyway.
The above post and any ideas expressed therein are released to the public domain under a Creative Commons CC0 license.
 


Return to Minetest Problems

Who is online

Users browsing this forum: No registered users and 7 guests

cron