Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dota-lua-types

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dota-lua-types

TypeScript definitions for Dota 2 Lua API

  • 4.6.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

Dota Lua Types

TypeScript definitions for Dota 2 Lua API, designed to be used with TypeScriptToLua.

Installation

Check out our addon template for usage examples.

  1. Get package from npm
yarn add -D dota-lua-types
# or
npm install -D dota-lua-types
  1. Modify your tsconfig.json
{
  "compilerOptions": {
    "types": ["dota-lua-types"],
    "plugins": [{ "transform": "dota-lua-types/transformer" }]
  }
}

Enums

This package includes 2 versions of enum types - raw and normalized. Raw types are included with "types": ["dota-lua-types"]. They are defined using original engine names and have no structural changes. This makes the code using some enums compatible with Panorama, however it leads to repetition and requires you to use inconsistent standard names.

Normalized enum types can be included with "types": ["dota-lua-types/normalized"]. With these types, enums have consistent names and have no repeated parts. For example, instead of EDOTA_ModifyGold_Reason.DOTA_ModifyGold_Unspecified you have to write ModifyGoldReason.UNSPECIFIED.

Both type versions define aliases for alternative names, so libraries created with one version would be compatible with a different one.

Notes

  • You can explore the same data in readable form on dota-data page.

  • To extend standard classes you can use declaration merging:

    interface CDOTA_BaseNPC {
      log(message: string): void;
    }
    
    CDOTA_BaseNPC.log = function (message) {
      print(`${this.GetUnitName()} says: ${message}`);
    };
    
    HeroList.GetHero(0)!.log('Hello world');
    
  • All Dota classes there are declared as interfaces. To extend them you can use utilities

    import { BaseAbility, BaseModifier, registerAbility, registerModifier } from './utils';
    
    @registerAbility('ability_test')
    export class Test extends BaseAbility {
      GetIntrinsicModifierName = () => TestModifier.name;
    }
    
    @registerModifier('ability_test_modifier')
    export class TestModifier extends BaseModifier {
      OnCreated() {
        print('Test modifier created');
      }
    }
    

Keywords

FAQs

Package last updated on 07 Nov 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc