UOSAGAS Scripting

Lists, Timers & Cooldowns

Razor Script has no arrays or objects. What it has instead are three named, global stores, lists, timers and cooldowns, which cover nearly everything a script actually needs.

Lists

A list is a named bag of values you can loop over. Create it, push into it, walk it with foreach, then throw it away.

createlist 'ore'
pushlist 'ore' 0x19B9
pushlist 'ore' 0x19BA
pushlist! 'ore' 0x19B9     // ! = only if not already in the list
 
foreach id in ore
    @dclicktype id backpack
    wait 500
endfor
 
removelist 'ore'
Do thisWith
How many entries?list 'ore'
Does it exist?listexists 'ore'
Is a value in it?inlist 'ore' 0x19B9
Read position 0atlist 'ore' 0
Take one outpoplist 'ore' 'front'
Empty it, keep itclearlist 'ore'
Delete itremovelist 'ore'

Lists are global and outlive the script. Start with removelist (or clearlist) so a second run does not inherit leftovers from the first.

Filling a list from the world

findtype returns one random match. findtypelist puts every match into a list. That is the difference between looting one coin pile and looting all of them.

loot-all-gold.razor
removelist 'loot'
createlist 'loot'
 
findtypelist 'loot' 0x0EED ground 0 any 3   // gold, any hue, within 3 tiles
 
foreach item in loot
    dclick item
    wait 600
endfor
 
removelist 'loot'

Timers

A timer counts up in milliseconds from the moment you create it. Use one to measure how long since something happened.

createtimer 'trip'
 
while timer 'trip' < 60000      // for one minute
    walk 'North'
    wait 400
endwhile
 
removetimer 'trip'

settimer pre-loads elapsed time, so settimer 'trip' 5000 behaves as if it had started five seconds ago. timerexists tells you whether it was ever created.

Cooldowns

A cooldown counts down. You start it with a duration; the expression tells you how much is left, and reaches 0 when it is done.

cooldown 'bandage' 30000        // milliseconds
 
if cooldown 'bandage' > 2000
    overhead 'not yet'
else
    hotkey 'Bandage self'
    cooldown 'bandage' 30000    // restart it
endif

The duration is in milliseconds. Older scripts that pass seconds keep working: a value under 100 is read as seconds. The on-screen cooldown bar is not implemented yet, but the timer itself works.

Timer or cooldown?

TimerCooldown
DirectionCounts up from 0Counts down to 0
You ask“How long since…?”“How long until…?”
Reads as true whenAny time has passedIt is still running
Good forTiming a run, throttlingGating a repeatable action

Note the flip in meaning: if cooldown 'x' means “still on cooldown, do not act”, while if not cooldown 'x' means “ready”. The same reads naturally for bandaging, which behaves like a cooldown in seconds.

The ignore list

A special built-in list: anything on it becomes invisible to findtype, dclicktype, targettype and friends. It is how you stop a loop from picking the same corpse forever.

while findtype 'corpse' ground as body
    dclick body
    wait 1000
    ignore body            // never look at this one again
endwhile
 
clearignore                // start fresh next run

unignore removes a single entry; clearignore empties the whole thing. Both also accept a list name to work in bulk.