For some time now, efforts have been underway to overhaul the documentation for CC:Tweaked. As part of this process, an ambitious idea emerged: to enable CC:Tweaked to run directly in a web browser. This would allow users to interact with and test code samples instantly with just a click.
Initially, there was no awareness of Mimic, EveryOS’s impressive project. Therefore, in classic problem-solving fashion, a deep dive into development began, resulting in the creation of copy-cat, an alternative ComputerCraft emulator that operates directly in your browser.
copy-cat: Another ComputerCraft emulator
The primary goal of copy-cat is to provide an accurate and current emulation environment for documentation purposes. To achieve this, it’s built upon a modified version of the CC:Tweaked source code. This ensures that both the Lua VM and Java APIs behave almost identically to the original.
It’s important to note that while striving for near-perfect replication, certain browser environment limitations make complete emulation impossible.
Key Features of the Online Emulator
Despite these constraints, copy-cat offers a range of powerful features:
- Integrated Code Editor: Benefit from the advanced capabilities of the Monaco editor, directly within the emulator. This provides a robust coding environment for writing and testing ComputerCraft programs online.
- File Management: Download the entire contents of a virtual computer’s file system as a convenient zip archive. Furthermore, you can upload zip files back into the emulator, making it easy to manage and share projects.
- Media Capture Tools: Create screenshots of the terminal display or record animated GIFs of your ComputerCraft sessions. This is ideal for sharing demonstrations or documenting program behavior.
- Full Settings Access: Configure all of ComputerCraft’s settings to your preference. You have the freedom to enable or disable Lua 5.1 support, tailoring the environment to your specific needs and experiments.
Accuracy and Nuances in Browser Emulation
While copy-cat strives for accuracy, users should be aware of inherent limitations in browser-based emulation. For example, the HTTP API has been largely reimplemented, but certain functionalities like setting custom headers or accessing specific sites may be restricted. Similarly, input event handling (keyboard presses, mouse interactions) might exhibit minor differences compared to a native ComputerCraft environment. It is advisable not to depend on precise input behavior for critical applications.
Running Online Demos with Startup Code
A notable feature of copy-cat is the ability to execute arbitrary startup code via a query parameter in the URL. This powerful capability allows for the creation of live, shareable demonstrations of programs directly within the online emulator. This functionality is particularly useful for showcasing programs that do not rely on peripherals or turtles.
For instance, you can experience mbs, a program for ComputerCraft, directly in your browser using this link: try out mbs. This link includes base64 encoded startup code that automatically installs and runs mbs.
This feature, while currently a proof-of-concept, has the potential to be expanded, making it even more user-friendly in the future.
Call to Action and Future Development
Copy-cat is still under active development, and your feedback is highly valued. If you have suggestions, encounter bugs, or are interested in contributing, please visit the issue tracker.
Performance may occasionally be suboptimal, which is understandable considering the technical complexity of running a Lua VM written in Java within a Javascript VM. Despite this, copy-cat provides a valuable and accessible way to experiment with ComputerCraft in any modern web browser.