How do I properly create objects based on specific instances

Get help using Construct 2

Post » Fri Feb 20, 2015 7:42 am

123.jpg

As you can see in the first event, I'm trying to create an object Check everytime an instance of this object is InUse (Boolean). I can have only 2 instances of this object with InUse set to True at the same time, so when I have only one instance with InUse as True, it runs once as it should be, but when I have two it starts to loop infinitly. The problem is that I can't figure out how to stop this infinity loop. I've tried other ways to do it but I'm too blind to see the solution because I'm on this for several hours and I stopped thinking many hours ago :D . A different point of view and a fresh mind would be nice to help me solve this. ;)

Thanks!
You do not have the required permissions to view the files attached to this post.
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Post » Fri Feb 20, 2015 8:04 am

> @kossglobal

It is way simpler if you do "Pick Nth instance" (System expression) then in your case pick 2nd (your limit).
You can say "if pick second is not true" > "spawn" (a second) object
thus never having more than two instances in the first place.

If you need them to be there first, but then destroyed, do the same with "pick 3rd instance" > if true destroy. So you will always keep two instances of your object.


I hope it helps.
B
8
S
3
Posts: 197
Reputation: 1,207

Post » Fri Feb 20, 2015 8:06 am

Can you try to put "For each Cunstomizations" on top?
Or even better, can you give us capx? :)
B
12
S
6
G
2
Posts: 99
Reputation: 1,727

Post » Fri Feb 20, 2015 6:25 pm

MultipleChoice wrote:> @kossglobal

It is way simpler if you do "Pick Nth instance" (System expression) then in your case pick 2nd (your limit).
You can say "if pick second is not true" > "spawn" (a second) object
thus never having more than two instances in the first place.

If you need them to be there first, but then destroyed, do the same with "pick 3rd instance" > if true destroy. So you will always keep two instances of your object.


I hope it helps.


My limit is already being handled correctly by another event and everything is working. The problem that I'm facing is just the visual part where I must tell to the player that he selected an icon/customization. Just it. I think this logic doesn't work. This method will never get the first instance. Also I have to spawn the object when it's true not the other way and I need an automatic way because I don't know if I'll allow the player to select more than two in the future.

@razorMonkey

I tried. It's the same.
I can't share it because it's a published project. But there is no need because everything about the problem is shown in the pic.
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Post » Fri Feb 20, 2015 7:34 pm

I'm losing my patience about this sh*t. I think i'll create a check object for each icon and then just play with visible and invisible checks. This not the best way to go but will work.
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Post » Fri Feb 20, 2015 10:16 pm

If you can replicate this in a sample capx it would be good. Not everyone has time to try and recreate the problem in a capx.

edit: try this method. I've put in a button to toggle the 'in use' for each Customization. It retains the 'trigger once' and will work for any number of Customizations.
customizations.capx


If you want a simple checkbox it can be as simple as this
checkbox.capx
You do not have the required permissions to view the files attached to this post.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Fri Feb 20, 2015 11:16 pm

codah wrote:If you can replicate this in a sample capx it would be good. Not everyone has time to try and recreate the problem in a capx.

edit: try this method. I've put in a button to toggle the 'in use' for each Customization. It retains the 'trigger once' and will work for any number of Customizations.
customizations.capx


If you want a simple checkbox it can be as simple as this
checkbox.capx


I was complaining about myself trying to solve the question. :)

I'll look at it. Thanks!
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Post » Fri Feb 20, 2015 11:56 pm

kossglobal wrote:
codah wrote:If you can replicate this in a sample capx it would be good. Not everyone has time to try and recreate the problem in a capx.

edit: try this method. I've put in a button to toggle the 'in use' for each Customization. It retains the 'trigger once' and will work for any number of Customizations.
customizations.capx


If you want a simple checkbox it can be as simple as this
checkbox.capx


I was complaining about myself trying to solve the question. :)

I'll look at it. Thanks!


Yeah I know, mine was just a general comment. For example I did recreate the issue (I think) so it would've been even easier for you to just copy/paste some code out to another capx (maybe). :)
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sat Feb 21, 2015 2:10 am

codah wrote:
kossglobal wrote:
codah wrote:If you can replicate this in a sample capx it would be good. Not everyone has time to try and recreate the problem in a capx.

edit: try this method. I've put in a button to toggle the 'in use' for each Customization. It retains the 'trigger once' and will work for any number of Customizations.
customizations.capx


If you want a simple checkbox it can be as simple as this
checkbox.capx


I was complaining about myself trying to solve the question. :)

I'll look at it. Thanks!


Yeah I know, mine was just a general comment. For example I did recreate the issue (I think) so it would've been even easier for you to just copy/paste some code out to another capx (maybe). :)


Yeah I should had done that. It's because I'm rushing the update of my game so I posted the pic and then I came back to work on other stuff too :P
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Post » Sat Feb 21, 2015 10:35 am

@kossglobal
Can you, instead of Trigger once, put some boolean variable into each object and set it to false, put condition that only executes that actian if that boolean inside object is false and create action that puts boolean to true. That should force it to execute only once per object.
Can you, instead of Trigger once, put some boolean variable into each object and set it to false, put condition that only executes that actian if that boolean inside object is false and create action that puts boolean to true. That should force it to execute only once per object.
B
12
S
6
G
2
Posts: 99
Reputation: 1,727

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 17 guests