Giter Site home page Giter Site logo

cceasygui's Introduction

CCEasyGui

This is a simple library for ComputerCraft that allows you to make buttons and gui elements with ease. This is a simple library for simple programs e.g. controlling redstone with a button.


Features

  • You can create buttons and elements using the RegisterElement() function.
  • Buttons and their text will change color when pressed.
  • Buttons will only execute if you let go over the button, just like a pc.
  • Text for buttons and elements are word wrapped. Just make sure everything has enough room to fit.

Usage

Installation

Download the 'EasyGui.lua' file and upload it to the computer. You can simply drag n' drop from your pc in modern version of CC, in older versions you'll have to use pastebin. And if http is disable on the server ๐Ÿคท

Usage

Load the library using os.loadAPI("EasyGUI.lua")

Once loaded create a one object using gui = EasyGUI.GUI(*terminal or monitor*, *background color*)

Use RegisterElement() to create your buttons and elements. It takes 11 arguments; here's how you would make a button

RegisterElement("element text/name", function() *what ever you want it to do* end, *background color*, *background when pressed*, *text color*, *text color when pressed*, *style*, *originX*, *originY*, *width*, *height*)

To create an element it would look something like this

RegisterElement("element text/name", nil, *background color*, nil, *text color*, nil, *style*, *originX*, *originY*, *width*, *height*)

Use Run() to start rendering the gui. This will loop forever checking for button presses.

Styles

There are three element styles right now and you pass them to RegisterElement() by their string.

  • "box"
  • "minimal"
  • "border"

Notes

  • The height and width specify the visual borders of the element and the hitboxes of buttons; even if you use the minimal style it will still register clicks within its bounds.
  • Colors are specified using the builtin colors class e.g. colors.blue
  • If you specify a function it will behave as a button, if it is nill, it will behave as a static element and cannot be pressed.
  • Be careful not to overlap buttons, they'll behave unexpectedly.

Example

os.loadAPI("EasyGUI.lua")

gui = EasyGUI.GUI(term.current(), colors.black)

gui:RegisterElement("Box Button", function () end, colors.green, colors.blue, colors.red, colors.white, "box", 2, 2, 13, 2)
gui:RegisterElement("Minimal Button", function () end, colors.red, colors.white, colors.white, colors.red, "minimal", 17, 2, 14, 0)
gui:RegisterElement("Bordered Button", function () end, colors.blue, colors.gray, colors.white, colors.lightGray, "border", 2, 6, 17, 2)
gui:RegisterElement("This element meant to be a long text and should be automatically wrapped", nil, colors.blue, nil, colors.white, nil, "border", 21, 6, 17, 7)

gui:Run()

This script will register three buttons and one element with word wrapping.

image

cceasygui's People

Contributors

memesanddremes avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.