Alice Community  

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

Reply
 
Thread Tools Display Modes
Timers
Old
SirThorfinn
Senior Member
 
SirThorfinn's Avatar
 
Status: Offline
Posts: 232
Join Date: Sep 2010
Location: Some where Unreal!
Lightbulb Timers - 12-13-2010, 09:07 PM

Ok, i want to make a timer for my game that counts down from a certain amount of time like 5 min. So how do i set a # variable as a string so that it can be translated into some type of text on screen so the player know how much time is left?
I relatively familiar with how Alice works but i've never thought about this so any help is appreciated .
Thanks


/|..__________________/\_
/ `---___________----_____|]-------<BLAM>------>
/_==o;;;;;;;;_______.:/
), ---.(_(__) /
// (..) ), ----"
//___//
//___//

<Youtube Page> (Not much there but maybe something you'll like) http://www.youtube.com/user/SirThorfinn?feature=mhum
<Xbox Live Gamertag> SirThorfinn

-----Friend of Thor-------------------------------------------
-----Spartans NEVER Die------------------------------------
All most anything on SirThorfinn is me... Almost.
   
Reply With Quote
Old
SirThorfinn
Senior Member
 
SirThorfinn's Avatar
 
Status: Offline
Posts: 232
Join Date: Sep 2010
Location: Some where Unreal!
Default 12-14-2010, 02:07 PM

Please?


/|..__________________/\_
/ `---___________----_____|]-------<BLAM>------>
/_==o;;;;;;;;_______.:/
), ---.(_(__) /
// (..) ), ----"
//___//
//___//

<Youtube Page> (Not much there but maybe something you'll like) http://www.youtube.com/user/SirThorfinn?feature=mhum
<Xbox Live Gamertag> SirThorfinn

-----Friend of Thor-------------------------------------------
-----Spartans NEVER Die------------------------------------
All most anything on SirThorfinn is me... Almost.
   
Reply With Quote
Old
haven812
Guest
 
Status:
Posts: n/a
Thumbs up 12-14-2010, 02:30 PM

The easiest way to do this is to create some 3D text. Then, in the texts properties, drag its property titled "text" into the method editor. For now select default string as the value. Now you drag the "what as a string" function that is under the world to the place holder you just put in. You now can drag the variable that represents the time you want to display into the what to string part. See example...

Note* I'm not sure what you can do about the .0 bit at the end
Attached Files
File Type: a2w time.a2w (167.4 KB, 25 views)
   
Reply With Quote
Old
SirThorfinn
Senior Member
 
SirThorfinn's Avatar
 
Status: Offline
Posts: 232
Join Date: Sep 2010
Location: Some where Unreal!
Default 12-14-2010, 02:40 PM

ok thanks, i don't think i ever noticed that function, lol


/|..__________________/\_
/ `---___________----_____|]-------<BLAM>------>
/_==o;;;;;;;;_______.:/
), ---.(_(__) /
// (..) ), ----"
//___//
//___//

<Youtube Page> (Not much there but maybe something you'll like) http://www.youtube.com/user/SirThorfinn?feature=mhum
<Xbox Live Gamertag> SirThorfinn

-----Friend of Thor-------------------------------------------
-----Spartans NEVER Die------------------------------------
All most anything on SirThorfinn is me... Almost.
   
Reply With Quote
Old
SirThorfinn
Senior Member
 
SirThorfinn's Avatar
 
Status: Offline
Posts: 232
Join Date: Sep 2010
Location: Some where Unreal!
Default 12-14-2010, 02:44 PM

i solved the .99999... thing here-
yeah!.JPG
This didnt put the .999 thing.


/|..__________________/\_
/ `---___________----_____|]-------<BLAM>------>
/_==o;;;;;;;;_______.:/
), ---.(_(__) /
// (..) ), ----"
//___//
//___//

<Youtube Page> (Not much there but maybe something you'll like) http://www.youtube.com/user/SirThorfinn?feature=mhum
<Xbox Live Gamertag> SirThorfinn

-----Friend of Thor-------------------------------------------
-----Spartans NEVER Die------------------------------------
All most anything on SirThorfinn is me... Almost.
   
Reply With Quote
Old
haven812
Guest
 
Status:
Posts: n/a
Smile 12-14-2010, 03:17 PM

I'm not sure what .9999 thing you are talking about. I was referring to the .0 that Alice puts on the ends of whole numbers when you convert them to string. I do, however, think I have come up with a possible fix...

This does involve the use of scripting in Alice, but it is relatively simple.
In the world.script, insert the following code
Code:
def removeDecimal(string):
    world.string = string[0:(len(string)-2)]
this stores the string without the .0 in the world.string variable (hint hint, create this beforehand). You then just set the text property to the world.string.
The code in Alice should look like this
pic.jpg
note the script box placed in the method editor.
*NOTE- if the number does not have .0 on it, this code will just remove the last two numbers so beware.
There may also probably an easier way of doing the exact same thing, but Alice didn't like directly changing the text's text through scripting, so I made a bit of a detour
Attached Files
File Type: a2w time.a2w (175.1 KB, 7 views)
   
Reply With Quote
But
Old
MrMoke
Senior Member
 
MrMoke's Avatar
 
Status: Offline
Posts: 501
Join Date: Sep 2007
Location: Austin, Texas
Default But - 12-14-2010, 07:21 PM

This works too. Set the start value to anything, modify the set text to 0 sec. duration, the decimal digits are removed, and the loop should run 1 sec. per pass.
Attached Images
File Type: jpg Noname.jpg (15.8 KB, 56 views)

Last edited by MrMoke; 12-16-2010 at 09:10 AM.
   
Reply With Quote
Old
David B
Senior Member
 
David B's Avatar
 
Status: Offline
Posts: 1,145
Join Date: Dec 2010
Location: N/A
Default 12-14-2010, 07:47 PM

I made this timer a while ago just for fun because I was bored. It counts down from 1 min. (60 sec.)
Attached Files
File Type: a2w Timer.a2w (244.9 KB, 16 views)
   
Reply With Quote
Old
David B
Senior Member
 
David B's Avatar
 
Status: Offline
Posts: 1,145
Join Date: Dec 2010
Location: N/A
Default 12-14-2010, 08:01 PM

Quote:
Originally Posted by haven812 View Post
The easiest way to do this is to create some 3D text. Then, in the texts properties, drag its property titled "text" into the method editor. For now select default string as the value. Now you drag the "what as a string" function that is under the world to the place holder you just put in. You now can drag the variable that represents the time you want to display into the what to string part. See example...

Note* I'm not sure what you can do about the .0 bit at the end
You only created one 3D text (I created 60). I thought that was cool.

Your Timer Code:


My Timer Code:


Take A Look At My Timer (It has 60 pieces of 3D text in it) by clicking here.
Attached Images
File Type: jpg yt.jpg (23.0 KB, 60 views)
File Type: jpg mc.jpg (25.8 KB, 59 views)
Attached Files
File Type: a2w Timer.a2w (244.9 KB, 10 views)
   
Reply With Quote
Old
haven812
Guest
 
Status:
Posts: n/a
Default 12-14-2010, 08:29 PM

that probably took a little more time...
   
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 ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.