How to spawn a buddy?
-
@Deeeds as far as I know, yes. That’s why I suggested a project.
-
@iTap-Development Are you SURE it works? Have you ever done this?
Spawn and object. Let's call him Mate
Spawn an object to be Mate's Buddy
Mate sends a channelID to Buddy
Buddy sets that variable in his local storage.
Buddy's got a Receiver with an Event Key that's set to that locally stored variable.
Everything works except Buddy's receiver.
-
@iTap-Development @Aidan-Oxley I found the problem.
Buddy's Receiver is set by creating a copy of what's in the variable for itself, it's not a reference to the variable's contents (nor is looking contents via a pointer etc). So once it gets a value from the variable, it's got its own copy and isn't actually looking at the variable's contents to know what it's listening to.
In the initial Spawning, he's getting a null as the receiving channel because the variable hasn't yet been initialised.
And that never changes, even when the variable's value changes.
A very slight delay before activating the receiver forces it to set itself with that variable after the variable has been initialised with the value of the previously received ChannelID from his Mate.
This goes back to my other point, somewhere else, that I think broadcasting might be quite efficient, and that @hamed is setting up fast lookup tables for messaging and been a clever fella about how he's done messaging, even if nobody has bothered to describe how/why it works the way it does.
-
@Deeeds that’s why I suggested sharing a project! Glad you figured it out!
-
@iTap-Development How would that help to share a project for that?
This is why I asked you about conceptual thinking.
The question contains the problem.
-
@Deeeds because I could have looked at it and potentially found the problem, especially since I’ve built similar before.
-
@iTap-Development I'll say this once again:
The problem is CONCEPTUAL!
How does one do this kind of thing in this engine with its limited sense of relationships?
That is the question and the problem.
This is not about one specific effort, this is about understanding the limitations of this engine and its approaches to relationships.
Is it making sense what I'm asking, now?
-
@Deeeds you asked a specific question about a specific problem you were having with a specific behavior. Sure, you are wondering about the concept, but also specifically asked, “can a receiver use a variable as the Event Key?”. So stop with the concept nonsense.
-
@iTap-Development It's in the very first word of the original post:
"imagine"
-
@iTap-Development Think outside the bun.
The question, the Original post, is the problem trying to be solved. That is a CONCEPTUAL problem.
Along the way to solving that might be some examples, and I posited one, a buddy relationship. You're welcome to use other examples. But the problem remains conceptual. How does one reference a buddy of a spawned mate?
Whilst I thought I'd solved this problem, I have not.
Can you demonstrate that it's possible?
That might be a better way to use your literalist thinking.
Here's the example that demonstrates the problem.
Spawning 3 mates.
Each mate then spawns a buddy.
Each mate wants to be able to communicate with his buddy.
Is this possible in this engine?
At this point, I'm saying no. It seems broadcasting gets hung up around the first instance for the spawned buddy.
-
@Deeeds I’ll see about building that....I might not have time tonight, but I’ll try.
-
@Deeeds what would you like them to communicate?
-
@Deeeds is having the mate and buddy see each other’s position and move based on the position(or something like that) good enough?
-
@iTap-Development For an example of communication, think of something that can only be seen internally by mate and buddy. Say, for example, the result of some calculation in Mate that he wants to share with his buddy.
-
@iTap-Development and CHEERS ! For the time and consideration. THANK YOU!
-
@Deeeds Yes, it is possible, but not as easy as you’d like.
This is for my new “KrystalOS” (touch-screen OS simulator)
I’ve successfully made a Loop spawn my “App_Base” object, each of their X coord is unique (in the spawn Loop, SpawnObjectX = LoopIndex).After this loop finishes, another loop runs which broadcasts to each individual app by using their unique broadcast key (from the x position) in the broadcast, I send them their App Name and App Index.
-
@Deeeds great! I’ll see what I can do.
-
@Kamdroid This is very similar to my testbed.
The initial loop is exactly like yours, the index is used as an ID for the spawned objects.
Then the spawned objects are each spawning One buddy for themselves, and giving him that ID as channel to receive messages on.
Then the "master" will sometimes send details about events in its world to its buddy. And this is where things aren't working as expected, or reliably.
That I need to go to this degree of bother is also INFURIATING me. It's not often I beg for encapsulation and polymorphism. But I do today.
-
@Kamdroid This has taught me a very dirty trick. I spawn the objects to a position of x based on their index, and then, inside them, use a "get position" to create their ID, then use an array of their desired positions to move them where they should, also based on that index value, as their desired position is in that array.
-
@Deeeds I honestly don’t find it too dirty, it’s quite easy to implement