Random Dialogue/No Repeats

Get help using Construct 2

Post » Thu Dec 26, 2013 11:54 am

I've hit a wall on this. I have random dialogue but atm it repeats. I want to have each line to only fire off once on a play through. I was determined to figure it out myself. I ask for help in IRC and while the advice was sound, I couldn't implement the ideas. I've tried and tried some more. Then I tried more after that. I can't figure it out. I need help.

I'm including the whole .capx (it's a big file because of large images). It's a bit to wade through but the important parts are in the "Globals" event sheet under the "Touch" group. And the "Dialog" sheet. I only worked on the "Yes" option.

https://www.dropbox.com/s/1npeolvwmxuej0l/Sbb2Help02.capx

Any help is appreciated. Thank you.
B
16
S
6
Posts: 33
Reputation: 1,620

Post » Thu Dec 26, 2013 12:12 pm

If you choose to keep doing the dialogue in this manner (which I'm not sure is the greatest way for it) I guess the solution would be to remove the entry after using it, or setting it to 0 in the array. And set the text to the random array value if the array value is not 0 and else repeat the set text to random untill an array value is found that isn't 0.
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 Dec 26, 2013 12:46 pm

That is exactly what I tried to do. I just couldn't figure out how to do it.
B
16
S
6
Posts: 33
Reputation: 1,620

Post » Fri Dec 27, 2013 6:19 am

Keep all dialogues in an array. Install http://www.scirra.com/forum/plugin-pattern-gen-easter-egg_topic59168.html plug in. It creates random number in given range without repeat. And use that as an index to array of dialogues. I did something like what you are trying and this helped me.
B
6
S
2
G
1
Posts: 77
Reputation: 708

Post » Fri Dec 27, 2013 9:22 pm

Thank you, this looks like it might be what I need. Unfortunately, I don't understand how it works. I can't make sense of the example capx. Is there anything you can tell me about how I can use it?
B
16
S
6
Posts: 33
Reputation: 1,620

Post » Sat Dec 28, 2013 12:06 am

I can't figure this out. I can't make shuffle work. I don't know what I'm doing.ghostwheel2013-12-28 00:10:08
B
16
S
6
Posts: 33
Reputation: 1,620

Post » Sat Dec 28, 2013 10:52 am

Can someone please help me?
B
16
S
6
Posts: 33
Reputation: 1,620

Post » Sat Dec 28, 2013 4:59 pm

I cannot download your capx at the moment, but I will try to solve your problem. I will pretend your array is called DialogArray. To get the array to work, I would first set your array to a size of (number of dialogs you want, 2, 1) on the start of the layout. In the first dimension of the array, I will store whether or not this piece of dialog has already been used, and the second dimension will be used for the text itself. Create a global variable called NumberOfDialogsUsed (or whatever you want to call it) and leave it set to 0.

I am assuming you have some variable which stores the location in the array that you want to display, and I will pretend it's called PickedDialog.

When you want to pick a dialog:

If NumberOfDialogsUsed < DialogArray.Width | PickedDialog = floor(random(DialogArray.Width))

       (subevent)
       While
       DialogArray.At(PickedDialog) = 1 | Add 1 to PickedDialog
              
              (subevent)
              If PickedDialog > or = DialogArray.Width | Set PickedDialog = 0

       (subevent)
       (no conditions) | Add 1 to NumberOfDialogsUsed
                        | Set DialogArray.At(PickedDialog) = 1


Now to display your text, you will find it at DialogArray.At(PickedDialog, 1)

In this example, once you used up every dialog, nothing will happen when you want to display text. At this point if you would like to pick from all the dialogs again, you will have to set NumberOfDialogsUsed = 0, and loop through your array and set DialogArray.At(loopindex) = 0sgtwombatstudios2013-12-28 17:07:06
B
10
S
2
G
1
Posts: 64
Reputation: 1,032

Post » Mon Jan 06, 2014 8:08 pm

Thank you for the help. I couldn't make this method work, however I did eventually figure out a way to do what I wanted. :)
B
16
S
6
Posts: 33
Reputation: 1,620

Post » Tue Jan 07, 2014 2:16 am

Threw together a quick example.
We iterate through an array and delete values as they are returned.
https://dl.dropboxusercontent.com/u/139218609/examples/randomnorepeat.capx
If deleting the values isn't a viable option then you might add to the array depth and use it to store whether or not a value on the x axis been accessed.
B
10
S
2
G
1
Posts: 202
Reputation: 1,555

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 1 guest