[PLUGIN] Instance Group

Forum Home Forum Home > Construct 2 Development > Plugins for Construct 2
 Post Reply Post Reply Page  123 5>
Author
10,423 Rep
Post Options Post Options   Quote rexrainbow Quote  Post ReplyReply Direct Link To This Post Topic: [PLUGIN] Instance Group
    Posted: 01 Mar 2012 at 9:52am
Instance Group
(Update: 2013/05/05)

This plugin contains groups indexed by name. Each group stored instances by UID. The group supports two kinds of data structures:
- set: union,complement,intersection
- list: sorting

In actions of this plugin, you can
- add/remove uid to/from a group
- union,complement,intersection
- shuffle a group
- sort by custom function
- pick instances from a group (using uid)
In conditions, you can
- retrieve a group
- test if a uid is in a group
In expressions, you can
- get uid from index (since group is a list)
- get index by uid

When instance destroyed, plugin will remove uid from groups automatically.



Here is an example.


You can sort the group by custom function.
1. Declare sorting function by "Condition: On sorting".
2. In this function, you can get two values from "Expression: CmpUIDA" and "Expression: CmpUIDB", using these two uid to pick up instances and compare them by your rule.
3. Finally, using "Action: Set compared result" to tell plugin which one is larger.


Advance: private group
"Expression: PrivateGroup" can return a special group name formatted by
"@" + uid + "$" + name
. Group which created by these name will be destroyed automatically when instance had been destroyed.
For example, group "@10$aa","@10$bb" will be destroyed automatically when instance with (uid=10) has been destroyed.



PS. There is a small plugin which can provide "action:pick instance by UID". It can save events.

Edited by rexrainbow - 05 May 2013 at 7:14am
Back to Top
9,205 Rep
Post Options Post Options   Quote edisone Quote  Post ReplyReply Direct Link To This Post Posted: 01 Mar 2012 at 9:20pm
so powerful!!!
Back to Top
10,423 Rep
Post Options Post Options   Quote rexrainbow Quote  Post ReplyReply Direct Link To This Post Posted: 02 Mar 2012 at 1:01am
Sorry, I put wrong image in the first thread. Fix it.

Edited by rexrainbow - 02 Mar 2012 at 1:01am
Back to Top
922 Rep
Post Options Post Options   Quote unlikely Quote  Post ReplyReply Direct Link To This Post Posted: 02 Mar 2012 at 4:27am
I was working on a node-based path plugin, but I may just try something with this instead. Thanks!
Back to Top
10,423 Rep
Post Options Post Options   Quote rexrainbow Quote  Post ReplyReply Direct Link To This Post Posted: 02 Mar 2012 at 4:45am
@unlikely

I made this plugin for storing/retrieving a group of instances in event sheet. It could be an input/output for other plugins.

For example, a kind of "filter" (plugin) will get instances from a (instance) group, do some computing, then put the result in another (instance) group.
So that user could get the result group to do their jobs in event sheet.

I'll need to define an api for this purpose.

Edited by rexrainbow - 02 Mar 2012 at 4:53am
Back to Top
922 Rep
Post Options Post Options   Quote unlikely Quote  Post ReplyReply Direct Link To This Post Posted: 02 Mar 2012 at 4:55am
Yes, I see.

I'm still trying to figure out the best way to implement a path (not pathfinding, just path) system. I have started working on a plugin, but I am not sure I can get it to do exactly what I want. I'm also not sure precisely how to implement it, whether it be simply an array of points that also contain information about smoothness of the path there and relative speed adjustments, or something more simple.

I guess ideally I would have a path object with nodes that define the path and how the path is parametrized... I could ask the path for the position at a specific "time" along the path--a parametrized curve.

Sorry, I don't know if any of that ramble made sense, but that is my goal.

Edited by unlikely - 02 Mar 2012 at 4:59am
Back to Top
10,423 Rep
Post Options Post Options   Quote rexrainbow Quote  Post ReplyReply Direct Link To This Post Posted: 02 Mar 2012 at 5:05am
@unlikely

I made Zigzag behavior before. It used a LOGO-like script to describe a path, like "F 100;R 60".
Back to Top
922 Rep
Post Options Post Options   Quote unlikely Quote  Post ReplyReply Direct Link To This Post Posted: 02 Mar 2012 at 5:08am
Ah, yes, that looks fairly close to essentially what I'm after. It's not exactly what would be ideal in my situation, but it will certainly be helpful--I'll check it out. Thank you!
Back to Top
6,626 Rep
Post Options Post Options   Quote tonycrew Quote  Post ReplyReply Direct Link To This Post Posted: 02 Mar 2012 at 11:48pm
Nice Plugin rex...
http://dl.dropbox.com/u/44766364/Games/Space2011/index.html Space 2011 (C2 Competition Entry
http://dl.dropbox.com/u/44766364/Games/getin/index.html Get That Ball In (C2 Game)
Back to Top
10,423 Rep
Post Options Post Options   Quote rexrainbow Quote  Post ReplyReply Direct Link To This Post Posted: 03 Mar 2012 at 5:45am
Update:

- Add missing expression description.
- Add "private group" feature to simulate private group of instance. Using "expression: PrivateGroup" to get private group name when getting a group. See the first post for more detail.

Edited by rexrainbow - 03 Mar 2012 at 9:23am
Back to Top
 Post Reply Post Reply Page  123 5>

Forum Jump Forum Permissions View Drop Down