kaeza wrote:bdjnk wrote:
I've got some code I'd like to execute whenever a certain type of node is added to the world, including when starting / playing / connecting to the game. Node definitions have lua functions for when hooking to events, for instance on_construct which seemed to most likely candidate, but that doesn't work. Is there some way to do this?
on_construct is only called when the node is placed. Unfortunately, what you require is not so easy (if even practical) to implement.
Edit: I assume you mean the code is run *only* once after connecting. Am I mistaken?
I wasn't very clear, sorry. Yeah, I want it to run once, but probably just when the game / server starts. I don't think I need it for all connecting / joining. I would've thought there'd be some kind of mapping / node creation process that occurred which I'd be able to link into...
Still, I gonna try and use
register_on_joinplayer or
register_on_newplayer and a find_nodes_in_area. I don't think it's the "right" answer, but it might work.
Oh, on that note, what is the difference between register_on_joinplayer and register_on_newplayer? The wiki isn't very clear about it.