Jump to content




copy-cat: A ComputerCraft emulator for the web


2 replies to this topic

#1 SquidDev

    Frickin' laser beams

  • Members
  • 1,403 posts
  • LocationDoes anyone put something serious here?

Posted 20 May 2019 - 07:50 PM

One thing I've been working on for a little while now is revamping CC:Tweaked documentation situation. As part of that, I had the fantastic idea of "could we run CC:Tweaked in the browser?", allowing people to run code samples with a click of a button.

Now, at the time, I wasn't aware of EveryOS's fantastic Mimic fork, and so I did the only thing logical and went on a long yak shaving expedition. Presenting...

copy-cat: Another ComputerCraft emulator
Posted Image

As it's original aim was to be used for documentation, it aims to be as accurate and up-to-date as possible. In order to achieve this, copy-cat is built from a modified version of CC:Tweaked's source code - both the Lua VM and Java APIs behave exactly1 the same.

1. While we try to keep as close as we can, there are some elements which are impossible to emulate due to the restricted environment of a browser.
For instance, the http API has been almost entirely recreated, and some functionality (such as setting specific headers or requesting some sites) is not impossible. As with any emulator, there will be subtle differences in how input events (key presses, mouse clicks, etc...) are handled, so do not rely on our behavior.

While this is all well and good, that's not all copy-cat can do. There's all sorts of other fancy features, including:
  • Built-in editor, with access to all of Monaco's goodness.
  • Download the computer's file contents as a zip file. And then drag-and-drop that zip back into the file browser to open it again!
  • Take screenshots and record gifs of the terminal.
  • Access to all of ComputerCraft's settings. You can enable and disable Lua 5.1 support to your heart's content.
That said, there's still lots of things missing, so if you've got suggestions, bug reports or would just like to help out, head over to the issue tracker! I will confess the performance is a bit lacking a times, but given that this is a Lua VM written in Java running in a Javascript VM, I'll say that's pretty understandable.

One other thing worth mentioning is the ability to run arbitrary startup code via a query parameter. This allows you to create online demos of a program (assuming it doesn't require peripherals or turtles). For instance, why don't you try out mbs?

If you want to try this out yourself, it's just a base64 encoded string - ideally you'd just run your installer. I'm hoping to expand on this in the future (and make it more accessible), but it's a fun POC for now.

Edited by SquidDev, 20 May 2019 - 07:51 PM.


#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,451 posts

Posted 21 May 2019 - 03:32 AM

It's possible that your project is too popular already.

#3 SquidDev

    Frickin' laser beams

  • Members
  • 1,403 posts
  • LocationDoes anyone put something serious here?

Posted 21 May 2019 - 11:32 AM

View PostLyqyd, on 21 May 2019 - 03:32 AM, said:

It's possible that your project is too popular already.
Just fixed this, and a couple of other issues with http and websockets. Also made some modifications to how events are queued, which should mean timers are a little better behaved.

Serves me right for pushing a release without getting other people to test it first!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users