Optimizing varibles and random numbers Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Kade F

Optimizing varibles and random numbers  Topic is solved

21 Sep 2018, 06:00

I'm writing a script with a lot of random numbers for click offsets. Currently I have to assign a list of randoms from 1-30

Code: Select all

function(){
Random, rand1, -2,2
Random, rand2, -2,2 
Random, rand3, -2,2 
Random, rand4, -2,2 
Random, rand5, -2,2 
Random, rand6, -2,2 
Random, rand7, -2,2 
Random, rand8, -2,2 
Random, rand9, -2,2 
Random, rand10, -2,2 
Random, rand11, -2,2 
Random, rand12, -2,2 
Random, rand13, -2,2 
Random, rand14, -2,2 
Random, rand15, -2,2 
Random, rand16, -2,2 
Random, rand17, -2,2 
Random, rand18, -2,2 
Random, rand19, -2,2 
Random, rand20, -2,2 
Random, rand21, -2,2 
Random, rand22, -2,2 
Random, rand23, -2,2 
Random, rand24, -2,2 
Random, rand25, -2,2 
Random, rand26, -2,2 
Random, rand27, -2,2 
Random, rand28, -2,2 
Random, rand29, -2,2 
Random, rand30, -2,2 
random,time1,10,90
random,time2,10,90
random,time3,10,90
random,time4,10,90

global firstposX = (fx+(rand1+rand2))
global firstposY =	(fy+(rand3+rand4))
global secondposX = ((fx+40)+(rand5+rand6))
global secondposY =	(fy+(rand7+rand8))
global thirdposX = (fx+(rand9+rand10))
global thirdposY =	((fy+40)+(rand11+rand12))
global fourthposX = ((fx+40)+(rand13+rand14))
global fourthposY =	((fy+40)+(rand15+rand16))
global fifthposX = ((fx+80)+(rand13+rand14))
global fifthposY =	((fy)+(rand15+rand16))
global sixposX = ((fx+80)+(rand13+rand14))
global sixposY =  ((fy+40)+(rand15+rand16))
global sevenposX = ((fx+122)+(rand13+rand14))
global sevenposY =  ((fy)+(rand15+rand16))
global eightposX = ((fx+122)+(rand13+rand14))
global eightposY =  ((fy+40)+(rand15+rand16))
global niposX = ((fx)+(rand13+rand14))
global niposY =  ((fy+80)+(rand15+rand16))
}
I'm looking for a better way to write this. I'm running into a wall finding a way to compress this part of my script.
Is there an easier way to use multiple randoms than this?
I currently use huge random number blocks like this inside multiple functions so the numbers re roll every time I call the hotkey
User avatar
tomoe_uehara
Posts: 213
Joined: 05 Oct 2013, 12:37
Contact:

Re: Optimizing varibles and random numbers

21 Sep 2018, 06:12

Code: Select all

Loop, 5 {
	Random, rand%A_Index%, -2,2
}
MsgBox %rand1%`n%rand2%`n%rand3%`n%rand4%`n%rand5%
ExitApp
Spoiler

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Lamron750 and 356 guests