Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to perform temporary arithmetic on a table?

Asked by
RoboFrog 400 Moderation Voter
9 years ago

I've posted a similar question before, but it was lengthy and intimidating. So, I've gotten rid of that one and now have a more refined question.

I'm currently trying to iterate through a table, and check if the supplied number to a function is within 6 integers of any numbers inside of a table. However, it won't let me "perform arithmetic" on the table since it thinks I'm attempting to change its values.

This is my code so far --

local mdist = 8;

local Coordsx = {
    107;
}

function xcheck(xrand) -- random number supplied by another function
    for index, value in pairs(Coordsx) do
        if value + mdist <= xrand + mdist or value - mdist >= xrand - mdist then
            wait();
        else
            return false;
        end
    end
end

I've tried things like "local valuecalc = value;" then using valuecalc in place of value, but it's still apparently linked directly to value and not just what it equals.

I also don't want mdist to permanently change (which I don't think it is by tracking it in the output). The issue still lies in the fact that it won't let me even "test" if the currently iterated value is within 6.

Any help is greatly appreciated!

Answer this question