r/ComputerCraft • u/SamirG569 • Jan 26 '26
To anyone who wants it, a tutorial to making buttons/a gui in Computercraft without having to download 30 external apis and watch 80 tutorials on youtube just to find nothing what u need
https://www.youtube.com/watch?v=YG15XkI-8Ysit isnt high quality i just coded tbh so have fun! (day 1 of making computercraft reddit active again)
30
Upvotes
1
u/Insurgentbullier NIH patient Jan 26 '26
Ooh, I like the use of shell.execute(), creative.
1
u/9551-eletronics Computercraft graphics research Jan 26 '26
Code review time!!! :3 (day 1 judging code on r/computercraft reddit)
i would change this a lot. first off for the box drawer i would just draw it line by line as that will be a lot faster than iterating over all boxes, i would use string.rep to make the line once and then use term.blit to draw it
For text Centering you really wanna be using a separate function, as it is right now it makes it hard to read
you want to make all variables and all functions local.
You are using an object to hold the button data but do not include colors? why? also you could make a constructor for this easily to add new ones
same thing for checking if its within a box, first off you could use <= instead of doing math on the sizes, and ideally you would wanna offload this into a separate function too for readability.
also why the switch to shell.execute? why not use shell.run to launch the fg program?