[quote:28c7c1a7]Nice work. Looks pretty slick.
I was reading up on the thread that explains why picking works this way now, and I'm actually confused.
In the thread, it is explained that the object doesn't exist to same-level events until the next top level event. Then how come pick by UID works on our tests?
Agree that it gets confusing, because its logic that you have created the object, so surely it must be there, but it actually ain't as explained by Ashley in that post.
A solution also from that post is:
[quote:28c7c1a7]The workaround is to try to do everything in the same event - nest the other events beneath the creating event if possible, so everything is moved up in to the green area.
Which are the reason that you can create an object and right afterwards set its variables.
Set Object name = "Whatever"
That also means that you can pick UID of the object if its in a sub level of the create function.
But if you do it like this:
level 1: Create object
Level 1: Pick Object with UID of the newly created object shouldn't work.
You have to reach a top level. (Now this post is from version r102, so its pretty old, but don't think a lot if any have changed.)
However the common way of dealing with this problem as you most likely know is to throw in a Wait of 0, 0.1 or 0.01 or whatever as it will then go through to the next tick and force it to reach a top level or what to say and then it works. Im not really sure how solid this actually is, it seems to work well with simple stuff, but if it gets a bit complex it seems to not really work well.
For instant if you have an event:
Repeat 10 times
------- Call function("Spawn enemy")
Function Spawn enemy
Call function ("initialize enemy")
Function Initialize enemy
Call function ("Create enemy weapon")
Function Create enemy weapon
Then suddenly things starts to go wrong as I see it.
Because now there are actually two objects that doesn't exist yet, The Enemy and the Weapon that you want it to use. So if you throw in a Wait different places to solve it, It might work. However at the very start we are actually repeating this 10 times, to create 10 enemies which will then create 10 different weapons, so suddenly you might have 20 objects that actually doesn't exist, and then it seems to go wrong. Whether that's completely true im not 100% sure about, but it seems that a function doesn't count as a top level, which I find to be logic if its the case, but I haven't seen anything saying that it ain't which is why im not certain.
As I mentioned in my last post, I had to repeat it 5 times, but I did something similar with 50 objects using a wait, and it looked like it was working fine, however as I went through the objects in the debugger I could see that suddenly some of the objects would have "NaN" in some of the variables. Which didn't make sense as 95-98% of them had no problems and all different possibilities for this variable was used, but for some reason some of them just failed, and my guess it that since I repeated it several times, it might have screwed up with the wait somehow. So the only thing I did, was to move the function call to the Object handler, didn't change any code and none of them had any problems after that, same goes for several other mistakes that was happening. So I moved those as well and now all of them gets initialized correctly, without having to use wait, which I think in itself is a huge benefit.