Jump to content




Cobalt - a callback wrapper for ComputerCraft


18 replies to this topic

Poll: Cobalt Survey

Have you found Cobalt useful?

You cannot see the results of the poll until you have voted. Please login and cast your vote to see the results of this poll.

Have you found Cobalt easy to use?

You cannot see the results of the poll until you have voted. Please login and cast your vote to see the results of this poll.

Do you plan on using Cobalt in your projects

You cannot see the results of the poll until you have voted. Please login and cast your vote to see the results of this poll.
Vote Guests cannot vote

#1 ebernerd

  • Members
  • 262 posts
  • LocationBoston, MA

Posted 01 July 2016 - 04:45 AM

Posted Image


If you're looking for Cobalt-UI, the UI lib included with Cobalt, check it out in APIs and Utilities!


HEY! LISTEN! You should read the documentation so you know what you're doing!

COBALT NOW HAS A DISCORD! https://discord.gg/ZdhMJJ5


Run the installer! pastebin run h5h4fm3t

If you're feeling adventurous, pastebin run h5h4fm3t beta to get the beta version!

The installer prompts you to install other packages, such as Cobalt-UI. You also need HTTP and/or HTTPS enabled. If not, download the ZIP from github.

Cobalt aims to make programming in ComputerCraft easier and more centralized. If you've ever programmed in Love2d you will recognize and understand how this works. Rather than having ComputerCraft be event based, and have sprawling programs, Cobalt wraps that into a callback form. This project was originally for CCJam 2016!

If you already have Cobalt installed (and have HTTP/HTTPS enabled), type cobalt version to get a version check. If it reports that you are out of date, type cobalt update.

Cobalt's installer is also available on DannySMC's AppStore!

Example:
Spoiler

Another example (PONG!)
Spoiler

Since Cobalt is callback based, rather than event based, code is much simpler and more compact. For more (and I mean MUCH more) information, check out the documentation.

The current version is 1.1_3, and most of the coolness and effort has gone into Cobalt-UI. You should give it a spin!



This is my first project on CC since LimeFyre 2. I think I've stepped up the quality and stuff like that. If you have things you'd like to see, post it here!

Edited by CompuTech, 26 August 2017 - 04:29 AM.


#2 クデル

  • Members
  • 349 posts

Posted 01 July 2016 - 10:56 AM

I didn't notice this at first, but it is actually rather nice to use, +1. :)

#3 CrazedProgrammer

  • Members
  • 495 posts
  • LocationWageningen, The Netherlands

Posted 01 July 2016 - 01:10 PM

Very nice, good job!
You will get a good position on the CCJam2016 ranks :)

#4 ReBraLaCC

  • Members
  • 100 posts
  • LocationSublime Text 2

Posted 07 July 2016 - 09:37 PM

damn, well made! This looks a lot like Löve as far as graphics go ;)

#5 ebernerd

  • Members
  • 262 posts
  • LocationBoston, MA

Posted 07 July 2016 - 10:22 PM

View PostReBraLaCC, on 07 July 2016 - 09:37 PM, said:

damn, well made! This looks a lot like Löve as far as graphics go ;)

Thanks! The next version acutally moves away from paintutils and draws to a surface (from CrazedProgrammer's Surface API) rather than to term. It works a million times better, and you can write software that runs at like 120fps with no screen tear.

#6 _strx

  • Members
  • 58 posts

Posted 18 July 2016 - 11:56 PM

View PostCompuTech, on 07 July 2016 - 10:22 PM, said:

View PostReBraLaCC, on 07 July 2016 - 09:37 PM, said:

damn, well made! This looks a lot like Löve as far as graphics go ;)

Thanks! The next version acutally moves away from paintutils and draws to a surface (from CrazedProgrammer's Surface API) rather than to term. It works a million times better, and you can write software that runs at like 120fps with no screen tear.

1) The max FPS in ComputerCraft is 20.

2) "no screen tear" can easily be done by calling
term.current().setVisible(false);
before rendering and then
term.current().setVisible(true);
after it renders.

#7 ebernerd

  • Members
  • 262 posts
  • LocationBoston, MA

Posted 19 July 2016 - 12:04 AM

View PostPixelFox1, on 18 July 2016 - 11:56 PM, said:

View PostCompuTech, on 07 July 2016 - 10:22 PM, said:

View PostReBraLaCC, on 07 July 2016 - 09:37 PM, said:

damn, well made! This looks a lot like Löve as far as graphics go ;)

Thanks! The next version acutally moves away from paintutils and draws to a surface (from CrazedProgrammer's Surface API) rather than to term. It works a million times better, and you can write software that runs at like 120fps with no screen tear.

1) The max FPS in ComputerCraft is 20.

2) "no screen tear" can easily be done by calling
term.current().setVisible(false);
before rendering and then
term.current().setVisible(true);
after it renders.

However, I don't know if that fixes the issues of screen flicker. Cobalt's new graphics system (nyi since CCJam judging is still active) fixes that as well.

#8 _strx

  • Members
  • 58 posts

Posted 19 July 2016 - 02:39 AM

View PostCompuTech, on 19 July 2016 - 12:04 AM, said:

View PostPixelFox1, on 18 July 2016 - 11:56 PM, said:

View PostCompuTech, on 07 July 2016 - 10:22 PM, said:

View PostReBraLaCC, on 07 July 2016 - 09:37 PM, said:

damn, well made! This looks a lot like Löve as far as graphics go ;)

Thanks! The next version acutally moves away from paintutils and draws to a surface (from CrazedProgrammer's Surface API) rather than to term. It works a million times better, and you can write software that runs at like 120fps with no screen tear.

1) The max FPS in ComputerCraft is 20.

2) "no screen tear" can easily be done by calling
term.current().setVisible(false);
before rendering and then
term.current().setVisible(true);
after it renders.

However, I don't know if that fixes the issues of screen flicker. Cobalt's new graphics system (nyi since CCJam judging is still active) fixes that as well.

it fixes screen flicker.

#9 The Logo Maker

  • Members
  • 83 posts
  • Locationyes

Posted 19 July 2016 - 10:00 AM

View PostPixelFox1, on 18 July 2016 - 11:56 PM, said:

1) The max FPS in ComputerCraft is 20.

this the max Frame Per Second that Computer Craft can display. it can render a much higher even though it will not display but all of the program code that render will still run

#10 Emma

  • Members
  • 216 posts
  • Locationtmpim

Posted 19 July 2016 - 04:55 PM

From what I understand, computercraft Lua code can run and perform render operations in the sense of storing information in a buffer as fast as it can (up to 120 fps even (and beyond)) however due to the minecraft tickrate being 20, the computer's monitor can only refresh 20 times a second, which brings up the topic of things like vsync. Like, do you really even need 120fps if it only can ever be rendered at 20fps. At that point we're just wasting cpu power that could be spent to doing more usefull things, like performing physics calculations or whatever.

#11 MKlegoman357

  • Members
  • 1,170 posts
  • LocationKaunas, Lithuania

Posted 19 July 2016 - 05:41 PM

View PostPixelFox1, on 18 July 2016 - 11:56 PM, said:

1) The max FPS in ComputerCraft is 20.

View Postepicidity, on 19 July 2016 - 10:00 AM, said:

...it can render a much higher even though it will not display but all of the program code that render will still run

View PostIncinirate, on 19 July 2016 - 04:55 PM, said:

...up to 120 fps even (and beyond)) however due to the minecraft tickrate being 20, the computer's monitor can only refresh 20 times a second, which brings up the topic of things like vsync. Like, do you really even need 120fps if it only can ever be rendered at 20fps...

False. The computer can render as fast as the server (the actual real-life computer) can process the statements and the computer's screen/monitor will refresh as fast as possible. Probably the only point where tickrate matters are timers (which accepts 0.05 as the lowest possible value). Actually, that's where the "myth" comes from: you cannot make a timer lower than 0.05 thus getting only 20FPS. But you can kind of overcome this issue by constantly yielding and pulling events until the computer waits the amount of time you want. Although, this solution isn't an ideal one anyway.

#12 Emma

  • Members
  • 216 posts
  • Locationtmpim

Posted 20 July 2016 - 12:31 AM

View PostMKlegoman357, on 19 July 2016 - 05:41 PM, said:

View PostPixelFox1, on 18 July 2016 - 11:56 PM, said:

1) The max FPS in ComputerCraft is 20.

View Postepicidity, on 19 July 2016 - 10:00 AM, said:

...it can render a much higher even though it will not display but all of the program code that render will still run

View PostIncinirate, on 19 July 2016 - 04:55 PM, said:

...up to 120 fps even (and beyond)) however due to the minecraft tickrate being 20, the computer's monitor can only refresh 20 times a second, which brings up the topic of things like vsync. Like, do you really even need 120fps if it only can ever be rendered at 20fps...

False. The computer can render as fast as the server (the actual real-life computer) can process the statements and the computer's screen/monitor will refresh as fast as possible. Probably the only point where tickrate matters are timers (which accepts 0.05 as the lowest possible value). Actually, that's where the "myth" comes from: you cannot make a timer lower than 0.05 thus getting only 20FPS. But you can kind of overcome this issue by constantly yielding and pulling events until the computer waits the amount of time you want. Although, this solution isn't an ideal one anyway.

This is true... until you realize that the server only sends packets X times a second, so even if on the server (real-life) it updates and refreshes faster, the client will only get updates X times a second. (From what I've seen X is usually around 30)

#13 MKlegoman357

  • Members
  • 1,170 posts
  • LocationKaunas, Lithuania

Posted 20 July 2016 - 07:04 AM

View PostIncinirate, on 20 July 2016 - 12:31 AM, said:

This is true... until you realize that the server only sends packets X times a second, so even if on the server (real-life) it updates and refreshes faster, the client will only get updates X times a second. (From what I've seen X is usually around 30)

If this were true writing each pixel individually would take you about 32 seconds, which is not true at all.

Oh, misinterpreted that. Yes, there's a limit to how fast the server can send packets.

Edited by MKlegoman357, 20 July 2016 - 07:08 AM.


#14 PossieTV

  • Members
  • 62 posts

Posted 28 July 2016 - 03:05 AM

Amazing program! It makes it super easy for the graphically challenged (which I am) and lazy (which I also am) to focus on functionality instead of nice graphics. With that said, there are a few notes that I have.

1.) The key event doesn't support the fn key and the command key, not on my mac anyway. It was an easy fix though. I just added a check in the event handling part of the cobalt program.
2.) It would be nice to have each object have a "visible" attribute that would allow me to hide and show an object without changing cobalt.state
3.) While the graphics are impressive, it is really only useful for creating basic things like menus and log in screens. Now don't get me wrong, those things are useful, it would just be nice for it to be able to handle more challenging graphical problems. For example, if you could remove buttons from a panel, or draw them directly to the screen.

I really do like the callback feature though. I think that's the best thing about cobalt. Not only does it makes graphics super easy, it makes the actual programming easier too. It's less typing and less headaches for me XD. Overall, well done. I don't download programs from the forums that often, let alone use them, let alone take the time to give feedback (I usually prefer to build all of my own tools). So again, good job!

#15 ebernerd

  • Members
  • 262 posts
  • LocationBoston, MA

Posted 07 August 2016 - 04:30 PM

View PostPossieTV, on 28 July 2016 - 03:05 AM, said:

--snip--

Thanks so much! I will add a visible feature - I actually think they have that value already, just isn't utilized.

Also, I'm here to let you know that...
COBALT v1.1_0 has been released!
This update fixes many of the issues present in the original release, as well as add many new features. If you're looking for the updates to Cobalt-UI, go to the Cobalt-UI thread.

ADDITIONS
  • Ported to CrazedProgammer's Surface API. All drawing is handled by "cobalt.application.view" and completely eliminates screen flicker
  • New module: cobalt.mouse
  • cobalt.mouse.isDown(button)
  • cobalt.math.clamp(value, lower, upper)
MODIFICATIONS
  • cobalt.graphics.center now wraps text, so no need for \n characters to make sure it fits.
  • cobalt.keyboard.isDown(key), if key is left empty, returns true or false if ANY key is down.
REMOVALS
  • cobalt.graphics.centerInArea()


Happy coding! Any issues you have, please put them in the github issue tracker.

#16 ebernerd

  • Members
  • 262 posts
  • LocationBoston, MA

Posted 14 August 2016 - 08:03 AM

I am currently working on an update. Are there any features you guys would like to see in Cobalt or Cobalt-UI? Let me know!

#17 ebernerd

  • Members
  • 262 posts
  • LocationBoston, MA

Posted 15 August 2016 - 06:30 PM

Cobalt v1.1_3 is out!

This update provides bugfixes and a new feature - custom error handling. In v1.1_4 (or whatever the next major update is) it will be customizeable, but if you encounter an error within a cobalt function (i.e., nothing outside of a callback) will save the error to the .err-logs/ directory.

If you have cobalt installed, run "cobalt update" to update!

Happy coding! If you have any issues, please put them on the github issue tracker.

#18 ebernerd

  • Members
  • 262 posts
  • LocationBoston, MA

Posted 04 September 2016 - 03:58 AM

Currently working on a new version, which is coming along pretty well. Are there any features you'd like to see?

#19 ebernerd

  • Members
  • 262 posts
  • LocationBoston, MA

Posted 25 September 2016 - 08:57 PM

Cobalt now has a discord! https://discord.gg/ZdhMJJ5

You can chat about the programs you make with it, get help from me directly, or suggest features.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users