Switchbox

Get help using Construct 2

Post » Mon Jun 10, 2013 11:12 pm

Hi People!

I must be committing some simple logical mistake, but i can't figure it out.
http://imgur.com/BD4Gwmw,hQoK5L5
Its a simple switchbox, if i do it like in the image above it works, but i want it to work, so that you press S once it moves in this direction, and if you press S again, it moves back.
http://imgur.com/eDNNJHj
But when i do it like this nothing at all happens :(

Thx in advance people :)El Yoth2013-06-10 23:16:29
B
10
S
3
G
2
Posts: 14
Reputation: 2,409

Post » Tue Jun 11, 2013 12:09 am

The events run top down so when the first event is true and runs the second becomes true and also runs. A solution is to use the "else" condition with subevents:

[code]+ on S pressed
+ onoff=1
-- do this
+ else
-- do that[/code]R0J0hound2013-06-11 00:10:12
B
85
S
27
G
84
Posts: 5,059
Reputation: 57,352

Post » Tue Jun 11, 2013 12:31 am

Thanks a lot R0J0hound!

I tried it the way you suggested, but Else does not work on triggered events :(..
So i tried 'key is down' instead of 'on key pressed', which worked, but also caused the switch to permanently change its state. I got it to work now adding a system 'wait' (for 0.2 seconds) to my former settings and now it works.

You and the whole Construct2-Community are great!

:DEl Yoth2013-06-11 00:32:30
B
10
S
3
G
2
Posts: 14
Reputation: 2,409

Post » Tue Jun 11, 2013 4:49 pm

You missed the part where he said "subevents".
B
58
S
23
G
22
Posts: 890
Reputation: 16,790

Post » Wed Jun 12, 2013 12:24 am

@Magistross & @R0J0hound
Yaaay! Thanks for pointing that out :D
http://imgur.com/umzmMLe
Now it works! (But i feel stupid )El Yoth2013-06-12 00:25:54
B
10
S
3
G
2
Posts: 14
Reputation: 2,409


Return to How do I....?

Who is online

Users browsing this forum: KittenKatja, MAVERICK, QuantumMMX and 12 guests