This feature has been a beast (like a huge centipede monster)! It has consisted of many hurdles, and many retakes, until I finally got a foundation that I think is closer to what we want for the future.
I present to you the first version of room scripts!
Feature
Room scripts
It is now possible for supporters to write programming scripts for rooms:
export function onRoomEvent(addr: string, ev: string): void {
// Sweep black-listed characters on arrival
if (Event.getType(ev) == "arrive") {
const char = JSON.parse<Event.Arrive>(ev).char;
if (Store.getString("blacklist." + char.id) != null) {
Room.sweepChar(char.id, "is sent off by a bouncer.");
}
}
}
(This is only an example snippet and not a full script)
The snippet above may look a lot like Typescript, but is in fact AssemblyScript, a language sharing many features and standard library functions with Typescript. Initially, the plan was to use Lua, the same scripting language used by games like World of Warcraft and Roblox (kind of). But the need for a tighter sandboxing model caused it to finally land on using WebAssembly to execute scripts, and AssemblyScript as the scripting language.
Commands
There is currently no GUI to manage room scripts. Instead we have a set of commands:
Help command | Description |
---|---|
help roomscript |
Show room script info |
help create roomscript |
Create a room script |
help list roomscripts |
List the room’s scripts |
help set roomscript |
Set a room script attribute |
help delete roomscript |
Delete a room script |
(All room script commands can be found under: help build rooms
)
The roomscript
command shows not only the script itself, but also the script’s Post address (used by other scripts to send messages), and any errors encountered:
Example
roomscript myscript
Script development environment
Since the game in itself has no GUI to write scripts, a script development environment for local development, has been created. You can find it on GitHub:
This project allows you to write, compile, and test room scripts locally, before using copy/paste to add them to the game. The development environment also features a set of examples.
When used with an IDE that supports Typescript type checking (such as VSCode), you can get help through code completion, parameter info, quick info, and member lists:
For more info, see the README of the Mucklet script development environment.
Limitations & restrictions
The room script feature is highly experimental and fairly untested. In order to prevent scripts from crashing the server, some limitations have been added:
- Only supporters/pioneers may create room scripts.
- A room may have max 5 scripts.
- Scripts may be max 50k characters long.
- Scripts may only use 512kB of memory in total while running.
- Scripts may only run for max 200 milliseconds during each call.
- Scripts may only schedule 3 posts at a time.
- Scripts may only store a total of 10MB of data.
- Scripts may be stopped if spamming or being too active in other ways.
These are the limitation at the time of this release, but may be changed in the future.
Upcoming features
This is the first version of room scripts, which sets the foundation. Here is an incomplete list of some of the planned features for upcoming releases:
- List and manage room exits
- Intercept exit usage to allow “locks” and exit redirection
- List room characters
- Get room character details (like description, gender, species, etc.)
- Custom script commands - to trigger scripts without having to listen to the room
- Posting messages between room scripts and bots.
- Script support for room instances
Eventually, the game will also be extended with Area scripts and Realm scripts.
Thanks to everyone in this thread for helping me with ideas, and especially to @farcaller for the WASM suggestions, and discussions. Also thanks to @Shinyuu for the encouragement to finally do this feature!
Room listen indicator
If a room contains a script that listening in on room events, an indicator will show up on the area overlay at the top right corner of the chat log:
This is to inform the players that something is listening to them.
Improvements
Remove +X other events from notifications
When receiving notifications, the “+X other events” type of counting that was appended to the notification message did not work properly on IOS, and has therefore been removed.
Thanks to @Shinyuu for giving me all the IOS feedback!
Fixes
JSON circular reference on report
When making a report with attached logs, where the log would contain info messages (such as the one showing when using add note
), an error about “Converting circular structure to JSON” would show up. This has been fixed.
Thanks to Sabella for reporting this issue!