nothjarnan / love2d-button

MIT License
6 stars 1 forks source link

Just a tiny little bit I wanted to share :) #2

Open jojomoore2007 opened 5 years ago

jojomoore2007 commented 5 years ago

I actually recently started making a ComputerCraft API to make clickable buttons with functions tied to them, i.e. a new way to make buttons.

The only problem is to make it work requires you to wrap all your code into a main() function, then load the API at the very start of the code and run main() and btn.begin() parallel to each other using parallel.waitForAny(main, btn.begin) at the very end so the API can automatically run a function as soon as a button is clicked, without the need for any extra calls to btn.pullEvent() (Passthrough of os.pullEvent() but runs functions if it gets a "mouse_click" event with the X and Y positions being in the button's range) calls. If you choose to not include that at the end, you have to implement some way to call btn.pullEvent() or btn.pullEventRaw() (An exact copy of btn.pullEvent() but with os.pullEventRaw() instead of os.pullEvent()) every so often, or the functions will not be called.

That was a very long explanation.

TL;DR: I made a cool button API for CC that only works if you wrap your code in a function and run it parallel to btn.begin().

nothjarnan commented 5 years ago

That's pretty cool. I'm pretty active in the CC community as well, mainly on servers though.

jojomoore2007 commented 5 years ago

That's pretty cool. I'm pretty active in the CC community as well, mainly on servers though.

Yeah, I make lots of APIs and programs for CC. I'm currently making a package manager kinda like NPM for CC (CCPM). I have noticed they seem to be using RECAPTCHA V1 (Although someone got in somehow...) and I can't make an account... 😞

I was actually planning on making a GitHub pages site for CC where you could make posts, but I think I'm just gonna make a CC blog where I'll post the APIs and programs I make.

Welp, see ya around, I'm gonna go make a game engine for CC!

P.S.: I made a pull req. on your LOVE2D button API. I added the feature you mentioned in the README for you.

nothjarnan commented 5 years ago

Thank you, mad props for adding that feature. There is a new forum for computercraft found here: https://forums.computercraft.cc/