Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
If/Else
Old
reddStarr
Guest
 
Status:
Posts: n/a
Question If/Else - 05-04-2009, 06:46 PM

Hi I'm new, and new to storytelling alice but i'm very good at using it....


Umm but I was wandering if anyone could tell me how the if/else part of storytelling alice works. I'm having trouble because I'm trying to make a game but I don't know what to use to make something like:

When this happens
This will happen next

Thank you - reddStarr
   
Reply With Quote
Old
HisWorld
Guest
 
Status:
Posts: n/a
Default 05-04-2009, 09:06 PM

Bascially I think you have the idea of an if-else statement.

It is a conditional statement, just a logical switch.

If "a certain condition is true"

then "a certain event will happen i.e. a variable will change, a method is called"

Else" a different condition will occur, this could be the start of another
if-then else statement"

Ok I tried to include some alice code with color's but because of the forum's file size restriction I could only attach it in a .txt document.
Attached Files
File Type: txt if-else example.txt (931 Bytes, 15 views)

Last edited by HisWorld; 05-04-2009 at 09:34 PM. Reason: trying to attach a file
   
Reply With Quote
Old
reddStarr
Guest
 
Status:
Posts: n/a
Question 05-04-2009, 09:09 PM

What do you mean by test... do you mean trial and error
   
Reply With Quote
Old
HisWorld
Guest
 
Status:
Posts: n/a
Default 05-04-2009, 10:24 PM

I updated my post
   
Reply With Quote
2 possibilities come to mind..
Old
veghead05
Guest
 
Status:
Posts: n/a
Cool 2 possibilities come to mind.. - 05-04-2009, 10:30 PM

The first thing that comes to mind is the If/else, as you said.
You drag the If/else tile (from the bottom) into the method editor. Under the If part is your "when this happens" part, also known as the condition. Think of it as a trigger for something to happen.
The else part can be left blank, if you are only concerned with one thing happening; otherwise, you can put an alternative method--something that happens when your condtion is not met.

As an example, say you want an arrow to explode into confetti if it hits a bullseye. The condition would be, If it hits the bullseye... the instructions for the if would be that it explodes into confetti.
You could leave it at that, leaving the else part blank, or you could add an else statement--such as, if it doesnt hit the bullseye, then the arrow turns gray.
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2019, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.