Results 1 to 8 of 8

Thread: Use an array value to generate a random number

  1. #1
    Join Date
    Oct 2006
    Posts
    412
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Use an array value to generate a random number

    This is part of my code so far, it compiles but everytime it doesn't run for a full for loop.

    PHP Code:
    program designCharacter;
    {.include 
    srl/srl.scar}

    var   
    i,a,iMaxInteger;
          
    ycInteger;

    var 
    lookMax: array [0..11of Integer;

    procedure setlookMax;
    begin
    lookMax
    [0]:=8
    lookMax
    [1]:=7
    lookMax
    [2]:=7
    lookMax
    [3]:=5
    lookMax
    [4]:=2
    lookMax
    [5]:=4
    lookMax
    [6]:=2
    lookMax
    [7]:=11
    lookMax
    [8]:=15
    lookMax
    [9]:=15
    lookMax
    [10]:=5
    lookMax
    [11]:=8
    end
    ;

    procedure makeCharacter;
    begin
    setlookMax
    ;
    yc:=90
    for a:=0 to 6 do //Only runs 4 times
        
    begin
        iMax
    :=Random(lookMax[a])
        for 
    i:= 0 to iMax do
            
    begin
            Mouse
    (165,yc,2,2,true)
            
    Wait (50 Random (250));
            
    end;
        
    a:=a+1
        yc
    :=yc+35
        Wait 
    (25 Random (50));
        
    end;
        
    Wait (50 Random (250));
    end;

    procedure colorCharacter;
    begin
    setlookMax
    ;
    yc:=95
    for a:=7 to 11 do //Only runs 3 times
        
    begin
        iMax
    :=Random(lookMax[a])
        for 
    i:= 0 to iMax do
            
    begin
            Mouse
    (467,yc,2,2,true)
            
    Wait (50 Random (250));
            
    end;
        
    a:=a+1
        yc
    :=yc+35
        end
    ;
        
    Wait (50 Random (250));
    end;

    procedure designCharacter;
    begin
    makeCharacter
    ;
    colorCharacter;
    //Mouse(260,280,5,5,true) clicks accept
    //Wait(1000+Random(500))
    end;

    begin
    designCharacter
    End

    Your welccome to run it on a new account. It randomly generates your character's looks as part of my upcomming 'create your army' script.

    with the character design screen up, locate the rs window, and click play.

  2. #2
    Join Date
    Sep 2006
    Posts
    161
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Why not just have them all click random(25) times or something, because the character trait selection wraps around?

    As for the loops, why not change them to while loops?

    Oh, and more importantly for you,
    for loops automatically increment, and if you call a:=a+1 then you're incrementing again, and it's really incrementing twice a run.


    Wow. I've been away quite a while. Real life, yea, way unpredictable. Sorry, y'all, if I've caused any inconvenience.

  3. #3
    Join Date
    Oct 2006
    Posts
    412
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    YAY! Thank you I Pick Axes! I didn't know that for loops auto increment. Deleting the a:=a+1 made it work flawlessly with the current setup. I just tested it with a while loop, and it works the same. Ill stick with the for loop for now, but may change it in the final setup. I used an array because my original one was 185 lines because I did each character attribute in its own procedure. Im using the constants of the array instead of Random(#) just so its more organized I suppose, and saves time. Imagine having it get 24 on Random(25) for the feet attribute. Alot of wasted clicks.

    It works now, and Im happy nontheless. Thank you

    OH and what is that mouse function that move the mouse instead of instantly placing it at x,y? not movemousesmoth, but the better srl one?

  4. #4
    Join Date
    Sep 2006
    Posts
    161
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Mouse handles spline movement and randomized click. MMouse is for moving but not clicking.


    Wow. I've been away quite a while. Real life, yea, way unpredictable. Sorry, y'all, if I've caused any inconvenience.

  5. #5
    Join Date
    Sep 2006
    Location
    Scripter's Heaven
    Posts
    455
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    hmm... we may be building competing scripts, mine also makes the characters, but benmouse commits suicide when i try to find a color and move there!

  6. #6
    Join Date
    Oct 2006
    Posts
    412
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I have actually put the script on hold because i read somewhere that a srl scripter is soon to be launching his version of a tut runner. most likely sooner than i can have mine completed. im only at the bread baking stage .

  7. #7
    Join Date
    Oct 2006
    Posts
    119
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by IronTeapot View Post
    I have actually put the script on hold because i read somewhere that a srl scripter is soon to be launching his version of a tut runner. most likely sooner than i can have mine completed. im only at the bread baking stage .
    Keep it going man, thats how you learn new stuff. And who's to say your script won't be better?

  8. #8
    Join Date
    Oct 2006
    Posts
    412
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Humm, your right. I guess ill just keep going. Never hurts to have multiple versions of one script. Matbe it will get me a membership status

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Choosing random element from array
    By Repentinus in forum C/C++ Help and Tutorials
    Replies: 5
    Last Post: 12-24-2007, 11:11 PM
  2. random number 28+
    By ShowerThoughts in forum OSR Help
    Replies: 6
    Last Post: 10-13-2007, 03:40 PM
  3. Random Number of Clicks?
    By Bourdou! in forum OSR Help
    Replies: 5
    Last Post: 08-12-2007, 05:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •