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, 10: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, 03: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, 03: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, 03: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, 03: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, 04: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
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, 09:56 PM

Quote:
Originally Posted by SirThorfinn View Post
i solved the .99999... thing here-
Attachment 4027
This didnt put the .999 thing.
Can you upload it?
   
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, 09: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, 09:29 PM

that probably took a little more time...
   
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, 09:48 PM

Quote:
Originally Posted by David B View Post
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.
Quote:
Originally Posted by haven812 View Post
that probably took a little more time...
Yes it did. I spent more time adding the text than I did programming it.
   
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 ©2021, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.