🔧Engine

Table to work with game engine.

IsInGame(): boolean

Returns true if the game is in progress.


IsShopOpen(): boolean

Returns true if the shop is open.


SetQuickBuy(item_name: string, reset [?]: boolean): nil

Name
Type
Description

item_name

string

The name of the item to quick buy. (e.g. blink, relic)

reset [?]

boolean

Reset the quick buy list. (default: true)

Add item to quick buy list.


RunScript(script: string, contextPanel [?]: string): boolean

Name
Type
Description

script

string

The script to run.

contextPanel [?]

string

The name of the panel to run the script in. (default: "Dashboard")

Run a JS script in the panorama context. Return true if the script was executed successfully. JS documentation

Example

-- in dota console, you should see "Hello from Lua!"
Engine.RunScript("$.Msg('Hello from Lua!')");

ExecuteCommand(command: string): nil

Name
Type
Description

command

string

The command to execute.

Execute a console command.

Example

-- in dota chat, you should see "Hello from Lua!"
Engine.ExecuteCommand("say \"Hello from Lua!\"");

PlayVol(sound: string, volume [?]: number): nil

Name
Type
Description

sound

string

The sound to play. Could find in sounds folder in pak01_dir.vpk file.

volume [?]

number

The volume of the sound. (default: 0.1)

Play a sound with a specific volume.

Example

-- play a sound with a volume of 0.5 (very loud)
Engine.PlayVol("sounds/npc/courier/courier_acknowledge.vsnd_c", 0.5);

CanAcceptMatch(): boolean

Returns true if the player can accept the match.


GetGameDirectory(): string

Returns the current game directory. (e.g. dota 2 beta)


GetCheatDirectory(): string

Returns the current cheat directory.


GetLevelName(): string

Returns the current level name. (e.g. maps/hero_demo_main.vpk)


GetLevelNameShort(): string

Returns the current level name without the extension and folder. (e.g. hero_demo_main)


AcceptMatch(state: integer): nil

Name
Type
Description

state

integer

DOTALobbyReadyState

Accept match.


ConsoleColorPrintf(r: integer, g: integer, b: integer, a [?]: integer, text: string): nil

Name
Type
Description

r

integer

Red value.

g

integer

Green value.

b

integer

Blue value.

a [?]

integer

Alpha value. (default: 255)

text

string

Text to print.

Print a message to the dota console.


GetMMR(): integer

Returns the current MMR.


GetMMRV2(): integer

Returns the current MMR. Works better than Engine.GetMMR. Must be called from the game thread. Ex: OnNetUpdateEx, OnGCMessage, not OnFrame or on initialization.


ReloadScriptSystem(): nil

Executes script system reload.


ShowDotaWindow(): nil

Brings the game window to the forefront if it is minimized. Use this function to make the game window the topmost window.


IsInLobby(): boolean

Returns true if the player is in a lobby.


GetBuildVersion(): string

Returns the cheat version.


GetHeroIDByName(unitName: string): integer|nil

Name
Type
Description

unitName

string

Can be retrieved from NPC.GetUnitName

Returns hero ID by unit name.

Example

local abaddonId = Engine.GetHeroIDByName( "npc_dota_hero_abaddon" )

GetDisplayNameByUnitName(unitName: string): string|nil

Name
Type
Description

unitName

string

Can be retrieved from NPC.GetUnitName

Returns hero display name by unit name.

Example

local nevermore_name = Engine.GetDisplayNameByUnitName( "npc_dota_hero_nevermore" )
-- nevermore_name == "Shadow Fiend"

GetHeroNameByID(heroID: integer): string|nil

Name
Type
Description

heroID

integer

Returns hero name by ID.


GetUIState(): Enum.UIState

Returns current UI state.

Last updated