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

Metalhead33

Members
  • Content Count

    2
  • Joined

  • Last visited

Posts posted by Metalhead33

  1. Ever wanted to have a second monitor attached to your computer, but wasn't fond of binding the GPU to two monitors at once?

    Do you for some reason miss the horrible-looking font of ComputerCraft's monitor?

    Are you a cheater who wants colour badly, even though you can only afford a Tier 1 Computer?

    Then wait no longer, the solution is here for you!

     

    The CCMonitor Wrapper!

    http://pastebin.com/FG9xfh5F

     

    With the CCMonitor Wrapper, you attach a secondary monitor - a ComputerCraft Monitor (basic and advanced alike) - to your OpenComputers computer, and feel the nostalgic looks right away! (or colours, if you are cheap)

     

    If you are not yet convinced, just listen to these convincing testimonials!

     

    "... uh.... why does this thing even exist? I think there is really no need for it..."

     

    So what are you waiting for? Order today!

    pastebin FG9xfh5F ccmon.lua
    

    And put it into /lib or /usr/lib!

     

    Jokes aside, what this does is wraps the CC Monitor, so you only have to invoke require("ccmon"), and you can go right away.

    local ccwrapper = { }
    local component = require("component")
     
    -- We need to check if the user has a CC monitor.
    local monitor = { }
    if component.isAvailable("computercraft_advanced_monitor") == true then
        monitor = component.computercraft_advanced_monitor
    elseif component.isAvailable("computercraft_monitor") == true then
        monitor = component.computercraft_monitor
    else
        print("No ComputerCraft monitor was detected!")
        return nil
    end
    return component.proxy(monitor.address)
    

    See?

    To use it, you simply go...

    local ccwrapper = require("ccmon")
    ccmon.write("Hello world!")
    

    Usage is basically covered here. Requires both OpenComputers and ComputerCraft.

     

    Not sure what could this be used for, but I felt tempted to write this short program, and felt like sharing it for no reason.

  2. Hello everyone!
     
    This is my very first post on the forum, and ho-boy, have I got some software library for you guys.
    MenuSys.
     
    So what exactly does MenuSys does, and why am I bragging about it like it's some great invention?
    Well, because it's not  great invention at all. Quite the contrary. It is something anyone could have came up with, and in fact, it's entirely possible that someone has already created something similar, and I was just simply too lazy to check.
    But okay, okay, enough bad jokes.
    MenuSys basically gives programmers an easy way to implement menus by giving them an API that lets them define a bunch of menu options in a table, call the menu, and have a conditional branch based on what did they choose.
     
    The best way to get MenuSys is via pastebin, although you'll net an InternetCard in your computer for that.

    pastebin get 41g8zs6R menusys.lua

    Put it somewhere you will find easily... like /lib or /usr/lib.

    So how to use it?
    First, you need to
     

    local menusys = require("menusys")

    Then you'll need a table. If you use only one dimension, you will call on the function displayMenu. If you use a two-dimensional array, you'll gonna use displayMenuMult.
     
    Here is some demonstration with single-dimension tables:

    local menusys = require("menusys")
    local choices = { "1", "2", "3" }
    while true do
        local x = menusys.displayMenu(choices,"Intro","Outro",1)
        if x == 0 then
            break
        end
    end

    Do note that Intro and Outro can be either text or function. Why function? Because that way, you can do graphical things before the menu is displayed.

     

    And with two-dimension tables:
    Here is some demonstration with single-dimension tables:

    local menusys = require("menusys")
    choice_state = {
        [1] = { false, false },
        [2] = { false, false },
    }
     
     
     
    function choice_concat(text,x,y)
    if choice_state[x][y] == true then
        return text .. " " .. x .. "-" .. y .. " [ON]"
    else
        return text .. " " .. x .. "-" .. y .. " [OFF]"
    end
    end
     
    choices = { }
    for xkey,xvalue in ipairs(choice_state) do
        choices[xkey] = { }
        for ykey,yvalue in ipairs(xvalue) do
            choices[xkey][ykey] = function() return choice_concat("NODE",xkey,ykey) end
        end
    end
     
    x = 1
    y = 1
       
    while true do
        x,y = menusys.displayMenuMult(choices,"Test Functions","Test Functions",x,y)
        if x == 0 then
            exit()
        else
            if choice_state[x][y] == true then
                choice_state[x][y] = false
                else choice_state[x][y] = true
            end
        end
    end

    It is also available for ComputerCraft.

    MIT License

     

    -----------

    Copyright © 2016, Zsolt Tóth

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.

×
×
  • Create New...

Important Information

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