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

Standalone - Turn Your ComputerCraft Lua Programs into Standalone Java Applications!

Started by GravityScore, 04 December 2012 - 03:30 PM
GravityScore #1
Posted 04 December 2012 - 04:30 PM
Hey all.

My lasted project I'm currently developing is a Java application that emulates computercraft, and turns your lua programs into standalone java applications for you to distribute across any real life OSes that support Java! (Any suggestions for a name would be welcome! - currently thinking about "Standalone")

How I plan for this to work is to have your own downloadable and executable jar file, then for you to be able to load your Lua program into it via loading it from a file or supplying a download/Pastebin link. You can then choose for it to behave like a normal computer, where you are able to download more files and store them in the computer just like in CCEmu and CC in Minecraft, or you can lock the application into booting this program up on startup and not being able to exit it (like a real application). Control-T (not in the locked application computers), Control-R and Control-S will all work, and I will re-create all CC APIs, and add more to them if I feel like it.

I also plan to exclude all peripherals from this application - meaning no disk drives, printers, or turtles (or any associated APIs), but I will implement Rednet. Each open instance of your Lua program in this application will be assigned an ID when it opens its Rednet modem, and will be able to communicate to all other instances of your application that exist and have Rednet open, using that Application's ID. I've been looking around for solutions to this and I found a useful technology called AMQP (Automatic Message Queuing Protocol, or something :P/>). I used this in Python to develop a simple chat program (like Skype with no voice calling) - and there seems to be a Java implementation of the library. I'll need to set up a server, and I will see if there is any free hosting around that can do it - I don't particularly want to host it myself :P/> (suggestions for hosting services are very welcome!). If anyone has any better suggestions, PLEASE leave a comment. I'll probably implement this Rednet system in the second version.

I was also thinking to add some form of download center, so people are able to post their lua applications to me, and any people with the application can see all posted applications and download ones to their computer (like an app store). I was thinking to host this on Dropbox, but again - I welcome any better suggestions!

If you have anything more you would like to see in this, please drop me a PM or leave comment below! I welcome more suggestions!

I currently have nothing for you to download, which is why this is in General and not Programs.

If I've derped anything up in this post, please tell me!

Added/Removed Features in APIs
SpoilerOk, so looking though the CC API documentation, I will not be implementing many functions/APIs due to the lack of peripheral implementation (this is not an emulator, but a tool to allow you to turn your lua apps into standalone applications).

Bit API - I will fully implement this
Colors API - Fully implement
Coroutine API - Will fully implement
Disk API - Not implementing at all (due to no peripherals)
FS API - Fully implement
GPS API - Nope
Help API - Who actually uses this? If many people do, I will implement, but currently I can't be bothered
HTTP API - Fully
IO API - Fully
Math API - Fully
OS API - Fully, with added os.exitApp(), which will quit the Java app, and removal of os.getComputerID(), as the ID will be used in Rednet only
Paint Utils - Fully
Parallels - Definitely, but I have no idea how (must look though it - help would be appreciated!)
Printer API - Nope
Rednet API - Everything, but the rednet.open(side) will not need to take a side parameter (same with rednet.close), and addition of rednet.getID() for getting the application's ID. I may also implement Rednet channels (something major CC doesn't have)…
Redstone API - Nope
Shell API - Everything
String API - Everything
Table API - Everything
Term API - Everything, with adding term.getCharAtPos(x, y), term.getCursorBlink(), and removal of redirect and restore (due to no peripherals)
Text Utils API - Everything
Turtle API - Nope
Vector API - Nope (due to no GPS API)


Progress:
Completed so far:
- Terminal window can draw text from calls made in Java
- Terminal window is able to be drawn to from Lua files
- LuaJ can execute Lua files
- FS, IO, OS, Math, String, Coroutine, and Table Libraries Implemented in Java (easy to transfer into Lua)

Need to do:
- Complete the rest of the libraries
- Add libraries into Lua
- Complete file system sandbox
- Download Center
- Loading of files into the application
- Startup program locking
- Probably more
Dlcruz129 #2
Posted 04 December 2012 - 04:36 PM
Why no paintutils? Other than that, sounds cool and good luck!
GravityScore #3
Posted 04 December 2012 - 04:37 PM
Why no paintutils? Other than that, sounds cool and good luck!

I didn't think people used it :P/> (at least, I never have)

I can include if you want. In fact, I probably will now. :P/>
Dlcruz129 #4
Posted 04 December 2012 - 05:14 PM
Why no paintutils? Other than that, sounds cool and good luck!

I didn't think people used it :P/>/> (at least, I never have)

I can include if you want. In fact, I probably will now. :P/>/>

I definitely use paintutils. I love making splash screens.
Sammich Lord #5
Posted 05 December 2012 - 10:19 AM
Why not include the OpenGL lib that CCGPU uses? It will be much easier to code then having to draw each and every pixel with code.
billysback #6
Posted 05 December 2012 - 11:20 AM
You could just draw images using in built java APIs, it seems like a better idea to add in a AWT API to let your programs create geometric shapes and draw them on-screen using Images, Buffered Images etc. Obviously this would be ridiculous amounts of work but it would be awesome :P/>
GravityScore #7
Posted 05 December 2012 - 02:14 PM
Why not include the OpenGL lib that CCGPU uses? It will be much easier to code then having to draw each and every pixel with code.

I'm writing this using LWJGL (using the Slick 2D library, which I am very fond of), which makes my life so much easier. The only down side to not using AWT/Swing is that LWJGL requires natives to run, and on the computer I'm using now, I have to specify the path to them via VM arguments. This will probably force me into writing a launcher of sorts (maybe in Python? or maybe using Swing….). But writing a launcher will be good because it will allow me to implement autoupdating, and automatic downloading of any required files :D/>
BigSHinyToys #8
Posted 05 December 2012 - 10:51 PM
@GravityScore
will computers have access to the full file system of your computer or work out of one folder (using it as root) like they do now? This is a great idea and I will be keeping an eye on this closely.
GravityScore #9
Posted 05 December 2012 - 10:59 PM
@GravityScore
will computers have access to the full file system of your computer or work out of one folder (using it as root) like they do now? This is a great idea and I will be keeping an eye on this closely.

I was planning for them to be sandboxed (into a single directory hidden in the user's library). I think it is a bit dangerous to give them full filesystem access…
Dlcruz129 #10
Posted 06 December 2012 - 06:32 PM
Why not include the OpenGL lib that CCGPU uses? It will be much easier to code then having to draw each and every pixel with code.

I'm writing this using LWJGL (using the Slick 2D library, which I am very fond of), which makes my life so much easier. The only down side to not using AWT/Swing is that LWJGL requires natives to run, and on the computer I'm using now, I have to specify the path to them via VM arguments. This will probably force me into writing a launcher of sorts (maybe in Python? or maybe using Swing….). But writing a launcher will be good because it will allow me to implement autoupdating, and automatic downloading of any required files :D/>/>

JarSplice, google it. It compacts all your jars and natives into a runnable jar file, and has an option to make a .exe, .osx, and .whateverLinuxUses.
dissy #11
Posted 07 December 2012 - 12:26 AM
I was wondering what you had in mind for the application of standalone computer craft app-lets.
I realize anyone can only speak for themself, so this question isn't just for GravityScore but open to anyone.

The emulation aspects fully make sense, and in fact I heavily use CCemu as well as am looking forward to trying out this program when ready too. Simulations and emulators are so exceptionally handy in many ways, I assume I don't need to extole their virtues here ;}
The way I see it, the more competition in the emulation/simulation area, the better each program will get and the more fun features that might be available to us in the future.

I'm just personally having a hard time thinking up applications for stand alone apps.
I should say I'm not implying anything negative about the idea, or that it shouldn't be done!
But I assume you came up with the idea to solve a particular problem or desire, and was hoping you could share some of them (or for anyone else to share the ideas that came about when you first read about this project)

One of my first thoughts was that, at least until you impliment rednet modems, that without any other APIs one could just use a real Lua compiler for the host system to do something similar. In that case, ease of use is about all that came to mind, since it can be argued to be much easier to select a 'compile' menu option from the emulator you just tested your code in, than muck about with installing another Lua compiler.

I'm more just interested in hearing about other peoples ideas of how they might use this, to see if that gets my own creative juices flowing.

Thanks!
GravityScore #12
Posted 07 December 2012 - 02:35 AM
The idea for this came about after reading this thread, about how one person was concerned that their lua skills were almost useless in the real world, and could only be used in ComputerCraft. I agreed with what the OP said, saying that people who only learn lua for ComputerCraft do not have the opportunity to develop games/apps for the real world of computers.

I thought I would make this program with the goal of not trying to make an emulator for people to test their code - that's already been done, I use it almost every time I write code for CC, and I think it's brilliant. The goal of this was to allow people the opportunity to release their lua apps into the real world though a Java application. This is the reason there is no peripherals, and the option to lock out the user from using the app as a CC computer.

I personally would love to see my Firewolf program come to life in this application! Especially if I am able to visit a website made by another person from across the other side of the world! Other programs I would love to see include the CCEmail, and I was possibly planning to add a full screen feature so people are able to make their own fully featured OSes for real computers! Although the possibilities are somewhat limited, I haven't had a real Java program to write in a while, so I thought I would give this a shot!

Hope this answers your questions!
BigSHinyToys #13
Posted 07 December 2012 - 03:40 AM
was concerned that their lua skills were almost useless in the real world, and could only be used in ComputerCraft
if you have the lua download from the site it comes with recompiled exe's that allow you to more or less easily make real world application. I haven't looked into it in full yet but it looks quite simple for someone that knows CC lua.
The goal of this was to allow people the opportunity to release their lua apps into the real world though a Java application
this is a very noble goal and me and many others will be happy to see you succeed.
I personally would love to see my Firewolf program come to life in this application!
That is a very nice application works well.
planning to add a full screen feature
it would be very nice to see my mouse file browser running on a full screen computer. This is a very good ideas and will allow some very cool application. The reason I asked before about whether it will have access to the main file system C:\ and other drives was to see how in a real world scenario mouse file browser would perform. I quite like some features of it that windows dose not have.
Mads #14
Posted 10 December 2012 - 07:28 AM
Why not just write an application in Lua?

Anyways, this looks cool.
1lann #15
Posted 11 December 2012 - 11:59 PM
Why not just write an application in Lua?

Anyways, this looks cool.
Lua's default API is pretty limited, especially interactivity wise and what is displayed. Also Macs and Windows computers don't come with Lua installed.
BigSHinyToys #16
Posted 12 December 2012 - 01:24 AM
Why not just write an application in Lua? Anyways, this looks cool.
Lua's default API is pretty limited, especially interactivity wise and what is displayed. Also Macs and Windows computers don't come with Lua installed.
http://code.google.com/p/luaforwindows/downloads/list

That link goes to a compiled compilation of apis that allows simple applications to be made from pure lua without having to know any other language.

I haven't tried it much but it seams like it could be very useful.
D3matt #17
Posted 12 December 2012 - 01:44 PM
… Why not just write an actual program? I don't see how this is useful beyond any other CC emulator.
1lann #18
Posted 12 December 2012 - 09:40 PM
In response to D3Matt:
I don't think everyone has a CC-Emu installed on their computer, therefore making the program useless if you want to share itwith others who don't want CC-Emu installed. With Standalone, people can just send the "wrapped" program to anyone and the only requirement for the other person is to have Java installed. It's like comparing Wine to Winebottler

In response to BigShinyToys:
Not sure, but isn't it required for the person running the script to have the libraries installed? So if you were to share it with someone would it still work if they didn't have the libraries installed?