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

How would I correctly access this table?

Asked by
14jojo -19
2 years ago
FireConfig = { -- i am trying to access the fireconfig table to change the firerate
    FireRate = 360, 
    InternalMag = false, 
    InternalMagSize = 0, 
    CanOneInTheChamber = false, 
    Damage = 17, 
    BurstCount = 3, 
    PelletCount = 1, 
    MuzzleVelocity = 1050, 
    DamageFallOff = {
        StartsAt = 90, 
        LowestAt = 150, 
        FinalMod = 0.2353
    }
}

-- gun mods functions
local function modgun(gun, property, mult)
    if guns.apply_to_all ~= true then
        if gun and property and mult then
            if type(mult) == 'number' then
                guns.data[gun][property] = guns.copydata[gun][property] * mult
            elseif type(mult) == 'boolean' then
                guns.data[gun][property] = mult
            elseif type(mult) == 'string' then
                guns.data[gun][property] = mult
            end
        end
    else
        for i, _ in next, guns.data do
            if guns.data[i][property] then
                if type(mult) == 'number' then
                    guns.data[i][property] = guns.copydata[i][property] * mult
                elseif type(mult) == 'boolean' then
                    guns.data[i][property] = mult
                elseif type(mult) == 'string' then
                    guns.data[i][property] = mult
                end
            end
        end
    end
end


-- how do I call to change the FireRate
modgun(guns.gunname, 'FireRate', (value_firerate)) -- how do I correctly access the fireconfig table which has the value of firerate?
0
I think I'm gonna need a bit more specification RunkerSecurity 6 — 2y
0
So on line 46 I am attempting to change the FireRate however, I can because I am incorrectly calling the FireRate since it's in FireConfigs table using the function I have how would I correctly change the FireRate 14jojo -19 — 2y
0
FireConfig['FireRate'] = insert number here, access the table by simply writing the table, index stuff inside using brackets [ and ], put a string of what you are indexing, in this case you are getting FireRate then use equal to and set to a value. greatneil80 2647 — 2y
0
You could use rawset, idk I'm checking the script its perfectly fine. MiAiHsIs1226 189 — 2y

Answer this question