Attached Particle Spawners and associated questions

Byakuren
Member
 
Posts: 441
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri

Attached Particle Spawners and associated questions

by Byakuren » Thu Aug 04, 2016 00:59

I was thinking of implementing attached particle spawners (https://github.com/minetest/minetest/issues/567), and had a few questions.

  • Which parts of the code would I need to change to extend an existing server -> client message (add particle spawner)?
  • Are the ids for corresponding CAOs and SAOs equal?
  • I am planning on having SAOs have a std::set of the ids of the particle spawners that are attached to them, so that they can be removed when they are unloaded. Is this a good idea?
Every time a mod API is left undocumented, a koala dies.
 

kahrl
Member
 
Posts: 236
Joined: Fri Sep 02, 2011 07:51

Re: Attached Particle Spawners and associated questions

by kahrl » Thu Aug 04, 2016 08:17

ad 1: You would change the sending code (Server::SendAddParticleSpawner in server.cpp) and the receiving code (Client::handleCommand_AddParticleSpawner in network/clientpackethandler.cpp). Make sure to wrap the receiving part in a try-catch block so that clients remain compatible with old servers.

ad 2: Yes.

ad 3: Seems fine to me, though I might be missing a potential problem as I haven't worked on the active object code in a long time.
 

Byakuren
Member
 
Posts: 441
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri

Re: Attached Particle Spawners and associated questions

by Byakuren » Thu Aug 04, 2016 18:29

kahrl wrote:ad 1: You would change the sending code (Server::SendAddParticleSpawner in server.cpp) and the receiving code (Client::handleCommand_AddParticleSpawner in network/clientpackethandler.cpp). Make sure to wrap the receiving part in a try-catch block so that clients remain compatible with old servers.

ad 2: Yes.

ad 3: Seems fine to me, though I might be missing a potential problem as I haven't worked on the active object code in a long time.

Thanks kahrl. Do you also know whether there is a function for getting userdata fields from a table, similar to getintfield etc.?
Every time a mod API is left undocumented, a koala dies.
 

kahrl
Member
 
Posts: 236
Joined: Fri Sep 02, 2011 07:51

Re: Attached Particle Spawners and associated questions

by kahrl » Thu Aug 04, 2016 20:00

Byakuren wrote:Thanks kahrl. Do you also know whether there is a function for getting userdata fields from a table, similar to getintfield etc.?

Use lua_getfield to retrieve the field value and push it to the Lua stack, then a function like ObjectRef::checkobject or LuaItemStack::checkobject (etc...) to convert it to a pointer to some type that's usable from C++.
 

Byakuren
Member
 
Posts: 441
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri

Re: Attached Particle Spawners and associated questions

by Byakuren » Thu Aug 04, 2016 20:23

kahrl wrote:
Byakuren wrote:Thanks kahrl. Do you also know whether there is a function for getting userdata fields from a table, similar to getintfield etc.?

Use lua_getfield to retrieve the field value and push it to the Lua stack, then a function like ObjectRef::checkobject or LuaItemStack::checkobject (etc...) to convert it to a pointer to some type that's usable from C++.

Alright, I did that. Thank you again.
Every time a mod API is left undocumented, a koala dies.
 

Byakuren
Member
 
Posts: 441
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri

Re: Attached Particle Spawners and associated questions

by Byakuren » Thu Aug 04, 2016 23:02

Every time a mod API is left undocumented, a koala dies.
 


Return to Minetest Engine

Who is online

Users browsing this forum: No registered users and 1 guest

cron