How do I add an instance with iid=0?

Get help using Construct 2

Post » Thu Jun 23, 2016 10:27 pm

@99Instances2Go ,
An object type has an array:
type.instances[]
This holds essentially a list of instances, and when you create a new instance, it gets added to the end of it.
What I want is an option to add to the beginning of that Array.
B
41
S
19
G
65
Posts: 1,085
Reputation: 37,842

Post » Thu Jun 23, 2016 10:37 pm

Instances are identical. Unless you know something we don't.
Image ImageImage
B
168
S
50
G
164
Posts: 8,227
Reputation: 105,573

Post » Thu Jun 23, 2016 10:58 pm

newt wrote:Instances are identical. Unless you know something we don't.

No they aren't, that's why there is an array of instances, to hold all the different ones. When there is no SOL, it references the type.instance[] array. Pick Nth Instance would pick based on the index of that array.

I'm looking to see if I can create a plugin that can reorder the type.instance[] array. Not sure if it can, but even so, would be nice to have this implemented without needing a plugin.
B
41
S
19
G
65
Posts: 1,085
Reputation: 37,842

Post » Thu Jun 23, 2016 11:17 pm

So let's get this straight.
You want to destroy the first instance, and create a new instance, and have it replace the first instance?
Image ImageImage
B
168
S
50
G
164
Posts: 8,227
Reputation: 105,573

Post » Thu Jun 23, 2016 11:26 pm

I want to be able to create an object, specifying whether to add the instance to the front of the instance array or the back.
B
41
S
19
G
65
Posts: 1,085
Reputation: 37,842

Post » Thu Jun 23, 2016 11:41 pm

Ok, now tell use what is different between the one you are creating, and the one at the front, other than iid, size, angle, opacity, or position.
Image ImageImage
B
168
S
50
G
164
Posts: 8,227
Reputation: 105,573

Post » Thu Jun 23, 2016 11:56 pm

The difference is that if I can create an object at front so that it has index 0, I can design events more cleanly. There is less room for error, less potential for wrong instances to be picked, less overhead managing variables, easier to change/modify existing objects, etc.
Ideally, I'd want to be able to create an object and specify which iid it will have, essentially inserting it anywhere in the array (not overwriting anything). Specifying front or back was just my easier suggestion.
Seriously- this would be really useful. Maybe it's not clear to you, but I've been doing things the ways you've suggested countless times in the past, and I come to realize this sort of feature would help me a lot.

I've been looking at plugin stuff, and I don't think it's possible to do it with a plugin, but maybe someone who knows more about creating a plugin would know whether it is possible. Hopefully @Ashley will consider this feature.
B
41
S
19
G
65
Posts: 1,085
Reputation: 37,842

Post » Fri Jun 24, 2016 12:14 am

You can push the UID of each object as it is created to the back (or front) of an array, and manipulate that array as you see fit. The array object will give you all the granular control you want. Sounds like you probably already knew that though.

I got the impression that the developers specifically discourage using IIDs at all, which is why there are very limited expressions to utilize them.
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303

Post » Fri Jun 24, 2016 1:30 am

Prominent wrote:The difference is that if I can create an object at front so that it has index 0, I can design events more cleanly. There is less room for error, less potential for wrong instances to be picked, less overhead managing variables, easier to change/modify existing objects, etc.
Ideally, I'd want to be able to create an object and specify which iid it will have, essentially inserting it anywhere in the array (not overwriting anything). Specifying front or back was just my easier suggestion.
Seriously- this would be really useful. Maybe it's not clear to you, but I've been doing things the ways you've suggested countless times in the past, and I come to realize this sort of feature would help me a lot.

I've been looking at plugin stuff, and I don't think it's possible to do it with a plugin, but maybe someone who knows more about creating a plugin would know whether it is possible. Hopefully @Ashley will consider this feature.


I completely disagree. Moving iids around would more likely cause confusion as you are taking something and replacing it with something that is identical.
All you are really doing is changing how it looks in your head.
It's almost like taking the joker card, and replacing the ace, but it's worse, you're taking an ace, and replacing an ace.

Let me make a suggestion since you are having trouble organising it.
Why don't you start from the end of the index rather than the beginning?
Sprite(sprite.count) gives you the last index, so every time you create something it will effectively be at your start position.
Image ImageImage
B
168
S
50
G
164
Posts: 8,227
Reputation: 105,573

Post » Fri Jun 24, 2016 1:45 am

I can't do that because I am using both ends. I need to be able to add to either end.
And this wouldn't move IIDs around that much- only when object is created.
The benefits are greater than you realize.
B
41
S
19
G
65
Posts: 1,085
Reputation: 37,842

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: jaytrott86 and 10 guests