dvar

Dvar from the game such as cg_draw2D or sensitivity etc. Dvars store their value in a union type. This means its your responsibility to call the correct getX and setX method to read or write data.

Properties

  • name

  • description

Methods

  • getBool

  • getInt

  • getFloat

  • getString

  • setBool

  • setInt

  • setFloat

  • setString

  • restoreDefault

Example:

local function main () 
    local f = engine.getDvar("sensitivity")
    local floatValue = f:getFloat()

    local i = engine.getDvar("cg_chatheight")
    local intValue =  i:getInt()

    local b = engine.getDvar("r_fullbright")
    local boolValue = b:getBool()

    local s = engine.getDvar("name")
    local stringValue = s:getString()

    f:setFloat(1.25) -- 1.25
    i:setInt(8) -- 8
    b:setBool(false) -- false
    s:setString("wzpa") -- wzpa

    --f:restoreDefault()

    print("Dvars: [" .. 
      tostring(floatValue) .. ", " ..
        tostring(intValue) .. ", " ..
        tostring(boolValue) .. ", " ..
        tostring(stringValue) ..
        " ]"
    )
end

engine.addEventListener("render", main)

Last updated