randomize a scene

krazziebone02

  • Posts: 113
sir i want to know how to randomize 5 scenes for example i have a button that switch the scene to proceed on the scene that i have a certain question.............now i want to do is when i click the button it should randomize a scene before it switch sir please help
i want to be the best user of stencyl

Innes

  • *
  • Posts: 1960
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.
Visit www.TheStencylBook.com - the only published book for learning Stencyl.

krazziebone02

  • Posts: 113
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.

sir i cant put the random number  inside the block of scene with name
i want to be the best user of stencyl

krazziebone02

  • Posts: 113
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.

sir thanks it work im sorry i thought i will put + sign and i try to put & sign and it works thank you so much sir
i want to be the best user of stencyl

krazziebone02

  • Posts: 113
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.

sir i already do what you said but i want to happen is when the question that already answered will not included when the question was  randomed??
i want to be the best user of stencyl

Innes

  • *
  • Posts: 1960
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.
Visit www.TheStencylBook.com - the only published book for learning Stencyl.

krazziebone02

  • Posts: 113
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.

sir can you give the block codes? i cant understand you reply sir if okay sir??
i want to be the best user of stencyl

Innes

  • *
  • Posts: 1960
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
Visit www.TheStencylBook.com - the only published book for learning Stencyl.

Alexin

  • *
  • Posts: 3127
Too bad you didn't enroll in Innes' Udemy course for a symbolic $10.

« Last Edit: January 11, 2015, 07:36:21 am by Alexin »
"Find the fun"
alexin@stencyl.com

Innes

  • *
  • Posts: 1960
Too bad you didn't enrolled in Innes' Udemy course for a symbolic $10.

I'll take that as a compliment!  :D

As it happens, I extended the offer until Monday 12th January 2015 ... http://community.stencyl.com/index.php/topic,37794.msg213481.html#msg213481
Visit www.TheStencylBook.com - the only published book for learning Stencyl.

krazziebone02

  • Posts: 113
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

sir is my code correct?? where will i put the remove item?? in the scene that will pick first in random/??? here my code sir

i want to be the best user of stencyl

krazziebone02

  • Posts: 113
i already do the randoming scene but the problem the scene that i already answered is joined in random again iplease help help
i want to be the best user of stencyl

Innes

  • *
  • Posts: 1960
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.
Visit www.TheStencylBook.com - the only published book for learning Stencyl.

krazziebone02

  • Posts: 113
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.

ahhhmmmm i have a codes like this sir

this is my code for level 1

when the mouse was released "the correct answer"
then switch to scene with name: get item # random 1 and 2 from randomquestions
removed item # 0

this is my code for level 2

when the mouse was released "the correct answer"
then switch to scene with name: get item # random 0 and 1 from randomquestions
removed item # 1

this is my code for level 3

when the mouse was released "the correct answer"
then switch to scene with name: get item # random 0 and 1 from randomquestions
removed item # 2

but i get error sir what is the problem with my code sir
i want to be the best user of stencyl

Innes

  • *
  • Posts: 1960
It's difficult to say what the problem is when you are not showing the actual code.

One thing I can see is that you are removing the item from the list after the scene switch block. Is the remove code definitely being executed?


Also having having special events for each scene is risky as there is a lot of room for error. It would be better to create a generic behavior that handles all cases.
Visit www.TheStencylBook.com - the only published book for learning Stencyl.