Page 1 of 1

Attached Particle Spawners and associated questions

PostPosted: Thu Aug 04, 2016 00:59
by Byakuren
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?

Re: Attached Particle Spawners and associated questions

PostPosted: Thu Aug 04, 2016 08:17
by kahrl
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.

Re: Attached Particle Spawners and associated questions

PostPosted: Thu Aug 04, 2016 18:29
by Byakuren
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.?

Re: Attached Particle Spawners and associated questions

PostPosted: Thu Aug 04, 2016 20:00
by kahrl
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++.

Re: Attached Particle Spawners and associated questions

PostPosted: Thu Aug 04, 2016 20:23
by Byakuren
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.

Re: Attached Particle Spawners and associated questions

PostPosted: Thu Aug 04, 2016 23:02
by Byakuren