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

OpenGlasses Button API

Recommended Posts

Hello everyone! Direwo... eh, not quite right.

Well, OpenGlasses for 1.12 is out! And I noticed there were no public button API for it, so I made one myself!

I have a few functions built-in to make it easier to change stuff, but it was created with simplicity in mind. So if you simply just initialize a button and bind a function to it, it won't do any fancy stuff except for activating the function when you press it, so you have to add your own functionality to it:



But with a little bit of extra code:



Ok, not that big a difference, you guys are probably more creative than me!


I also have a concept called "groups". When creating a button, you can specify what group it should be in. So if you want to change the color of all the buttons to the left side to pink, you can do that.

Functions (in no particular order):

--Needs to be called before creating any buttons, works as a reset also:

--Creating a new button element:
gButtonAPI4.createNewButton(name,group,display,x,y,w,h,color: table,transparently,callback: function)

--Has to be inside of your main loop:

--Prints all registered groups:

--Change the visibility of the button/group:

--Change the color of the button/group:
gButtonAPI4.Color(button/group[,color: table])--None for default color.

--Same as color, but changes the label:
gButtonAPI4.Label(button/group[,text])--None for default label.

--Add a button to a group:




If you don't want to make a new function for each new button, you can then bind them all to the same function. And add a parameter to your function, the name of the button that was clicked will be returned:

local function btniF(buttonx)
  print("I am " .. buttonx .. "!")


I added a Demo program that shows most of the library's functions. Oh, btw, I like the number 4. It's not like this is my fourth attempt creating this or anything!

Write a reply if you have any questions, this was my first attempt to create a usable library.



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.

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.


  • Create New...

Important Information

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