How to add randomness in Construct 2?

Get help using Construct 2

Post » Thu Sep 17, 2015 6:31 am

LittleStain wrote:
Calfuso wrote:
BackendFreak wrote:First of all you don't need parenthesis. You use them to group calculations like in math.

Second thing. Every event is being checked every frame (so approx. 60 times a second). So if you want to trigger this random calculation only once then you have to add an extra check which will determine if this should be ran or not (suggesting a boolean-like variable or a trigger action like "On tap..."). But I have a feeling that the first thing you should read is How Events Work. Then you may want to read about the "hidden" useful functions called System expressions. This should make many things clear for you.





The Manual has never or will never help me. It's something whit how it's written whit not including all the fact you need and being confusing. If i couldn't understand the manual better i would ask alot less in these forums. I like tutorials though. I want to try the Boolean thing. I made a Boolean and set it to false. Shall i set it to true after the event has happened or what.


Why not?
You could even add the timer behaviour so it will only be triggered on timer and set the timer to a random number as well..
Change the boolean on timer could also work..

So many ways to do one thing, that might be what's confusing you about the manual, it doesn't tell you what to do, only what you can do..



What i got out from the manual was how you could make something spawn at random locations sine it showed a event from that. So i got help whit that. But i also want to know hoe to make a enemy do a movement or spawn something at random I still want to know two things about that.I used the Timer behavior like this. On start of layout Start Timer1 for 1.0 (Regular). On Compare values i have written "(random)" as a frst value and "(triggerchance)" as the second value. I need paranthesis. It doesn't work for me otherwise. If i just write (random) the expression complains on the lack of paranthesis. Then i made the compare values happen on time. This makes the sprite do the event exactly every second instead of at random like it should so the way i made the timer didn't work. How do you make a expression whitout a variable? You said i shouldn't have a variable for the random expression. Should i go into system, the sprite or what? Second i still want to know if i should make a single event whit random expression or just compare two values or both. If i should both, should the random event happen after the random expression or after the value comparing? I hope i am clear whit what i am asking.
B
11
S
2
Posts: 262
Reputation: 1,309

Post » Thu Sep 17, 2015 3:03 pm

The Manual has never or will never help me. It's something whit how it's written whit not including all the fact you need and being confusing. If i couldn't understand the manual better i would ask alot less in these forums. I like tutorials though. I want to try the Boolean thing. I made a Boolean and set it to false. Shall i set it to true after the event has happened or what.[/quote]

Why not?
You could even add the timer behaviour so it will only be triggered on timer and set the timer to a random number as well..
Change the boolean on timer could also work..

So many ways to do one thing, that might be what's confusing you about the manual, it doesn't tell you what to do, only what you can do..[/quote]


What i got out from the manual was how you could make something spawn at random locations sine it showed a event from that. So i got help whit that. But i also want to know hoe to make a enemy do a movement or spawn something at random I still want to know two things about that.I used the Timer behavior like this. On start of layout Start Timer1 for 1.0 (Regular). On Compare values i have written "(random)" as a frst value and "(triggerchance)" as the second value. I need paranthesis. It doesn't work for me otherwise. If i just write (random) the expression complains on the lack of paranthesis. Then i made the compare values happen on time. This makes the sprite do the event exactly every second instead of at random like it should so the way i made the timer didn't work. How do you make a expression whitout a variable? You said i shouldn't have a variable for the random expression. Should i go into system, the sprite or what? Second i still want to know if i should make a single event whit random expression or just compare two values or both. If i should both, should the random event happen after the random expression or after the value comparing? I hope i am clear whit what i am asking.[/quote]


Can anyone answer on this question. Please?
B
11
S
2
Posts: 262
Reputation: 1,309

Post » Thu Sep 17, 2015 3:16 pm

Without seeing your capx and/or eventsheet it is very unclear what you want..

If you are comparing if "(random)" is the same as "(triggerchance)" it will never be true, for the string (random) and the string (triggerchance) are not the same..
What I'm trying to say is that instead of values you are comparing strings (texts), which doesn't seem to be what you want..

What your event-sheet should look like if you are following the example provided on the last page:

Image

("Is equal to" should offcourse be replaced by "less or equal")
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Sep 17, 2015 7:27 pm

LittleStain wrote:Without seeing your capx and/or eventsheet it is very unclear what you want..

If you are comparing if "(random)" is the same as "(triggerchance)" it will never be true, for the string (random) and the string (triggerchance) are not the same..
What I'm trying to say is that instead of values you are comparing strings (texts), which doesn't seem to be what you want..

What your event-sheet should look like if you are following the example provided on the last page:

Image

("Is equal to" should offcourse be replaced by "less or equal")



I wrote it like this and the enemy doesn't do anything.

http://postimg.org/image/8mra79th7/

I don't know how you compare a text. Should i make a text? Even if i make a text it still needs a instance variable to compare. So i made a instance variable triggerchance and set in the number 30. Does that also work?
B
11
S
2
Posts: 262
Reputation: 1,309

Post » Thu Sep 17, 2015 8:14 pm

Why do you want to compare text?
when you use the " " around something it's a text/string..

Why not make it like the way I showed?
There is no need for the sprite71 within the comparison, I'm not sure what you expect it to do there, but this sure isn't the way..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Sep 17, 2015 8:33 pm

@Calfuso as I see you have a serious problem with the very basic thing. Even if we manage to understand what exactly do you need and give you the exact solution, it won't be a real help in your case.

You need to go several steps back. Try to read/learn about what variables, strings, integers, comparisons are. Not only from Scirra forum but in general. Maybe try to read some tutorial of basics of programming. Pick any common language like PHP or C. Just to understand the basics. It would make many things clear for you.
ImageImage
B
27
S
16
G
68
Posts: 934
Reputation: 38,577

Post » Thu Sep 17, 2015 9:37 pm

LittleStain wrote:Why do you want to compare text?
when you use the " " around something it's a text/string..

Why not make it like the way I showed?
There is no need for the sprite71 within the comparison, I'm not sure what you expect it to do there, but this sure isn't the way..



Okay this has become too difficult for me to understand by written help. What i need is a capx whit a sprite spawning something at random. Like that conveyer belt capx. That was verye helpful. That,s the only solution i can see whit my current skills. So now it,s about capx sharing or nothing.
B
11
S
2
Posts: 262
Reputation: 1,309

Post » Thu Sep 17, 2015 9:58 pm

Calfuso wrote:
LittleStain wrote:Why do you want to compare text?
when you use the " " around something it's a text/string..

Why not make it like the way I showed?
There is no need for the sprite71 within the comparison, I'm not sure what you expect it to do there, but this sure isn't the way..



Okay this has become too difficult for me to understand by written help. What i need is a capx whit a sprite spawning something at random. Like that conveyer belt capx. That was verye helpful. That,s the only solution i can see whit my current skills. So now it,s about capx sharing or nothing.


Ok.. I hope someone finds the time to create a capx for you..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Sep 17, 2015 10:14 pm

LittleStain wrote:
Calfuso wrote:
LittleStain wrote:Why do you want to compare text?
when you use the " " around something it's a text/string..

Why not make it like the way I showed?
There is no need for the sprite71 within the comparison, I'm not sure what you expect it to do there, but this sure isn't the way..



Okay this has become too difficult for me to understand by written help. What i need is a capx whit a sprite spawning something at random. Like that conveyer belt capx. That was verye helpful. That,s the only solution i can see whit my current skills. So now it,s about capx sharing or nothing.


Ok.. I hope someone finds the time to create a capx for you..



Why not you? You had time to made the conveyer belt capx. It,s just a matter of making one or two events . I don't need it now but atleast in tomorrow.
B
11
S
2
Posts: 262
Reputation: 1,309

Post » Fri Sep 18, 2015 8:53 am

Why not me?
It might look like I have no other life than to serve you, but actually I do..
I might have been a bit more eager to help you if you said "thank you" once in a while and asked "could you please" instead of demanding someone to do things for you..
I feel my free time is better spend doing things for me or helping people who actually show appreciation..

Good luck on your project!
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: wizdigitech, Zamargo and 14 guests