Interfaces
Engine
GetWindowWidth()
Returns window width:
Example:
print("Screen Resolution: " ..
tostring(Interfaces.Engine.GetScreenWidth()) .. "x" ..
tostring(Interfaces.Engine.GetScreenHeight()))
Output: Screen resolution: 1920x1080
GetWindowHeight()
Returns window height:
Example:
print("Screen Resolution: " ..
tostring(Interfaces.Engine.GetScreenWidth()) .. "x" ..
tostring(Interfaces.Engine.GetScreenHeight()))
Output: Screen resolution: 1920x1080
GetLocalPlayer()
Returns local player's index:
Example:
print("LocalPlayer: " .. tostring(Interfaces.Engine.GetLocalPlayer()))
Output: LocalPlayer: 1
IsInGame()
Returns true/false whether you are currently in-game:
Example:
print("InGame: " .. tostring(Interfaces.Engine.IsInGame()))
Output: InGame: false (would say true if in game)
IsConnected()
Returns true/false whether you are currently connected (in-game, or connected but in loading screen):
Example:
print("Connected: " .. tostring(Interfaces.Engine.IsConnected()))
Output: Connected: false (would say true if in game/end of loading screen)
ExecuteClientCmd()
Runs a command as if it were ran in console
Example:
Interfaces.Engine.ExecuteClientCmd("clear;echo Hello World!")
Would clear the in-game console and print to it: "Hello World!"
Input
IsButtonDown()
Returns true/false if button is pressed
Example:
TODO: This example.
EntityList
GetClientEntity()
Returns the Entity of a specified index
Example:
-- Get localPlayer
local localPlayer = Interfaces.EntityList.GetClientEntity(Interfaces.Engine.GetLocalPlayer())
if localPlayer:Exists() then
-- Get the localPlayer's origin
local origin = localPlayer:Origin()
-- Print the origin
print("localPlayer's origin = X:" .. origin.x .. " Y:" .. origin.y .. " Z:" .. origin.z)
end
Output: localPlayer's origin = X:1853.345 Y:-242.234 Z:232.463
GetHighestEntityIndex
Returns the index of the highest entity, (useful for doing a for loop over every ent in-game, although using GetEntitiesByClassID unless trying to loop through every enity, as it is more efficient by a landslide)
Example:
for entityIndex=0, Interfaces.EntityList.GetHighestEntityIndex() do
local entity = Interfaces.EntityList.GetClientEntity(entityIndex)
if entity:Exists() then
local origin = entity:Origin()
print("Entity " .. entityIndex .. "'s origin = X:" .. origin.x .. " Y:" .. origin.y .. " Z:" .. origin.z)
end
end
Output: Entity 0's origin = X:0 Y:0 Z:0 (Repeating for all entities)