ComputerCraft Archive

Question

computer utility kepler155c github

Description

ComputerCraft OS

Installation

Copy one of these commands into your ComputerCraft terminal:

wget:wget https://raw.githubusercontent.com/kepler155c/opus/develop-1.8/sys/modules/opus/ui/components/Question.lua question
Archive:wget https://cc.shobie.xyz/cc/get/gh-kepler155c-opus-sys-modules-opus-ui-components-question question
Quick Install: wget https://cc.shobie.xyz/cc/get/gh-kepler155c-opus-sys-modules-opus-ui-components-question Question

Usage

Run: Question

Tags

none

Source

View Original Source

Code Preview

local class = require('opus.class')
local UI    = require('opus.ui')

UI.Question = class(UI.MiniSlideOut)
UI.Question.defaults = {
    UIElement = 'Question',
    accelerators = {
        y = 'question_yes',
        n = 'question_no',
    }
}
function UI.Question:postInit()
    local x = self.label and #self.label + 3 or 1

    self.yes_button = UI.Button {
        x = x,
        text = 'Yes',
        backgroundColor = 'primary',
        event = 'question_yes',
    }
    self.no_button = UI.Button {
        x = x + 5,
        text = 'No',
        backgroundColor = 'primary',
        event = 'question_no',
    }
end