Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for the onSpawn() function? #146

Open
rkrempel opened this issue Dec 5, 2021 · 1 comment
Open

Documentation for the onSpawn() function? #146

rkrempel opened this issue Dec 5, 2021 · 1 comment

Comments

@rkrempel
Copy link

rkrempel commented Dec 5, 2021

So, I wanted a function to execute on an object when it spawns, but being a noob (I've managed to stay away from activities that required me to code for several decades), I did some testing first.

on Global:
function onObjectSpawn(object)
print('onObjectSpawn got triggered by '..object.getGUID())
object.call("onSpawn")
end

on the Object:
function onSpawn() --called by Global onObjectSpawn()
print('onSpawn got called on'..self.getGUID())
end

However, to my surprise, every copy/paste of the object printed "'onSpawn got called on.." twice, so eh?!?

I renamed "onSpawn" to "onSpawn2", then it got printed just once. Old name, but no Global script also leads it to printing it once.
New name, no Global script: zero. I conclude there exists a function "onSpawn()" that gets called when the script-owner Object spawns. Useful, but I cannot find any documentation on it in the API or anywhere else. I was even looking for such a function before deciding to use onObjectSpawn(). So: 🤬!

This really should be documented. No idea how to do this or who is in charge of doing it, just saying it's something worth doing. I found out the problem relatively quickly because the above was literally the only scripting going on. In a larger script, it could have taken ages to figure out what was going on. Especially for a noob like me.

@vutmu
Copy link

vutmu commented Dec 8, 2021

++ I confirm it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants