![]() |
Timers
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?:confused:
I relatively familiar with how Alice works but i've never thought about this so any help is appreciated :D. Thanks |
Please?
|
1 Attachment(s)
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 |
ok thanks, i don't think i ever noticed that function, lol
|
1 Attachment(s)
i solved the .99999... thing here:D-
[ATTACH]4027[/ATTACH] This didnt put the .999 thing. |
2 Attachment(s)
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)][/CODE]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 [ATTACH]4028[/ATTACH] 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 |
But
1 Attachment(s)
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.
|
1 Attachment(s)
I made this timer a while ago just for fun because I was bored. It counts down from 1 min. (60 sec.)
|
3 Attachment(s)
[QUOTE=haven812;29583]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[/QUOTE] You only created one 3D text (I created 60). I thought that was cool. Your Timer Code: [IMG]http://www.alice.org/community/attachment.php?attachmentid=4036&stc=1&d=1292378064[/IMG] My Timer Code: [IMG]http://www.alice.org/community/attachment.php?attachmentid=4037&stc=1&d=1292378250[/IMG] Take A Look At My Timer (It has 60 pieces of 3D text in it) by [URL="http://www.alice.org/community/attachment.php?attachmentid=4038&stc=1&d=1292378391"]clicking here[/URL]. |
that probably took a little more time...
|
All times are GMT -5. The time now is 11:25 PM. |
Copyright ©2022, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.