Anvil Scripting Reference
  • Getting started
    • Introduction
  • 🚀Examples
    • Create a speed overlay
    • Creating a Clock with ImGui
    • Calculating Distances Tool
  • ⚙️ User Settings
    • Make use of our settings API
  • 📦Namespaces
    • engine
    • player
    • key
    • mouse
    • memory
    • draw
    • ImGui
  • 🧪Types
    • Vec2
    • Vec3
    • Vec4
    • playerState
    • refDef
    • clientEntity
    • cg
    • usercmd
    • trace
    • dvar
  • 📄Enums
    • CmdButton
    • ImGuiWindowFlags
    • ImGuiStyleVar
    • ImGuiCol
Powered by GitBook
On this page
  • Properties
  • Methods
  1. Types

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)
PrevioustraceNextCmdButton

Last updated 1 month ago

🧪