Jump to content




Blue Shiny Rocks - Lua emulation and package manager


26 replies to this topic

#1 SquidDev

    Frickin' laser beams | Resident Necromancer

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

Posted 23 February 2016 - 05:36 PM

The ComputerCraft community is great, and has developed some incredible programs. However there is another source of awesome Lua programs called LuaRocks, developed to run on a normal implementation of Lua. Blue Shiny Rocks aims to bring allow CC to utilise these libraries and programs. It features a pretty decent emulation of a normal Lua 5.1 environment and a lightweight implementation of LuaRocks' package manager.

Firstly: this is never going to be perfect. The string bug, no debug library and lack of a C compiler means that not all packages will be downloadable and usable. Nor is the emulated environment going to be 100% correct: there is a list of problems on the repo. However, it is possible to get many packages working off the shelf. Those which don't can be modified using BSRocks' built-in patching system.


Features
  • Lua 5.1 environment with packages, require
  • ANSI colour support
  • Package manager (and dependencies obviously)
  • A really nice REPL.
  • Pretty cool fuzzy matching on command and package names
Basic usage (thanks to recgif)
Posted Image

More screenshots
Spoiler

Getting Started
  • First install from the Gist: pastebin run LYAxmSby get 6ced21eb437a776444aacef4d597c0f7/bsrocks.min.lua bsrocks
  • Look for a package: bsrocks search colours
  • Check it is the one you want: bsrocks desc ansicolors
  • Install it: bsrocks install ansicolors
  • Use it: bsrocks repl or bsrocks exec myFile.lua
You can also run bsrocks help for more information.

Helping
As I mentioned earlier, more advanced packages will require changes to run correctly. My next job is to start writing these, but if you want to help, feel free to check out this page. The main GitHub lives here.

Edited by SquidDev, 18 October 2016 - 12:11 AM.


#2 HDeffo

  • Members
  • 214 posts

Posted 26 February 2016 - 11:21 PM

This is amazing! :o nice job squid! I don't usually comment on program but this is just simply brilliant :D

#3 SquidDev

    Frickin' laser beams | Resident Necromancer

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

Posted 27 February 2016 - 08:21 AM

View PostHDeffo, on 26 February 2016 - 11:21 PM, said:

This is amazing! :o nice job squid! I don't usually comment on program but this is just simply brilliant :D

Thanks! I'm hoping to get another release out today with some bug fixes/enhancements. I'm currently working on a Penlight port, which is much easier than my previous one :) and should enable several other packages to be run: namely busted and LDoc.

#4 SquidDev

    Frickin' laser beams | Resident Necromancer

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

Posted 27 February 2016 - 11:08 AM

So. Progress! I've successfully ported LuaFileSystem and Penlight to run under BSRocks. This has two benefits. Firstly these packages have quite a lot of dependencies, and so this allows many packages to be installed without further work. Secondly its allowed me to find lots of bugs and make the whole patching process easier.

Major changes
  • Patchspecs use the manifest format too. This means downloads should be quicker.
  • Add better detection of issues (such as C files, undownloadable files).
  • Completion provider
  • Lots and lots and lots of bug fixes.
  • Add LuaFileSystem and Penlight.
I'm actually surprised how easy porting Penlight was. I've done it before and that took much longer. There are still some issues, but these lie in LuaJ not in BSRocks.

Edited by SquidDev, 27 February 2016 - 11:12 AM.


#5 Quartz101

  • Members
  • 141 posts
  • Location/dev/nvme0n1

Posted 27 February 2016 - 01:57 PM

I'm impressed!

Also, heres an idea, not relating to this. Create the C language in MC, but it can use CC stuff, and some normal C stuff, too.

#6 SquidDev

    Frickin' laser beams | Resident Necromancer

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

Posted 27 February 2016 - 02:12 PM

View PostQuartz101, on 27 February 2016 - 01:57 PM, said:

Also, heres an idea, not relating to this. Create the C language in MC, but it can use CC stuff, and some normal C stuff, too.

I think the closest you could get would be Clue, or porting Emscripten to Lua. It would be a lot of work and not something I'm really prepared to do :).

#7 Selim

  • Members
  • 189 posts
  • LocationHiding in Online Storage

Posted 27 February 2016 - 02:23 PM

This is simply amazing! I cannot begin to imagine the possibilities now available.

#8 FUNCTION MAN!

  • Members
  • 292 posts

Posted 27 February 2016 - 02:31 PM

Porting Emscripten would be harder than just creating a straight-up LLVM IR to Lua compiler.

#9 SquidDev

    Frickin' laser beams | Resident Necromancer

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

Posted 27 February 2016 - 02:41 PM

View PostFUNCTION MAN!, on 27 February 2016 - 02:31 PM, said:

Porting Emscripten would be harder than just creating a straight-up LLVM IR to Lua compiler.
Just read through what I said. I actually meant to generate Lua, rather than rewriting Emscripten in Lua. That way you would get all their optimisations/analysis. However Javascript is a very different beast to Lua, so I'm not sure how much would be even be applicable.

#10 FUNCTION MAN!

  • Members
  • 292 posts

Posted 27 February 2016 - 04:49 PM

View PostSquidDev, on 27 February 2016 - 02:41 PM, said:

View PostFUNCTION MAN!, on 27 February 2016 - 02:31 PM, said:

Porting Emscripten would be harder than just creating a straight-up LLVM IR to Lua compiler.
Just read through what I said. I actually meant to generate Lua, rather than rewriting Emscripten in Lua. That way you would get all their optimisations/analysis. However Javascript is a very different beast to Lua, so I'm not sure how much would be even be applicable.

I know what you meant.

Edited by FUNCTION MAN!, 27 February 2016 - 04:54 PM.


#11 Justy

  • Members
  • 210 posts
  • LocationCLGD

Posted 27 February 2016 - 08:01 PM

This is one of the best projects I have ever seen. Nice work!

#12 SquidDev

    Frickin' laser beams | Resident Necromancer

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

Posted 27 February 2016 - 08:53 PM

Thanks to everyone for their support. I've managed to get busted working with 3 simple changes! I know I'm beginning to sound like a broken record but this was so much easier than my original busted port I did a way back. Busted was one of my 2 targets to port, so its great that this was so easy!

#13 HDeffo

  • Members
  • 214 posts

Posted 28 February 2016 - 06:51 AM

My biggest question is will the LuaRocks socket API work for computercraft with this?

#14 Justy

  • Members
  • 210 posts
  • LocationCLGD

Posted 28 February 2016 - 07:27 AM

View PostHDeffo, on 28 February 2016 - 06:51 AM, said:

My biggest question is will the LuaRocks socket API work for computercraft with this?
Unfortunately no. As SquidDev said, we cannot properly use C libraries in ComputerCraft, so as a result we cannot use all of the packages that rely on C libraries.

#15 SquidDev

    Frickin' laser beams | Resident Necromancer

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

Posted 28 February 2016 - 10:52 AM

View PostHDeffo, on 28 February 2016 - 06:51 AM, said:

My biggest question is will the LuaRocks socket API work for computercraft with this?
As justync7 said: it isn't really possible. CCTweaks adds a TCP socket API, so I could build a wrapper about that. However CCTweaks isn't really popular/wide spread enough that I feel it would be useful. Just out of interest: what were you planning on doing with it?

#16 HDeffo

  • Members
  • 214 posts

Posted 28 February 2016 - 04:42 PM

I have a private cloud based OS with full data back up support and interserver remote peripherals (can wrap peripherals from another computer also on the same os). The problem is with the http limit it requires either a TON of requests at least every few ticks or some complicated hackish roundabout way of handling http. I remember one API that was out a while ago that managed to spoof CC http requests into sockets sort of but it was so complex I was honestly just scared to use it since if it didn't work I wouldn't have been able to fix it.

#17 H4X0RZ

  • Members
  • 1,315 posts
  • LocationGermany

Posted 28 February 2016 - 10:48 PM

View PostHDeffo, on 28 February 2016 - 04:42 PM, said:

I have a private cloud based OS with full data back up support and interserver remote peripherals (can wrap peripherals from another computer also on the same os). The problem is with the http limit it requires either a TON of requests at least every few ticks or some complicated hackish roundabout way of handling http. I remember one API that was out a while ago that managed to spoof CC http requests into sockets sort of but it was so complex I was honestly just scared to use it since if it didn't work I wouldn't have been able to fix it.

I believe the load was reduced thanks to the server, not the client. The client issued an async request and the server didn't complete it's response until something happened. That would limit the amount of requests unless CC has a timeout for requests.

#18 HDeffo

  • Members
  • 214 posts

Posted 28 February 2016 - 11:02 PM

wait CC doesn't have a timeout for requests :o holy carp thank you H4X0RZ that helps a ton! I may just make my os public in that case if I can confirm security and such

#19 FUNCTION MAN!

  • Members
  • 292 posts

Posted 07 March 2016 - 02:19 PM

The fact that we need a lua emulator within Lua is quite depressing.

#20 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 07 March 2016 - 04:28 PM

View PostFUNCTION MAN!, on 07 March 2016 - 02:19 PM, said:

The fact that we need a lua emulator within Lua is quite depressing.

What, why?

Also, this system is indeed awesome. Have been following it for some time, and it is pretty impressive.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users