ComputerCraft GK's Base Controlled from a Web UI!

Discussion in 'Programming' started by gknova61, 29 June 2014.

  1. gknova61

    gknova61 Farbes Lover

    Joined:
    17 March 2012
    Messages:
    1.238
    Likes Received:
    350
    Hey guys, so I just got back form a break and brought some goodies with me! :)

    Since I've been back, I've been mining, progressing through the new mods we got, and best of all, playing with ComputerCraft! I've got sooo many ideas since the HTTP API was finally enabled for next reset that everyone will be able to benefit off of but I'm starting out with a full base controlled from a web interface coded with the backend coded from scratch. I've also been working on things on the side like a bandwidth-saving update system, a better error handler, and so on. Just things that I found myself making to smooth this (and future) projects out. I'm also borrowing a few lua APIs from the wonderful CC Forum and when I release this, I'll give credit where due. For the past few days, I've mainly been working on the backend for this but I just started frontend pages today! Here's a look:
    [​IMG]

    Since I'll need a place to track where I'm at, and some motivation to not abandon this project like I normally would, I'll be posting here as I progress so stay tuned!
     
  2. Penagwin

    Penagwin Linux Servers are better then windows!

    Joined:
    10 February 2013
    Messages:
    114
    Likes Received:
    45
    What server? And I am assuming its also the server communicating with Alice(Computer Craft)?
     
  3. kerjava

    kerjava husky mix

    Joined:
    22 September 2012
    Messages:
    158
    Likes Received:
    25
    Sounds cool
     
  4. Siioh

    Siioh If you can read this, you're too far

    Joined:
    29 May 2013
    Messages:
    333
    Likes Received:
    118
    I want to see how this plays out...looks very interesting but from my knowledge will have quite a few problems to come across.
     
  5. LeiserGeist

    LeiserGeist Gamer, Software Developer

    Joined:
    26 October 2012
    Messages:
    479
    Likes Received:
    116
    Well that's pretty cool. Personally I find it easier to just carry around a pocket computer now with pretty much the same layout. I did so with my reactor and it turned out quite well...
    But this is a pretty cool new thing that's possible, and I'm sure there's tons of potential.
     
  6. gknova61

    gknova61 Farbes Lover

    Joined:
    17 March 2012
    Messages:
    1.238
    Likes Received:
    350
    The web server? Everything is on my local machine for development but I'll be moving it to a dedi when it's production-ready.
    I never actually knew about the Pocket Computers until now. They look pretty damn nice, and once I'm done with the Web frontend, It won't be hard at all to make a frontend for the Pocket Computers :D

    More or less, here's what I have so far in the base:
    [​IMG]
    To save server resources and becuase I wanted a more centralized command structure, the only computer that'll be accessing the internet is the router. Every x seconds, It'll pull a JSON array from the backend that'll give it 3 entries for each client: type (string), additional info (string), and current status (bit). The router will then update the clients over LAN. Basically, all the clients are doing is turining modem messages into redstone signals. But, theoretically, they can do anything a normal computer wrapping peripherals can. Right now, it's just the web frontend that's updating this but I've written the backend in such a way that implementing any frontend would be cake!
     
  7. LeiserGeist

    LeiserGeist Gamer, Software Developer

    Joined:
    26 October 2012
    Messages:
    479
    Likes Received:
    116
    I'd do that with just one computer to save space, resources, and possible frustration.

    As for pocket computers, they're quite amazing. When I get ingame I'll screenshot what I had for my reactor controller. And upload the code if anyone cares.

    Edit: I don't want to hijack your thread, so I'll post them in a new one :I
     
  8. gknova61

    gknova61 Farbes Lover

    Joined:
    17 March 2012
    Messages:
    1.238
    Likes Received:
    350
    Status update for 6/29/14 ~14:30 (GMT-10):
    -Reworked alot of the backend-side of things which should give a little performance boost, easier maintenance, and auditing.
    -Added more things for the game to report on. I'll say more about this later.

    Here's some info on my Repository-like Public File Updater (Name WIP) which I'll be releasing soon:
    -Compares hashes of files to save resources
    -Easy way of telling you what files need updating
    -Easy way of updating the files

    *Do note that this is only for files that belong in the public domain. There is no security measures for the files whatsoever because they're meant to be public.

    What would you do with one computer? Fetch data from the web and redstone control everything?

    P.S. Lone Survivor = 10/10!!!!
     
  9. LeiserGeist

    LeiserGeist Gamer, Software Developer

    Joined:
    26 October 2012
    Messages:
    479
    Likes Received:
    116
  10. gknova61

    gknova61 Farbes Lover

    Joined:
    17 March 2012
    Messages:
    1.238
    Likes Received:
    350
    I try to stay away from the parallels API. It's ugly to me, has no flexibility, and no doubt it takes a performance hit compared to one loop. If there was no other way, I'd use the coroutine API. Plus, doing it from one computer adds limits and some complexity. For example, if you're using red alloy cable, you suddenly only have 6 outputs you can control separately. Even with bundled cable, it would be a whole fiasco with wiring. In my mind, sending a message to turn on the AE system is much simpler. My only wish is that we had a mod like RedIO, but it's understandable that we don't since CC is more of a niche mod.

    Your reactor setup is damn cool, dude. Did you use an API to make the GUI buttons, and stuff? I've been trying to find one since I'm not great with that kind of stuff in lua.
     
  11. Tonius

    Tonius 555 Eternal Server Error

    Joined:
    30 January 2012
    Messages:
    480
    Likes Received:
    392
    RedIO is not updated for the current ComputerCraft API.
     
  12. Penagwin

    Penagwin Linux Servers are better then windows!

    Joined:
    10 February 2013
    Messages:
    114
    Likes Received:
    45
    I meant what are you using for the backend? Nodejs, Python(Flask, Django, Pyromid), ruby, php, etc?
     
  13. LeiserGeist

    LeiserGeist Gamer, Software Developer

    Joined:
    26 October 2012
    Messages:
    479
    Likes Received:
    116
    I wrote my own code, taking reference from existing programs on the methods they used for automating control rod levels and extending it to be more precise. Buttons are easy to make on a small scale.

    The only problem I seem to have is that computers don't start up unless you open them when loaded.. which seems unavoidable.
    EDIT: Just remembered autonomous activators... hmm....
    EDIT2: Autonomous activators turn on computers! Amazing
     
  14. gknova61

    gknova61 Farbes Lover

    Joined:
    17 March 2012
    Messages:
    1.238
    Likes Received:
    350
    Just checking in for the few days I missed :p. Unfortunately, not much has been done since the last status update becuase I'm prepping for a week vacation in Sin City but when I get back, it'll be full steam ahead!

    Edit: I am going to try to release my Repo API today but no promises. If all goes well, I'll have the (commented) PHP file, and the lua API up for download. I can even provide hosting for it on a small web server if you want.

    MySQL coupled with PHP. MyrddinE did suggest that I switch to Python because PHP is a bad language in general, and while I've bought an ebook and did some research on Python, I've decided to just strengthen my skills with PHP instead of learn a new language mainly because of the marketability with PHP. Although Python is a better language functionally, the fact is that PHP is more popular so it's easy to get help, and there's more jobs postings for PHP.
     
  15. Penagwin

    Penagwin Linux Servers are better then windows!

    Joined:
    10 February 2013
    Messages:
    114
    Likes Received:
    45
    Mysql? Has that not been deprecated? I wouldn't know for sure, because I don't use PHP(Were Mysql was most used). I say MONGO FTW! I don't quite understand PHP, it only runs when you visit the page or something like that? The server doesn't just run the program and wait patiently?
     
  16. kerjava

    kerjava husky mix

    Joined:
    22 September 2012
    Messages:
    158
    Likes Received:
    25
    php is server side script so technically it could be running all the time waiting but to be honest idk but id say it depends on how it is coded