Attached Particle Spawners and associated questions

For people working on the C++ code.
Post Reply
Byakuren
Member
Posts: 818
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Attached Particle Spawners and associated questions

by Byakuren » Post

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
Location: Rös̓̇chenhof

Re: Attached Particle Spawners and associated questions

by kahrl » Post

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: 818
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: Attached Particle Spawners and associated questions

by Byakuren » Post

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
Location: Rös̓̇chenhof

Re: Attached Particle Spawners and associated questions

by kahrl » Post

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: 818
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: Attached Particle Spawners and associated questions

by Byakuren » Post

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: 818
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: Attached Particle Spawners and associated questions

by Byakuren » Post

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

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests