[Behaviour] Store Reference

Post your completed addons to share with the community

Post » Wed Apr 17, 2013 4:10 pm


Store Reference Behaviour (v1.0)



Current problem in Construct 2:
It is not very straightforward to stablish relationships between gameobjects. If two objects A and B are related, then A must keep a variable with B's IID or UID and then keep checking which object has that id value. This may lead to repetitive code to keep variables that don't really store the object B, but only its identification.

Besides that, that way of coding doesn't allow you to keep, for a same object, a relationship to a variable amount of objects (unless you store IIDs or UIDs on an Array object, but that will increase the complexity of your project a lot).

The Behaviour:
Instances can hold Text, Boolean or Number variables. This behaviour creates the possibility for Object variables, in which you can store and retrieve objects. It allows your object to have as many variables as you want.

This is how you store objects:



And this is one of the ways to retrieve them:



As you can see, object variables are different from the usual variables because they are actually an array of objects. That gives you much more power to hold as many objects as you want.

I hope you enjoy it. Suggestions are welcome!

Links:

Behaviour Download (v1.0)
Example
Github Repository
Azis2013-04-17 21:29:00
B
5
S
1
Posts: 15
Reputation: 680

Post » Wed Apr 17, 2013 9:23 pm

Super Plugin!!!
Great Work

Kind Regards.
Savvy001
B
56
S
20
G
13
Posts: 778
Reputation: 13,204

Post » Sat Apr 20, 2013 3:55 am

Yes very good
B
61
S
9
G
7
Posts: 176
Reputation: 8,824

Post » Thu Jul 11, 2013 9:15 am

I think it could be very useful, but it's not possible to establish relations between instances of the same object. I have a feature suggestion for your plugin, it's called reference by tag:

- user can put a tag (string) into any object or instance and than set reference to that tag.
- it is possible to pick referenced object/instances by tag
B
42
S
11
G
4
Posts: 505
Reputation: 7,267

Post » Thu Jul 11, 2013 1:16 pm

@xoros

How is that any different than an instance variable?
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Thu Jul 11, 2013 5:59 pm

Yeah, that's true. Than call it reference by instance variable.
B
42
S
11
G
4
Posts: 505
Reputation: 7,267

Post » Thu Feb 12, 2015 1:16 pm

Seems useful !
B
12
S
7
G
7
Posts: 446
Reputation: 4,268

Post » Fri Jun 12, 2015 1:47 am

Hi, I am a beginner,
I like your behavior, would you please let me know how to set "owner" to player? thanks
B
11
S
3
Posts: 172
Reputation: 1,178


Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 1 guest