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

PwnagePineapple

Members
  • Content Count

    6
  • Joined

  • Last visited

Posts posted by PwnagePineapple

  1. 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.

  2. If you're not worried about addressing individual squares (or at least, not easily), you could try:

     

    local Shapes = {}
    
    function CreateSquares( Values ) 
    -- Where values is a table like so: { {x=2,y=2,w=3,h=3}, {x=3,y=4,w=5,h=2} }
      for i,v in pairs( Values ) do -- iterates over the table, so the first iteration: i would be 1 and v would be {x=2,y=2,w=3,h=3}
        local sq = glasses.addRect()
        sq.setPosition( v.x, v.y ) -- these reference the x&y variables in the table
        sq.setSize( v.w, v.h )
        table.insert( Shapes, sq )
      end
    end
    
    -- then call it like so.
    CreateSquares( { {x=2,y=2,w=3,h=3}, {x=3,y=4,w=5,h=2} } )
    

    So if I did have to address them (for the purpose of removing them later) I would iterate over the shapes table and delete them all using glasses.removeObject()?

  3. You could use a table and then store them in that.

    So like:

     

    local shapes = {}
    function CreateSquares()
      shapes.SquareA = glasses.createSquare()
      ...
    end
    
    Obviously replacing bits with the actual code, I haven't dabbled much with Open Glasses so don't know it's functions.

     

    The problem with that, is that requires me to have squareA, squareB, and squareC already in existence, all the way to SquareN. I would like a theoretically infinite amount of widgets, and you're solution doesn't allow for that. BTW the OpenGlasses documentation can be found here: http://og.starchasers.pl/doku.php

×
×
  • Create New...

Important Information

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