16
Ask a Question / Re: Pick random scene
« on: January 12, 2015, 08:13:54 am »
ill just wait the reply on my thread
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Yes, we noticed.
We don't mind helping new people, but to be honest, you are very annoying when it comes to spamming. And in such cases I rather want to spend my time on people who wait their turn and don't open multiple threads.
Luckily almost a year later, I have found a much more easy way of doing this =)
Create a GameAttribute list, and add all names of your scenes to it.
Store the value of a random generated number between 0 and length of the list -1 in a number attribute, then store the value of a random index number between 0 and length of list -1 in a text attribute, remove the item from the list using the number attribute, and switch to a scene with the name of your text attribute =)
what if i i want to remove the scene that is already answered??
what should i do?
It would be courteous to let others know that you already have a thread running on this topic. Sdieters has taken the time to answer your question, but the same answer has already been provided for you in the other thread.
sir i think the reply of sdieters is better........
Luckily almost a year later, I have found a much more easy way of doing this =)
Create a GameAttribute list, and add all names of your scenes to it.
Store the value of a random generated number between 0 and length of the list -1 in a number attribute, then store the value of a random index number between 0 and length of list -1 in a text attribute, remove the item from the list using the number attribute, and switch to a scene with the name of your text attribute =)
it's easy.
only problem is you need to specify every scene since you cant call a scene by simply using its name.
what you have to create is a behaviour as such:
lets say you have 5 scenes you want to pick from.
randomNumber << is a number attribute
when the mous (is released) on (self) << you can also place this on a scene behaviour, using the playbutton actor instead of (self).
set (randomNumber) pick a random number between 0 and 4 << giving 5 different options, since 0 is also an option.
IF randomnumber = 0,
*switch to level 1 using fading or not*
OTHERWISE IF = 1,
*switch to level 2 using fading or not*
OTHERWISE IF = 2,
*switch to level 3 using fading or not*
...(repeat this as many times as needed)
When you no longer want the scene to be available, that's when you can remove the scene number from the list.
For example, if the player answers a question correctly, the scene will no longer be needed, so remove the scene number from the list.
Sorry, I'm not going to write the code for you!
Work through the process...
Make a list attribute of numbers 1 to 5 and randomly select an item from that list. Delete that item from the list if it is no longer needed
If you only want each scene to be visited once, then you can keep a record of scenes already visited, for example, in a Game Attribute list.
When a scene number is no longer required (i.e. the question is answered correctly), add it to the list and check the list when randomly selecting the next scene number. If that number is in the list, then reselect a random number...
Or...
Create a randomly ordered list of the numbers 1 to 5 and select the first item in the list as the first scene number. If that question is answered correctly, then delete the first item from the list.
There are quite a few ways to achieve the same result. The best way to solve a problem like this is to think how you would solve the same problem by hand on a piece of paper, then translate your solution into a computer program. If you do this often enough, you will be able to solve problems like this in your head.
Name your scenes Level1, Level2...Level5
Switch to scene named 'Level' + random number between 1 and 5 as text.
Or just name your scenes 1,2,3,4,5 to make it easier.
Name your scenes Level1, Level2...Level5
Switch to scene named 'Level' + random number between 1 and 5 as text.
Or just name your scenes 1,2,3,4,5 to make it easier.
Name your scenes Level1, Level2...Level5
Switch to scene named 'Level' + random number between 1 and 5 as text.
Or just name your scenes 1,2,3,4,5 to make it easier.