Dynamic Object Reference (Wish List)

Discussion and feedback on Construct 2

Post » Mon Dec 09, 2013 7:55 pm

First Off... The work you've done with this is absolutely amazing... it took only 3 days of playing with this before deciding to buy a license Please don't stop the hard work.

So on to the biggest thing that I feel would add incredible value as a seasoned developer the only thing I'm really missing is the ability to "dynamically reference an object" (not an instance but the object class its self) based on some sort of reference.

I use functions religiously to reduce coding but any time I want create a method lets say to take an array and parse it into collection of a certain dictionary type (Create multiple instances of the same dictionary type) I have to create a function for every dictionary type and cannot create single function that passes the dictionary type I want to instantiate.

Example:


(I'm ambitiously attempting to build a multilayer game cross device)

Please look at the image above. I call an Ajax method to get my player list. Now I can dynamically pass any list I want to the function but I cannot dynamically specify what dictionary type to load it to. I always have to hard code it meaning I have to copy and past this function for every dictionary type I want to create. As in the example above I'm generating my "Players" instances from the list my Ajax call receives.

I would love if I could have just one function for this process instead having to recreate the same function and hard code the dictionary type I'm loading.

Please let me know if your working on or will at some point work on making this available. I would love this feature more than words can describe and think others would as well.

Thank you!
B
20
S
7
G
1
Posts: 221
Reputation: 2,077

Post » Mon Dec 09, 2013 8:43 pm

A much easier way to use multiple dictionaries is to put a dictionary in a container with a sprite. Then each sprite gets its own dictionary.

You can pass a reference to an object by passing its UID to a function, then picking it back with the 'Pick by UID' condition. In recent builds 'Pick by UID' should run in approximately constant time.
Scirra Founder
B
395
S
232
G
88
Posts: 24,371
Reputation: 193,772

Post » Mon Dec 09, 2013 9:37 pm

@Ashley

Thank you for the prompt reply.

This however doesn't solve my problem I don't think? If I put the dictionary in a sprite then I still have to hard code the specific sprite I want to access INSIDE the function.

What I was hoping for was the ability that when ever I set an Event or an Action that looks for object (IE Event: "For each" or Action: "Create Object") that instead of being restricted to the list of objects in my project that I can also use a function parameter in this case i would pass the "Players" Object as a parameter to the function and be able to reference that parameter when defining an event or action inside the function.

I could then call this function any time and pass it any Array and any Dictionary and it will take the Array and generate a dynamic number of instances of the Dictionary from it and load the corresponding values.
B
20
S
7
G
1
Posts: 221
Reputation: 2,077

Post » Mon Dec 09, 2013 9:44 pm

Well it looks like you're creating a dictionary per player, in which case putting it in a container with the player itself makes sense. You shouldn't need to hard code the object to use if you make use of families or UIDs.
Scirra Founder
B
395
S
232
G
88
Posts: 24,371
Reputation: 193,772

Post » Tue Dec 10, 2013 12:07 am

@Ashley

Thank you for pointing me in the right direction. I did finally solve it. Its not very attractive looking but it works. I hope someday you guy give us true dynamic object referencing but for now here is an example for anyone interested.

troublesum2013-12-10 00:08:33
B
20
S
7
G
1
Posts: 221
Reputation: 2,077

Post » Tue Dec 10, 2013 1:52 am

@Ashley

I take it back... after adding more dictionaries to the Family I found that the "Create Object" method actually creates a new instance of EVERY object in the family and not just the one I had selected by UID. I cant seem to find a away around this.

I have to always inside the function declare the object I want created removing my ability to re-use this function for other objects.

Anyways... thanks for the help. I did learn more useful stuff but I would still like the ability to dynamically pass an object (not the instance but the object class it self) to a function and call the parameter in the Event/Action with in the function it was passed to.

The complexity of games that can be achieved with this would be huge.... food for thought.

Thanks again for all your hard work.
B
20
S
7
G
1
Posts: 221
Reputation: 2,077

Post » Tue Dec 10, 2013 8:37 pm

@troublesum , try nickname plugin
ImageImage
B
70
S
21
G
7
Posts: 827
Reputation: 10,052

Post » Tue Dec 10, 2013 11:23 pm

@vtrix

You sir are my hero... Glad to see the community offering solutions as I know Ashley must be swamped with requests.
troublesum2013-12-10 23:27:39
B
20
S
7
G
1
Posts: 221
Reputation: 2,077


Return to Construct 2 General

Who is online

Users browsing this forum: LaDestitute, rbailey83 and 24 guests