Random numbers?
by Brandon Beauchene · in Technical Issues · 04/06/2006 (9:21 pm) · 9 replies
Ok Im curious. I know I was able to do this a while ago, but have since forgotten how. I need to be able to generate random numbers between 2 given values. like randInt in qbasic :P
I did looking in the 3DGPAI1 book and nothing on random anything, same with resources (as far as I could tell anyway.)
Any help would be appreciated thanks
I did looking in the 3DGPAI1 book and nothing on random anything, same with resources (as far as I could tell anyway.)
Any help would be appreciated thanks
#2
however, now i have another issue. allow me to explain a little how i have this gui set up
i have a gui with many nested guis within it. right now im working on allowing people to enter a username and password to login and when they click ok, the gui object holding the login info is going to be invisible and another screen will become visible this is the button's command
Command = "LoginOK();";
and at the bottom of the gui file i have this :
//--- OBJECT WRITE END ---
function LoginOK()
{
// this is where we would put the code to transmit login data to the server
// and login if correct info. but for now we will move on with character creation.
echo("Login Ok clicked, attempting to disable login and enable stat rolls.");
StatusScreenGui.query.statRolls.setVisible("1");
StatusScreenGui.query.loginScreen.setVisible("0");
canvas.Repaint();
}
yes i know...many nested objects. anyway. when i click ok this shows up in log.
......
Login Ok clicked, attempting to disable login and enable stat rolls.
starter.fps/client/ui/StatusScreen.gui (1058): Unable to find object: '' attempting to call function 'setVisible'
starter.fps/client/ui/StatusScreen.gui (1059): Unable to find object: '' attempting to call function 'setVisible'
......
i have tried setVisible(true);
i have tried StatusScreenGui::query.... etc
im running out of ideas.
and oh ya, the objects im trying to hide stay on screen and the ones im trying to show dont appear.
any help will be GREATLY appreciated ive racked my brain on this for 2 days and i think im missing something simple.
04/14/2006 (12:43 pm)
Well i seem to have overlooked that one :Phowever, now i have another issue. allow me to explain a little how i have this gui set up
i have a gui with many nested guis within it. right now im working on allowing people to enter a username and password to login and when they click ok, the gui object holding the login info is going to be invisible and another screen will become visible this is the button's command
Command = "LoginOK();";
and at the bottom of the gui file i have this :
//--- OBJECT WRITE END ---
function LoginOK()
{
// this is where we would put the code to transmit login data to the server
// and login if correct info. but for now we will move on with character creation.
echo("Login Ok clicked, attempting to disable login and enable stat rolls.");
StatusScreenGui.query.statRolls.setVisible("1");
StatusScreenGui.query.loginScreen.setVisible("0");
canvas.Repaint();
}
yes i know...many nested objects. anyway. when i click ok this shows up in log.
......
Login Ok clicked, attempting to disable login and enable stat rolls.
starter.fps/client/ui/StatusScreen.gui (1058): Unable to find object: '' attempting to call function 'setVisible'
starter.fps/client/ui/StatusScreen.gui (1059): Unable to find object: '' attempting to call function 'setVisible'
......
i have tried setVisible(true);
i have tried StatusScreenGui::query.... etc
im running out of ideas.
and oh ya, the objects im trying to hide stay on screen and the ones im trying to show dont appear.
any help will be GREATLY appreciated ive racked my brain on this for 2 days and i think im missing something simple.
#3
now im trying to remember what the command was to have the engine take the contents of a string
and run it like a command typed into a cs file....cant seem to find it anywhere and having coders block :/
04/14/2006 (7:38 pm)
Nevermind i figured it out :) now im trying to remember what the command was to have the engine take the contents of a string
and run it like a command typed into a cs file....cant seem to find it anywhere and having coders block :/
#4
04/14/2006 (9:00 pm)
Eval() is what you're looking for.
#5
im having difficulty takening a random number $Roll1 and assigning it to $Player.Stats.dexScore
heres the problem, there are 7 random numbers in a group of check boxes where only one can be selected
and another group of 6 stat checkboxes(grouped as another group). when you select a stat and select a roll
then click assign the 2 boxes are disabled (that works) but doing this doesnt work :
eval("$Player.Stats."@%Stat@"Score = $Roll"@%Roll@";");
where $Stat is a 3 letter string of the stat selected (str, int, dex, wis, con, cha) and %Roll is the roll number (1-7) selected. basically eval is getting this -
$Player.Stats.strScore = $Roll1;
if first roll and strBox are checked.
but when i echo back -
echo($Player.Stats.strScore);
I get empty strings. any ideas?
04/15/2006 (9:05 pm)
AHHHH. Thanks a bunch but now eval is giving me hell :Pim having difficulty takening a random number $Roll1 and assigning it to $Player.Stats.dexScore
heres the problem, there are 7 random numbers in a group of check boxes where only one can be selected
and another group of 6 stat checkboxes(grouped as another group). when you select a stat and select a roll
then click assign the 2 boxes are disabled (that works) but doing this doesnt work :
eval("$Player.Stats."@%Stat@"Score = $Roll"@%Roll@";");
where $Stat is a 3 letter string of the stat selected (str, int, dex, wis, con, cha) and %Roll is the roll number (1-7) selected. basically eval is getting this -
$Player.Stats.strScore = $Roll1;
if first roll and strBox are checked.
but when i echo back -
echo($Player.Stats.strScore);
I get empty strings. any ideas?
#6
04/15/2006 (9:32 pm)
WOOT I FIXED IT :) had been doing the $Player = new ScriptObject() part wrong :P thanks for all the help
#7
Isnt there a callback function for GuiTextListCtrl something like onClick() or onSelectChange() or something that is automatically called whenever you select a different row? cant figure it out and nothing in gui forumns or 3dgpai1 book :( help plz thanks
04/16/2006 (6:07 pm)
*sigh* another roadblock.Isnt there a callback function for GuiTextListCtrl something like onClick() or onSelectChange() or something that is automatically called whenever you select a different row? cant figure it out and nothing in gui forumns or 3dgpai1 book :( help plz thanks
#9
04/17/2006 (9:07 am)
Sweet thanks that got it working =D
Torque Owner Roshan Kuriyan
Default Studio Name
u can use this,
getrandom(min_number,max_number);
or getrandom(max_number);
see the appendix section of 3Dgpai1 book.