Jump to content




Termu - Terminal-based Emulator


58 replies to this topic

#1 CoderPuppy

  • Members
  • 121 posts

Posted 20 January 2016 - 06:14 AM


Termu
A ComputerCraft Emulator for the Terminal

Posted Image

This is a simple emulator written in Lua.
It definitely doesn't have perfect emulation (e.g. LuaJ string bug, error checking).
But it's pretty lightweight, supports very old versions of CC and with a couple small tweaks to the ROM can be automated (just in case you want to do that).
It's only been tested on Linux, but it should work on OS X and you might be able to get it to work on Windows (using MinGW or Cygwin or something).

Github: CoderPuppy/cc-emu
License: MIT

Recomended Installation

Spoiler

Configuration

Spoiler


Plans / To Do

Spoiler


Edited by CoderPuppy, 02 August 2016 - 03:35 AM.


#2 Admicos

  • Members
  • 207 posts
  • LocationTurkey

Posted 20 January 2016 - 10:20 AM

There is no cli.lua in the zip. Only the lua files from computercraft

EDIT: Didn't see the other repo
EDIT 2: My terminal just flashed black and gone back to shell. No errorrs, nothing.

Edited by Admicos, 20 January 2016 - 10:34 AM.


#3 CoderPuppy

  • Members
  • 121 posts

Posted 20 January 2016 - 03:54 PM

I just pushed an update that lets you actually see the error message, but you could just append ">/dev/null" to the end of the command, which should let you see the error.

#4 Selim

  • Members
  • 189 posts
  • LocationHiding in Online Storage

Posted 20 January 2016 - 04:22 PM

Installed as recommended, ran
lua cli.lua ./0/
and got the error:
./cc/bios.lua:232: attempt to index global 'colors' (a nil value)

Edit: Ok, the error code was interfering with the code tags. That was wierd.

[This isn't a proper closing code tag: [[/color]/CODE] -L]

Edited by Selim, 20 January 2016 - 06:59 PM.


#5 CoderPuppy

  • Members
  • 121 posts

Posted 20 January 2016 - 07:55 PM

View PostSelim, on 20 January 2016 - 04:22 PM, said:

snip

I just pushed a new branch: debug (here's a zip), it should provide more information.
Just looking at your error it seems like it's erroring before loading colors.

#6 Selim

  • Members
  • 189 posts
  • LocationHiding in Online Storage

Posted 20 January 2016 - 08:49 PM

./emu.lua:516: bad argument #1 to 'log' (number expected, got nil)
./cc/bios.lua:232: @
./cc/bios.lua:554: @
./cc/bios.lua:704: @

Edited by Selim, 20 January 2016 - 08:49 PM.


#7 CoderPuppy

  • Members
  • 121 posts

Posted 20 January 2016 - 10:31 PM

View PostSelim, on 20 January 2016 - 08:49 PM, said:

snip
Oh, my colors polyfill was broken, that's what happens when you don't test code (I tested it this time). I pushed an update that fixes it (which is available at the same link).

Edited by CoderPuppy, 20 January 2016 - 10:32 PM.


#8 Selim

  • Members
  • 189 posts
  • LocationHiding in Online Storage

Posted 20 January 2016 - 10:38 PM

Cool! It works on my first system now, but when I am trying to install it on my Raspberry Pi it gives me:
lua: ./emu.lua:641: attempt to call field 'initscr' (a nil value)
stack traceback:
./emu.lua:641: in function 'emu'
cli.lua:16: in main chunk
[C]: in ?

On a side note, is it possible to get the HTTP API ported over?

Edited by Selim, 20 January 2016 - 10:52 PM.


#9 CoderPuppy

  • Members
  • 121 posts

Posted 20 January 2016 - 10:57 PM

View PostSelim, on 20 January 2016 - 10:38 PM, said:

snip
On your first system could you try disabling multishell (using the new set program), there should be an error. Actually I wonder if it's colours loading before colors, which would explain the whole thing. I just pushed another new version that tests that. What OS are you running this on?

And on you RPi you may need to install ncurses (if you're on Rasbian that should be some combination of ncurses, libncurses5, libncurses5-dbg, libncursesw5 and libncursesw5-dev) then you may need to reinstall luaposix.
That's just from looking at the error though, I can't test further (too many packages that depend on ncurses).

EDIT: I'll see about the HTTP API, it might require a rewrite.

Edited by CoderPuppy, 20 January 2016 - 11:07 PM.


#10 Selim

  • Members
  • 189 posts
  • LocationHiding in Online Storage

Posted 20 January 2016 - 11:15 PM

Disabling multishell does not throw any errors. Running with the update does not throw any errors as well. System #1 is Debian Linux running alongside Chome OS via crouton on my Chromebook. On the Pi after installing the ncurses packages and reinstalling luaposix, it works!

#11 CoderPuppy

  • Members
  • 121 posts

Posted 20 January 2016 - 11:40 PM

View PostSelim, on 20 January 2016 - 11:15 PM, said:

snip
Ok, good! I've merged all the fixes back into master, so you probably switch back to that (if you're using git). Also I've looked into implementing the HTTP API, I don't think it'll be a complete rewrite, I will have to use plain ANSI escapes instead of using curses but I think that'll be the only real change.

Edited by CoderPuppy, 20 January 2016 - 11:41 PM.


#12 Selim

  • Members
  • 189 posts
  • LocationHiding in Online Storage

Posted 21 January 2016 - 05:03 PM

Updated and got
lua: cc-emu/emu.lua:256: module 'terminfo' not found:
		no field package.preload['terminfo']
		no file '/usr/local/share/lua/5.2/terminfo.lua'
		no file '/usr/local/share/lua/5.2/terminfo/init.lua'
		no file '/usr/local/lib/lua/5.2/terminfo.lua'
		no file '/usr/local/lib/lua/5.2/terminfo/init.lua'
		no file '/usr/share/lua/5.2/terminfo.lua'
		no file '/usr/share/lua/5.2/terminfo/init.lua'
		no file './terminfo.lua'
		no file 'cc-emu/terminfo.lua'
		no file '/usr/local/lib/lua/5.2/terminfo.so'
		no file '/usr/lib/arm-linux-gnueabihf/lua/5.2/terminfo.so'
		no file '/usr/lib/lua/5.2/terminfo.so'
		no file '/usr/local/lib/lua/5.2/loadall.so'
		no file './terminfo.so'
stack traceback:
		[C]: in function 'require'
		cc-emu/emu.lua:256: in main chunk
		[C]: in function 'require'
		cc-emu/cli.lua:9: in main chunk
		[C]: in ?

EDIT: Nevermind, I forgot to install luv.
EDIT2: Apparently I still get the error after installing luv.

Edited by Selim, 21 January 2016 - 05:58 PM.


#13 columna1

  • Members
  • 65 posts

Posted 21 January 2016 - 06:16 PM

View PostSelim, on 21 January 2016 - 05:03 PM, said:

Updated and got
lua: cc-emu/emu.lua:256: module 'terminfo' not found:
		no field package.preload['terminfo']
		no file '/usr/local/share/lua/5.2/terminfo.lua'
		no file '/usr/local/share/lua/5.2/terminfo/init.lua'
		no file '/usr/local/lib/lua/5.2/terminfo.lua'
		no file '/usr/local/lib/lua/5.2/terminfo/init.lua'
		no file '/usr/share/lua/5.2/terminfo.lua'
		no file '/usr/share/lua/5.2/terminfo/init.lua'
		no file './terminfo.lua'
		no file 'cc-emu/terminfo.lua'
		no file '/usr/local/lib/lua/5.2/terminfo.so'
		no file '/usr/lib/arm-linux-gnueabihf/lua/5.2/terminfo.so'
		no file '/usr/lib/lua/5.2/terminfo.so'
		no file '/usr/local/lib/lua/5.2/loadall.so'
		no file './terminfo.so'
stack traceback:
		[C]: in function 'require'
		cc-emu/emu.lua:256: in main chunk
		[C]: in function 'require'
		cc-emu/cli.lua:9: in main chunk
		[C]: in ?

EDIT: Nevermind, I forgot to install luv.
EDIT2: Apparently I still get the error after installing luv.

I get the same error as well.

#14 Admicos

  • Members
  • 207 posts
  • LocationTurkey

Posted 21 January 2016 - 07:34 PM

I can currently run it. But it's a little bit slow

EDIT: Pressing backspace prints "unknown key: 127"
EDIT2: CTRL doesnt work in edit.

Edited by Admicos, 21 January 2016 - 07:35 PM.


#15 Selim

  • Members
  • 189 posts
  • LocationHiding in Online Storage

Posted 21 January 2016 - 10:35 PM

Updated again, now I have
there's an error
lua: cc-emu/emu.lua:467: attempt to index local 'termNat' (a nil value)
stack traceback:
cc-emu/emu.lua:467: in function 'emu'
cc-emu/cli.lua:16: in main chunk
[C]: in ?

Edited by Selim, 21 January 2016 - 10:36 PM.


#16 CoderPuppy

  • Members
  • 121 posts

Posted 21 January 2016 - 10:40 PM

View PostSelim, on 21 January 2016 - 05:03 PM, said:

snip

View Postcolumna1, on 21 January 2016 - 06:16 PM, said:

snip
Sorry, I forgot about the terminfo dependency.

View PostAdmicos, on 21 January 2016 - 07:34 PM, said:

I can currently run it. But it's a little bit slow

EDIT: Pressing backspace prints "unknown key: 127"
EDIT2: CTRL doesnt work in edit.
It is rather slow when using the window API (probably because my implementation of term.blit is slow), but you can disable multishell (the main use of windows) using the new set program.
Backspace (and other keys) not working will probably be a problem, but that's an error from an old version (new errors should say "unknown key seq").
CTRL can't be captured on it's own in the terminal, but I mapped Ctrl-Shift-Tilde to it.

View PostSelim, on 21 January 2016 - 10:35 PM, said:

Updated again, now I have
there's an error
lua: cc-emu/emu.lua:467: attempt to index local 'termNat' (a nil value)
stack traceback:
cc-emu/emu.lua:467: in function 'emu'
cc-emu/cli.lua:16: in main chunk
[C]: in ?
Just pushed a fix that'll hopefully print the error even if termNat is nil.

#17 Selim

  • Members
  • 189 posts
  • LocationHiding in Online Storage

Posted 21 January 2016 - 11:01 PM

View PostCoderPuppy, on 21 January 2016 - 10:40 PM, said:

Just pushed a fix that'll hopefully print the error even if termNat is nil.
I will test later, my Pi is currently down. I am borrowing the USB hub that was powering it for another purpose atm.

Side note: Personally, I like when emulators have a variable set somewhere so that programs can identify it as not standard CC. Like CCEmuRedux changed the _HOST variable in its latest version to include details about the CCEmuRedux version. Now, as you are advertising this as working with any version of CC and cannot throw it in with _HOST (as it hasn't been around long), I would suggest a new _G variable.

Edited by Selim, 21 January 2016 - 11:42 PM.


#18 CoderPuppy

  • Members
  • 121 posts

Posted 22 January 2016 - 07:46 AM

I've pushed a bunch of updates including:
  • Add the HTTP API (probably buggy)
  • Add fs.find
  • Fix LuaJIT compat
  • Use terminfo for keybindings (should fix Admicos's problem with backspace)
  • Fix reading from files
  • Fix term.clearLine
  • Add _HOST, set to 'termu'

EDIT: and a hotfix for fs.find erroring when it doesn't find matches in a location

Edited by CoderPuppy, 22 January 2016 - 07:49 AM.


#19 Selim

  • Members
  • 189 posts
  • LocationHiding in Online Storage

Posted 22 January 2016 - 06:28 PM

Ok, now I have
lua: cc-emu/emu.lua:377: attempt to index global 'bit' (a nil value)
stack traceback:
        cc-emu/emu.lua:377: in function 'emu'
        cc-emu/cli.lua:16: in main chunk
        [C]: in ?


#20 CoderPuppy

  • Members
  • 121 posts

Posted 22 January 2016 - 11:56 PM

View PostSelim, on 22 January 2016 - 06:28 PM, said:

Ok, now I have
lua: cc-emu/emu.lua:377: attempt to index global 'bit' (a nil value)
stack traceback:
        cc-emu/emu.lua:377: in function 'emu'
        cc-emu/cli.lua:16: in main chunk
        [C]: in ?
Just pushed an update to fix that (I should test stuff that I say is supported).





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users