Skip to content
Zicklag edited this page Sep 24, 2022 · 3 revisions

Scripting in Punchy is powered by the bevy_mod_js_scripting plugin. Scripts may be written in either TypeScript or JavaScript and run both on native and in the browser.

At the time of writing we only have two scripts in Punchy: a demo script and the script to implement the Health item. The scripting API is extremely work-in-progress and may change quickly as we try to find the best way to connect Bevy to JavaScript.

The plan is to move as much of the gameplay code into scripts as possible. For example, the goal is to have all of the items and fighter attacks implemented as scripts, if possible. This has some useful side-effects:

  • Gameplay development can be quicker because we don't have to wait for scripts to compile, and they can be hot reloaded while the game is running for instant feedback.
  • Implementing the gameplay with scripts makes sure that the scripting interface is powerful enough to use for great mods. It also removes that barrier between modded items and built-in items that can make it feel like mods are stuck using a half-baked, limited API that only lets them change select aspects of the game.

The goal is not to allow scripts to change the game architecture. Most of the game will be written in Rust, but we want to allow scripts to change as much as the gameplay aspects as possible.

Tutorial

Since the scripting API is in flux, we won't include a tutorial here, but you can see demo_script.ts for a walkthrough.

Clone this wiki locally