Alice Community  

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

Reply
 
Thread Tools Display Modes
Random Number post to 3-d Text
Old
ljb716
Guest
 
Status:
Posts: n/a
Default Random Number post to 3-d Text - 04-20-2010, 02:36 PM

I am making a dice game, and I want to randomize two different numbers. I got that part, but I can't figure out how to then make the random number = to the 3-d text so that it will post onto the square dice I made.

Does anyone know how to do this? Or is there another way besides the 3-d text to put a label out on the screen?
   
Reply With Quote
Old
bjia56
Guest
 
Status:
Posts: n/a
Default 04-20-2010, 04:32 PM

You could always use the "print" method to print text, but it isn't in the world (it's in a boring little text box that appears below the play screen when text is printed).

Also, you can do:

<insert text object name here> set text to (<insert variable name here> as a string)>

Unfortunately, the number retains the decimal point after conversion to string. I have no idea how to make it not include the decimal.

Hope that helped! If it didn't, please say so.
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 978
Join Date: Sep 2009
Location: United States
Default 04-20-2010, 09:20 PM

In case you didn't understand, you set the text of the 3-D Text in the method you want, and then where you are supposed to input the text, you put in a block from the Properties tab of world called "[what] as a string". You then put in the variable you want for the [what].

There is a way to get rid of the decimal that comes up, so if u want to know just ask and I will tell you, but i see no point in explaining the creation of the method if you don't really care.


Check out my best projects so far and please comment:

Tic-Tac-Toe 2.0 ................... http://www.alice.org/community/showthread.php?t=3548
Alice Paint ........................... http://www.alice.org/community/showthread.php?p=23408
Real-Time Clock .................. http://www.alice.org/community/showthread.php?p=12725
Maze Game ......................... http://www.alice.org/community/showthread.php?t=4301
   
Reply With Quote
Old
flats
Guest
 
Status:
Posts: n/a
Default 04-23-2010, 08:45 AM

Quote:
Originally Posted by Dameria View Post
There is a way to get rid of the decimal that comes up, so if u want to know just ask and I will tell you, but i see no point in explaining the creation of the method if you don't really care.
Do you have a better way than using random number (java: randomNextDouble)?

Last edited by flats; 04-23-2010 at 08:48 AM. Reason: alice mode
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 978
Join Date: Sep 2009
Location: United States
Default 04-23-2010, 09:20 AM

Nope, random number is the way that I was talking about. I used it in the maze game for another person, you can look for that if you want.


Check out my best projects so far and please comment:

Tic-Tac-Toe 2.0 ................... http://www.alice.org/community/showthread.php?t=3548
Alice Paint ........................... http://www.alice.org/community/showthread.php?p=23408
Real-Time Clock .................. http://www.alice.org/community/showthread.php?p=12725
Maze Game ......................... http://www.alice.org/community/showthread.php?t=4301
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 04-23-2010, 12:31 PM

Quote:
Originally Posted by Dameria View Post
Nope, random number is the way that I was talking about. I used it in the maze game for another person, you can look for that if you want.
My problem is that it seems to be a glitch, as it doesn't work for me and my copy of Alice is pretty stable.


(')>
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 978
Join Date: Sep 2009
Location: United States
Default 04-23-2010, 12:35 PM

Did you see how I did it using the maze? Did it not work for you there?


Check out my best projects so far and please comment:

Tic-Tac-Toe 2.0 ................... http://www.alice.org/community/showthread.php?t=3548
Alice Paint ........................... http://www.alice.org/community/showthread.php?p=23408
Real-Time Clock .................. http://www.alice.org/community/showthread.php?p=12725
Maze Game ......................... http://www.alice.org/community/showthread.php?t=4301
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 04-23-2010, 12:39 PM

Not even sorta. I knew it wouldn't, though.

It's stuff like that that makes me wish I was better at editing complex raw code, so I could just go in, make a few tweaks, and have it change from doubles to integers (it's not a difficult thing, really).


(')>
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 978
Join Date: Sep 2009
Location: United States
Default 04-23-2010, 02:41 PM

So random numbers don't work at all for you? Maybe its just your version then.


Check out my best projects so far and please comment:

Tic-Tac-Toe 2.0 ................... http://www.alice.org/community/showthread.php?t=3548
Alice Paint ........................... http://www.alice.org/community/showthread.php?p=23408
Real-Time Clock .................. http://www.alice.org/community/showthread.php?p=12725
Maze Game ......................... http://www.alice.org/community/showthread.php?t=4301
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 04-23-2010, 05:50 PM

No, random numbers work, but the decimal cutting method you used doesn't.

If random numbers didn't work for me, I wouldn't have been able to make RP.


(')>
   
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 ©2017, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.