This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
LDDestroier's profile picture

Does anyone know of a CC emu which runs in linux terminal?

Started by LDDestroier, 09 January 2015 - 10:01 PM
LDDestroier #1
Posted 09 January 2015 - 11:01 PM
I have a cool Poweredge 2950 (and a Windows PC) running Ubuntu, and I want to have it run CraftOS. But the problem is, that every CC emulator runs in the graphical environment and not in the shell.

I want to get a CC emulator that runs within a linux terminal, and can be accessed via SSH client.
SquidDev #2
Posted 10 January 2015 - 09:18 AM
Dare I ask why it needs to be accessible via SSH? I just run CCEmuRedux off my USB stick and it works fine.

It might be feasible to port CCLite (or another pure-lua emulator) to use the terminal instead. I wrote a Lua Interop library, which can handle most terminal elements. However, there is no way to get terminal size/cursor position with escape codes, and no way to handle mouse events.

Another suggestion is X11 Forwarding, with something like Xming, but I really don't understand the SSH requirement.
lucy-san #3
Posted 11 January 2015 - 10:45 AM
It really would be just a case of rewriting https://github.com/g.../src/render.lua in CCLite to use ncurses. Actually, I might do it…

EDIT: Or not, fount a curses library for lua trough: https://github.com/luaposix/luaposix
Edited on 11 January 2015 - 10:07 AM
cdel #4
Posted 04 February 2015 - 05:56 AM
CC Emulator that would run in a linux terminal would be brilliant, I would love to have CraftOS technically running on my Raspberry Pi with a TFT screen. Even adding a small portable battery would open up a lot of possibilitys.
comp500 #5
Posted 20 February 2015 - 07:47 AM
I think the easiest way to do this would be to just implement a ssh-like protocol on CC, then running CCEmuRedux or similar headless.
Geforce Fan #6
Posted 21 February 2015 - 06:55 PM
I think the easiest way to do this would be to just implement a ssh-like protocol on CC, then running CCEmuRedux or similar headless.
not really
Edited on 21 February 2015 - 05:56 PM
comp500 #7
Posted 21 February 2015 - 07:53 PM
I think the easiest way to do this would be to just implement a ssh-like protocol on CC, then running CCEmuRedux or similar headless.
not really
why? i'd easily be able to make a ssh-like system using http(s)
LDDestroier #8
Posted 21 February 2015 - 08:14 PM
Okay, I suppose SSH wouldn't work, but maybe xterm. Still, if there isn't a terminal-based CC emulator, could someone try porting ccemuredux or cclite? I'm surprised there aren't any text-based CC emus already.
comp500 #9
Posted 21 February 2015 - 08:20 PM
Okay, I suppose SSH wouldn't work, but maybe xterm. Still, if there isn't a terminal-based CC emulator, could someone try porting ccemuredux or cclite? I'm surprised there aren't any text-based CC emus already.
I could try porting Mimic…

actually that might be easy
all there is to it is editing render.js
then putting it in a node/node-webkit instance
Edited on 21 February 2015 - 07:23 PM
comp500 #10
Posted 21 February 2015 - 08:29 PM
well that was easy!
now to make it into a CLI interface
LDDestroier #11
Posted 21 February 2015 - 09:48 PM
Oh goody! Ooo, is it possible to update the computercraft of Mimic from 1.5 to 1.6?
comp500 #12
Posted 21 February 2015 - 10:31 PM
Oh goody! Ooo, is it possible to update the computercraft of Mimic from 1.5 to 1.6?
that'd be up to GS and 1lann, but it supports 1.63:
Features
  • Full ComputerCraft emulator in your web browser
  • CC 1.63 support
  • Mobile (iOS and Android) support
CoderPuppy #13
Posted 21 February 2015 - 10:36 PM
A while ago I wrote a terminal-based emulator: https://github.com/CoderPuppy/cc-emu

I just fixed it up (and added better instructions) when I saw this thread.
comp500 #14
Posted 21 February 2015 - 10:40 PM
Progress update:

I've got it running in node-webkit, which means i can run node-webkit headless or port it to node
see you people tomorrow, i have to go now (GMT - usually 7am-8pmish on sat, if you want to know when you should check if im online)

A while ago I wrote a terminal-based emulator: https://github.com/CoderPuppy/cc-emu

I just fixed it up (and added better instructions) when I saw this thread.

ooh nice, will try it out later
LDDestroier #15
Posted 21 February 2015 - 11:04 PM
A while ago I wrote a terminal-based emulator: https://github.com/CoderPuppy/cc-emu

I just fixed it up (and added better instructions) when I saw this thread.

I was trying to use it, but I think I had a problem with lcurses, and it errors and lists a bunch of missing directories for Lua 5.2. Weird. I am using Lubuntu 14.04.
CoderPuppy #16
Posted 21 February 2015 - 11:21 PM
It is a bit finicky to setup. I think in *buntu you need to install luajit, lua-penlight, lua-curses and lua-posix. If that doesn't work then install luajit then manually compile luarocks with –lua-suffix=jit –with-lua=/usr and use luarocks to install everything else.

Example of using luarocks:

$ wget http://luarocks.org/releases/luarocks-2.2.0.tar.gz
$ tar zxpf luarocks-2.2.0.tar.gz
$ cd luarocks-2.2.0
$ ./configure --lua-suffix=jit --with-lua=/usr
$ sudo make bootstrap
$ sudo luarocks install penlight
$ sudo luarocks install lcurses
$ sudo luarocks install lposix
$ sudo luarocks install luabitop
Edited on 21 February 2015 - 10:25 PM
LDDestroier #17
Posted 22 February 2015 - 05:11 AM
I get the following error, even after installing the requirements from apt-get:


evan@evan-Latitude-D620:~/cc-emu-master$ lua cli.lua
lua: cli.lua:9: module 'emu' not found:
no field package.preload['emu']
no file '/usr/local/share/lua/5.2/emu.lua'
no file '/usr/local/share/lua/5.2/emu/init.lua'
no file '/usr/local/lib/lua/5.2/emu.lua'
no file '/usr/local/lib/lua/5.2/emu/init.lua'
no file '/usr/share/lua/5.2/emu.lua'
no file '/usr/share/lua/5.2/emu/init.lua'
no file './emu.luaemu.lua'
no file '/usr/local/lib/lua/5.2/emu.so'
no file '/usr/lib/i386-linux-gnu/lua/5.2/emu.so'
no file '/usr/lib/lua/5.2/emu.so'
no file '/usr/local/lib/lua/5.2/loadall.so'
no file './emu.so'
stack traceback:
[C]: in function 'require'
cli.lua:9: in main chunk
[C]: in ?
CoderPuppy #18
Posted 22 February 2015 - 05:27 AM
I think you have to run it with luajit so like luajit cli.lua . (The dot at the end is important, it tells it what directory to use as root)

Edit: also your package.path is weird, it seems to have "?.lua?.lua" or something in it
Edited on 22 February 2015 - 04:30 AM
comp500 #19
Posted 22 February 2015 - 07:14 AM
I think you have to run it with luajit so like luajit cli.lua . (The dot at the end is important, it tells it what directory to use as root)

Edit: also your package.path is weird, it seems to have "?.lua?.lua" or something in it
When I get some sort of linux box running (virtualbox/vagrant doesn't seem to be working on my main computer, i might try my pi) I'll test it out!
comp500 #20
Posted 22 February 2015 - 07:25 AM
It is a bit finicky to setup. I think in *buntu you need to install luajit, lua-penlight, lua-curses and lua-posix. If that doesn't work then install luajit then manually compile luarocks with –lua-suffix=jit –with-lua=/usr and use luarocks to install everything else.

Example of using luarocks:

$ wget http://luarocks.org/releases/luarocks-2.2.0.tar.gz
$ tar zxpf luarocks-2.2.0.tar.gz
$ cd luarocks-2.2.0
$ ./configure --lua-suffix=jit --with-lua=/usr
$ sudo make bootstrap
$ sudo luarocks install penlight
$ sudo luarocks install lcurses
$ sudo luarocks install lposix
$ sudo luarocks install luabitop
I tried it out, ./configure fails, lua.h not found

Also, with apt-get commands, lua cannot be found
If I run it with luajit instead of lua, it says that module luarocks.index cannot be found
If I install normal lua5.2, it says module emu not found…

My package.path has ./?.lua in it…
If I remove your editing of package.path, it comes up with the luarocks error again
… even when I apt-get install luarocks
Edited on 22 February 2015 - 06:35 AM
comp500 #21
Posted 22 February 2015 - 08:22 AM
auofyuieguyageufyiufesufys…
… well that is hard….
I have to change every reference of $, window, BrowserFS, XMLHttpRequest etc to node.js equivalents.

I might have to remove everything and just include the lua stuff

if only node webkit supported stdout/in


//require("./scripts/lib/jquery.min.js");
$ = function(x) {return x;};
//require("./scripts/lib/bootstrap.min.js");
//require("./scripts/lib/ace/src-min-noconflict/ace.js")
//require("./scripts/lib/Blob.js");
//require("./scripts/lib/FileSaver.js")
require("./scripts/lib/CapsLock.compressed.js")
//require("./scripts/lib/purl.js")
require("URIjs")
Lua5_1 = require("./scripts/lib/lua5.1.5.min.js")
//require("./scripts/lib/browserfs.js")
require("fs")
require("./scripts/lib/xdRequest.js")
require("./scripts/code.js")
globals = require("./scripts/globals.js")
core = require("./scripts/core.js")
require("./scripts/computer.js")
require("./scripts/filesystem.js")
require("./scripts/render.js")
events = require("./scripts/event.js")
require("./scripts/apis/bit.js")
require("./scripts/apis/fs.js")
require("./scripts/apis/http.js")
require("./scripts/apis/os.js")
require("./scripts/apis/peripheral.js")
require("./scripts/apis/redstone.js")
require("./scripts/apis/term.js")
core.run();
current progress ^
Edited on 22 February 2015 - 07:23 AM
comp500 #22
Posted 22 February 2015 - 08:43 AM
Well… I've done a bit of a rewrite, but I need to implement most (except Date/Time and bit) apis with node.js
comp500 #23
Posted 22 February 2015 - 09:07 AM
It's so exciting, as the load times get longer and longer, while the errors decrease

I think the lua stuff is actually being run :D/>

It gets to fs.list then errors because I haven't implemented the fs api

Also, I have an error which says 'thread' doesn't exist


actually that looks like an error in the Mimic code

corrected, now it's stopping at render.bsod, because I haven't implemented render :D/>
Edited on 22 February 2015 - 08:14 AM
CoderPuppy #24
Posted 22 February 2015 - 03:27 PM
It is a bit finicky to setup. I think in *buntu you need to install luajit, lua-penlight, lua-curses and lua-posix. If that doesn't work then install luajit then manually compile luarocks with –lua-suffix=jit –with-lua=/usr and use luarocks to install everything else.

Example of using luarocks:

$ wget http://luarocks.org/releases/luarocks-2.2.0.tar.gz
$ tar zxpf luarocks-2.2.0.tar.gz
$ cd luarocks-2.2.0
$ ./configure --lua-suffix=jit --with-lua=/usr
$ sudo make bootstrap
$ sudo luarocks install penlight
$ sudo luarocks install lcurses
$ sudo luarocks install lposix
$ sudo luarocks install luabitop
I tried it out, ./configure fails, lua.h not found

Also, with apt-get commands, lua cannot be found
If I run it with luajit instead of lua, it says that module luarocks.index cannot be found
If I install normal lua5.2, it says module emu not found…

My package.path has ./?.lua in it…
If I remove your editing of package.path, it comes up with the luarocks error again
… even when I apt-get install luarocks
Ok, sorry, I didn't test configure without lua installed, apparently –lua-suffix doesn't do anything (also it appears luajit doesn't include the necessary headers, so maybe that's the problem).

Updated example of using luarocks:

$ sudo apt-get install luajit libluajit-5.1-dev
$ wget http://luarocks.org/releases/luarocks-2.2.0.tar.gz
$ tar zxpf luarocks-2.2.0.tar.gz
$ cd luarocks-2.2.0
$ ./configure --with-lua=/usr --with-lua-include=/usr/include/luajit-2.0
$ sudo make bootstrap
$ sudo luarocks install penlight
$ sudo luarocks install lcurses
$ sudo luarocks install lposix
$ sudo luarocks install luabitop
comp500 #25
Posted 22 February 2015 - 03:32 PM
Good, things are running well, I still haven't implemented most apis but most display stuff works:

that bios error is from lua !!
CoderPuppy #26
Posted 22 February 2015 - 03:36 PM
What version of CC are you using? In 1.7 line 628 is "function()".
comp500 #27
Posted 22 February 2015 - 04:08 PM
What version of CC are you using? In 1.7 line 628 is "function()".
don't worry about that, that's just because I haven't implemented (almost) all apis, just testing colors and rendering at the moment
btw its based on mimic, so CC1.63

i have colors people!
Edited on 22 February 2015 - 03:10 PM
MKlegoman357 #28
Posted 22 February 2015 - 04:52 PM
You can find the exact colors on the wiki in hex form.
comp500 #29
Posted 22 February 2015 - 05:14 PM
You can find the exact colors on the wiki in hex form.
the coloring api i use doesn't support hex values, just a few named colours
Luca_S #30
Posted 22 February 2015 - 05:49 PM
comp500 very nice!
CoderPuppy #31
Posted 22 February 2015 - 06:15 PM
Why are you checking in colors.js instead of using npm?
comp500 #32
Posted 22 February 2015 - 06:53 PM
Why are you checking in colors.js instead of using npm?
i can't be bothered to make a .gitignore, will exclude it later
comp500 #33
Posted 23 February 2015 - 05:12 PM
Why are you checking in colors.js instead of using npm?
oh wait… you found my github repo :D/>

just so other people know, it's at https://github.com/comp500/Mimic
Sxw #34
Posted 24 February 2015 - 03:10 AM
Sorry for doing the same thing as comp500, but I didn't see his work when I started this project. I, too, am porting Mimic to Node.js. I have computer emulation working at https://github.com/Sxw1212/NodeMimic. See the README for details.
comp500 #35
Posted 24 February 2015 - 04:32 PM
Sorry for doing the same thing as comp500, but I didn't see his work when I started this project. I, too, am porting Mimic to Node.js. I have computer emulation working at https://github.com/Sxw1212/NodeMimic. See the README for details.
Nice! Unfortunately I don't have much time due to school anyway, I'll check out your version!
I can help you add colors just noticed how you do it… complicated but robust :D/> and http.

If nano can capture ctrl, why can't we? Is it in the libraries you're using
http://stackoverflow...-readline-shell < key.ctrl
Edited on 24 February 2015 - 04:11 PM
comp500 #36
Posted 24 February 2015 - 05:03 PM
Wow that's amazing!
Check out my pull request.
I did have to tweak install.js to get it to run on Windows, though

dir = "A:/comp500/Programming/NodeMimic-master/NodeMimic-master/"

Some tips:
  • only redraw the screen partially when needed
  • worm doesn't seem to work
  • on Windows, escape+T/R/S doesn't work
when I overflow the screen (e.g. programs then programs again) it crashes, saying it can't find render

time goes at one day a second

shutdown isn't very clean, leaving you at a blank command prompt and not stopping node

on edit, escape works but when i try to save it gives me a range error byteoffset out of range
Edited on 24 February 2015 - 04:06 PM
Sxw #37
Posted 25 February 2015 - 12:39 AM
*snip*
If nano can capture ctrl, why can't we? Is it in the libraries you're using
http://stackoverflow...-readline-shell < key.ctrl

We can capture ctrl, but only when another key is pressed, eg nano with Ctrl-X to save. Computercrafts edit just has you press ctrl to access a menu. If you know how to capture the raw ctrl, let me know please.

Wow that's amazing!
Check out my pull request.
I did have to tweak install.js to get it to run on Windows, though

dir = "A:/comp500/Programming/NodeMimic-master/NodeMimic-master/"

Some tips:
  • only redraw the screen partially when needed
  • worm doesn't seem to work
  • on Windows, escape+T/R/S doesn't work
when I overflow the screen (e.g. programs then programs again) it crashes, saying it can't find render

time goes at one day a second

shutdown isn't very clean, leaving you at a blank command prompt and not stopping node

on edit, escape works but when i try to save it gives me a range error byteoffset out of range

I haven't implemented esc-t/r/s yet, I'll finish that soon.
As for worm, it's probably not working due to colors being needed.
I've fixed the scrolling, it was a bug from leftover code.
As for the time going at one day a second, that's a Mimic bug. I've opened a Mimic ticket and will upgrade the commit version that's hardcoded when a new stable version come out.
I'll see what I can hook into for the shutdown event.

Thanks for the pull request, I'll look at it in later tonight.
Edited on 24 February 2015 - 11:40 PM