Skip to content

Exeteres/opc-types

Repository files navigation

OpenComputers and TypeScript

TypeScriptToLua TypeScriptToLua
Language
Build status Build status

Introduction

This repository contains TypeScript declarations for OpenComputers APIs, some of its mods and operating systems, including OpenOS and MineOS.

It is assumed that you will use TypeScriptToLua as a transpiler.

Some examples can be found in the examples folder. Also look at VSCode extension, which integrates TypeScript with OpenComputers.

Supported mods / operating systems

Name Type Package
OpenComputers (common API) Mod @opct/common
Applied Energistics 2 integration Mod @opct/ae2
OpenLight Mod @opct/openlight
OpenPrinter Mod @opct/openprinter
OpenSecurity Mod @opct/opensecurity
OpenOS Operating system @opct/openos
MineOS Operating system @opct/mineos

Installation

# Typings for OpenOS
yarn add @opct/openos # or npm install @opct/openos -S

# Typings for MineOS
yarn add @opct/mineos

# TSTL
yarn add typescript-to-lua
// tsconfig.json
{
  "compilerOptions": {
    "target": "esnext",
    "outDir": "dist",
    "module": "commonjs",
    "lib": ["esnext"],
    "strict": true,
    "moduleResolution": "node",
    "rootDir": "src",
    "types": ["lua-types/jit", "@opct/openos", "@opct/mineos"]
  },
  "tstl": {
    "luaTarget": "JIT"
  }
}

Setting up a comfortable working environment

  • You can use Visual Studio Code or any other editor with TypeScript support.

  • Instead of a real mod, you can use an emulator. Otherwise, it is necessary to set filesystem.bufferChanges to false in order to have external access to the disk.

  • Create a link to the disk to keep the source code separate from it:

    # linux / macos
    ln -s /path/to/disk/home/app dist
    # windows (cmd)
    mklink /j dist C:\path\to\disk\home
  • Use tstl --watch

About

OpenComputers and TypeScript

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors