You can send local values to a function with the paremeters.
local function rollCompare(i,j)
return rollTable[i] < rollTable[j];
end
In the above example, i and j are send to the function: local val = rollCompare(3,5) is the same as:
i=3
j=5
local val = rollCompare() with the example below
local function rollCompare()
return rollTable[i] < rollTable[j];
end
It's a lot tidier to keep stuff in parameters. They're local and put on the stack so won't create garbage to collect.
|