jeudi 12 octobre 2017

How do I select a random array, and then a random index inside THAT array?

;Sayings
friendly := ["hello there!", "Howdy!", "Greetings friend!", "hi there"]
helpful := ["x next to y and z", "this is helpful", "The sky is blue"]
other := ["where is my toaster", "do it", "just"]

;Categories
welcome := [[friendly][helpful][other]]

Numpad0::
    intotext(randomfromarray("friendly"),50,35,15)
    return

Numpad1::
    intotext(randomfromarray("helpful"),50,35,15)
    return

;Numpad2::
    ;Select a random saying from the welcome category.

intotext(whatisit,thekeydelay,introwait,outrowait)
{
    SetKeyDelay, thekeydelay
    Send, t
    Sleep, %introwait%  
    Send, %whatisit% 
    Sleep, %outrowait%
    Send, {enter}
}

randomfromarray(uniquepickof){
    return %uniquepickof%[random(1, %uniquepickof%.maxindex() )]
}

random(x, y){
   Random, var, %x%, %y%
   return var
}

  1. Can someone help me figure out (for Numpad2::) how to select a random Sayings array from the Welcome category, and then select a random index of that (saying) array?

I tried throwing a few ideas down but they all resulted with only "t" because I did not return the (pick random array )[index] value properly.




Aucun commentaire:

Enregistrer un commentaire