Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
PwnagePineapple

OpenGlasses Push Notification Library [Updated! Bugfixes Galore and Multi-line Support!]

Recommended Posts

I have created a library for OpenGlasses that allows for sending push notifications. It can be installed using the following command:

pastebin get huJePEwB /lib/ognotify.lua

It (optionally) depends on another library that defines several color presets (one per Minecraft dye color) that must be installed using this command:

pastebin get vVB06vMj /lib/ogcolor.lua

The main library provides one function, used for (you guessed it) sending push notifications, the syntax of which is as follows:

ognotify.send(title,desc,timeout,bcolor,balpha,tcolor,talpha,dcolor,dalpha)

Each notification has three parts: the background rectangle (parameters prefixed with a b refer to this component), the title (related parameters are prefixed with a t), and the description (parameters are prefixed with a d).

The first two parameters are the text for the title and description. The third is the time in seconds for which the notification will be displayed. The last six are the color values and opacities for each component, as demarcated by their respective prefix. The alpha values must be integers from 0 to one, representing percent opacity, with 0 being clear and 1 being completely opaque. The color values must be either:

     One of the following presets from the color library:

ogcolor.red
ogcolor.green
ogcolor.lime
ogcolor.blue
ogcolor.orange
ogcolor.yellow
ogcolor.light_blue
ogcolor.magenta
ogcolor.pink
ogcolor.white
ogcolor.light_grey
ogcolor.grey
ogcolor.black
ogcolor.cyan
ogcolor.purple

Or a table formatted like so:

{Red RGB / 255, Blue RGB / 255, Green RGB / 255}

Each RGB value must be represented as a decimal from 0 to 1, because of the way OG accepts colors. To convert a standard RGB value into the form OG requires, simply divide by 255

To do list:

  • Support multiple line descriptions (it currently supports a single-line description of ~30 characters before the text protrudes from the bounding box) Done!
  • Implement notification queue (currently, if multiple notifications are sent within a short period of time, they will overlap) Best left to a program implementing this library
  • (Possibly) move color parser into separate library Done

 

Changelog:

 

V1.0:

  • Tons of bugfixes (it would only run on my dev machine previously, for reasons unknown)
  • Support for multiple line notifications

V0.1:

  • Initial release

I hope this comes in handy to somebody.

Link to post
Share on other sites

Here is an example of its usage:

gn = require("ognotify")
gc = require("ogcolor")
gn.send("Title","Description",2,gc.grey,0.75,gc.black,1,gc.black,1)

This would send a notification with the title "Title" and Description "Description". The background is a grey rectangle with 75% opacity, and the title and description are both black at 100% opacity

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.