Picotron-TypeScript/README.md
2026-01-17 10:09:53 +01:00

63 lines
1.5 KiB
Markdown

# TypeScript for Picotron
This is an experimental template project to mix-and-match TypeScript and Lua for your Picotron projects.
Most of the _G.d.ts file has been AI-generated from the official documentation, with progressive manual adjustments.
> [!IMPORTANT]
> TypeScript code converted to Lua code is not guaranteed to be correct or efficient.
> Read the [TypeScriptToLua documentation](https://typescripttolua.github.io/docs/getting-started), follow best practices, and review the generated Lua code.
## Setup
### Requirements
- [NodeJS](https://nodejs.org/en/download)
- [pnpm](https://pnpm.io/installation)
### Create your project
- Create a new project (i.e. `my-project`) from this template
- Clone `my-project` in your Picotron's `drive` folder
- `cd my-project` then
- `pnpm install`
- `pnpm build`
- Inside Picotron:
- Open the terminal, `cd my-project` then `load game`
- Edit `main.lua` to change the `cd` line to `cd("/my-project/build")`
- Run the game
## Development
- `pnpm dev` will watch and rebuild your **TypeScript** code.
- `pnpm build` is required when you change **Lua** code.
The resulting code is a single `build/bundle.lua` file.
## Publish
**In Picotron**
```
> cd my-project
> load game
```
- Open the code inside Picotron
- Comment the `cd()` line in main.lua
- Save
**On the host**
`pnpm build`
**In Picotron**
Open the terminal:
```
> cp -f /my-project/build/src /ram/cart/build/src
> save
> export my-project.bin
```