Yes, scripting gets a GUI for this release. And we get additional script features that has been requested, including script documentation. But the big one is probably this:
Scripting is now available for everyone!1
Maybe it is a bad idea. I hope the server handles the additional strain. But at least it is a fun idea that I think will make this place better.
1. Deploying locally compiled scripts using mucklet-script and manager tokens is still supporter only.
Features
Script Documentation
A Mucklet Script Documentation page has been added, with API references to all functionality available for room scripts.
The documentation is generated from the mucklet-script source code.
To get a link to the documentation in-game, type:
help roomscript
Room script GUI
As a builder or room owner, rooms now have a Script (</>
) icon at the top tool bar on the Room Info page:
Clicking the icon will open the Room scripts page, where you can see a list of existing scripts, toggle them on/off (blue means on), and create new scripts:
Clicking on Create new script will open a dialog where you can create a new script. Once created, a Script editor will open up to let you edit the script.
If you, on the Room scripts page click on one of the scripts, the Edit Room Script page will open:
The pencil-icon (marked with a red square above) will open the Script editor for the script.
If the script is a locally compiled wasm-file deployed with mucklet-script, the script will not be editable, but the wasm-file may be downloaded:
Script editor
The script editor opens up in a separate browser tab and lets you edit a room script.
The script editor features:
- An editable text area with color highlighting for visual guidance.
- An Update button that uploads and compiles the script.
- A question mark (?) icon that opens a new browser tab with Script documentation.
Syntax errors or compile errors will only show once you click Update, and will be shown at the top of the screen:
Note
Ignore the error that says “compiler mismatch”. It is an internal error that shouldn’t be there.
Script: Use exit on custom command
Custom commands can now use CmdAction.useExit to send the character through one of the room’s exists. The exit may be hidden or inactive.
Example
// ID of inactive exit leading up.
const exitId = "aaaabbbbccccddddeeee"
export function onActivate(): void {
Room.addCommand("climb", new Command("climb ladder", "Climb up the ladder to the loft."))
}
export function onCommand(addr: string, cmdAction: CmdAction): void {
cmdAction.useExit(exitId)
}
For more info, see:
Mucklet Script Documentation - method CmdAction.useExit
Script: Fetch char info
Scripts can now use Script.getChar to fetch public information about any character, even if they are not in the room.
let charInfo = Script.getChar(charId)
For more information, see:
Mucklet Script Documentation - function Script.getChar
Script: Room private describe
It is now possible for a room script to send a describe to one or more characters in the room, without it being seen by the rest of the room. This is done with Room.privateDescribe.
Room.privateDescribe("You sense someone watching you." , [ charId ])
Would result in:
Thanks to @Kookierhondje for suggesting the feature in this thread!
GitHub issue #372 - Room private describe
Script: Bot posting
It is now possible for room scripts and bot scripts to send and receive post messages between each other.
Room script posting to a bot: (AssemblyScript)
// Bot post address is the bot's ID prefixed with "bot."
const botAddr = "bot.cf21jnu9gbrtr77tbh7g"
// Listen for incoming post messages from the bot.
Script.listen([botAddr])
// Posting is done using Script.post.
// Data must be valid JSON.
Script.post(botAddr, "ping", `{"foo":42}`)
Bot script receiving a post: (Javascript)
// Listen for 'out' events, the same way as any other event
controlledBot.on("out", (ev) => console.log(ev));
The post event, ev
, will look something like this:
{
"id": "d12opv4ks8oc7h285b7g",
"type": "post",
"time": 1749388540460,
"sender": "room.c2d1ml0t874bj4eva85g#d0hg8dsks8o83o1k4drg",
"target": "bot.cf21jnu9gbrtr77tbh7g",
"topic": "ping",
"data": { "foo": 42 }
}
Bot posting to a room script: (Javascript)
await controlledBot.call("post", {
addr: "room.c2d1ml0t874bj4eva85g#d0hg8dsks8o83o1k4drg",
topic: "pong",
data: { "bar": 43 },
})
This feature is made for @farcaller, to give him a less hacky way to communicate with external bots!
Delete exits targeting own room
It is now possible to delete exits targeting a room that you own, even if the source room is not owned by you.
To find rooms with exits leading to your current room, type:
list exits all
This list will include external exits and hidden exits if you own the current room. Below is the result from Miranda’s Café:
Exits targeting current room can then be deleted using the exit ID:
delete exit #balbgt69gbrqf705k170
For more info, type:
help list exits all
help delete exit
Thanks to @Arnavoni for requesting the feature in this thread!
GitHub issue #380 - Delete remote exit
Improvements
Describe layout
The layout of describe messages has been updated, the brackets have been removed, and the font now uses the same size as for poses. The changes are made to improve readability.
Before:
After:
Focus input on menu reply
When clicking the Reply option in the context menu (â‹®
) for a message, the console input now gets the focus.
Thanks to @Jagrabbit for suggesting this improvement!
GitHub issue #376 - Focus input on menu reply
Fixes
Console gives invalid change range error
An error could occur when using the command console:
Uncaught RangeError: Invalid change range 1 to 1 (in doc of length 0)
This has been fixed.
GitHub issue #367 - Codemirror: Invalid change range
Toaster width on mobile
Toaster popups had a fixed width which appeared broken on smaller devices. This has been fixed.
GitHub issue #366 - Toaster layout on smaller devices
Custom commands not listed in instance rooms
Custom commands added by scripts were not listed if the room was an instance room. This has been fixed.
Thanks to @Shinyuu for reporting this issue!
Room.removeCommand gives error
When a script called Room.removeCommand an error was logged:
error parsing script: "room.removeCommand" is not exported in module "env"
This has been fixed.
Thanks to @Xetem (it was you, right?) for reporting the issue!
Script memory errors
The AssemblyScript memory could get corrupted and result in various errors when JSON.parse
was used on nested structures. This has been fixed in a previous patch release.
Thanks to @Shinyuu for reporting the issue!
GitHub issue #12 - Script memory errors
Script hooks not removed
Script event hooks such as Script.listen, Room.listen, or Room.addCommand, could in certain situations remain after a script was deactivated or deleted. This resulted in lingering commands, or rooms that always showed the indicator that a script was listening. This has been fixed.
Thanks to @Shinyuu (again!) for reporting the issue.
Err not defined on some incomplete commands
Some commands (such as delete exit
) resulted in the error if not all parameters were included:
ReferenceError: Err is not defined
Script: exitAction.cancel not exported
When using ExitAction.cancel in a script that was created using create roomscript
, an error would be logged for that script:
error parsing script: “exitAction.cancel” is not exported in module “env”’
This has been fixed.
Thanks to Ace and @cade_trigon for reporting this issue in this thread!
Broken permissions
A bug made it possible for a player to delete exits created and owned by another player. This has been fixed.
Scripts may log Error parsing script
The server and script engine may get into a state where it fails to load the script, logging errors such as:
error parsing script: failed to create file
This has been fixed.
Thanks to @farcaller for reporting it and keeping the script for me to analyze!