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

MoparDan

Members
  • Content count

    9
  • Joined

  • Last visited

1 Follower

About MoparDan

  • Rank
    Junior Member

Contact Methods

  • Minecraft
    MoparDan

Recent Profile Visitors

265 profile views
  1. Hello everybody! My first posting and first real OC code, so please be gentle . The reason why I made this is because I got tired of lack of bundled cable support in CC (at the current moment in 1.6.4) and one of the things I greatly enjoyed doing in CC was making button GUI's to control various things for me. This code is highly unoptimized, even as I post this I can see areas that can be greatly optimized, but meh, I'm too lazy atm to do it My one question is how do you change it so you dont have to "sneak-click" the monitor to use the touch feature? One thing to note of importance. The deliberate delay of "os.sleep(0.1)" between switching the redstone state(s) in the bundled cable IS REQUIRED. Any attempt I made and removing it resulted in the code crashing at random points. I assume its due to trying to change 2 different colored cable states at near the same time (possible bug found?). Lastly, being I am fairly "noobish" at lua, any 'constructive' tips you can see I should be aware of to help prevent "bad coding habits" I would greatly apperciate it. Here is a youtube vid of it in action, and the code will follow below. Feel free to use it/edit it/clean it up as you wish! http://youtu.be/DHMHj0o9I5g local component = require("component") local colors = require("colors") local sides = require("sides") local rs = component.redstone local gpu = component.gpu local w, h = gpu.getResolution() local event = require("event") local Blue = 0x0000AA local Green = 0x00AA00 local Red = 0xAA0000 local Black = 0x000000 local state = 1 local function cls() gpu.setBackground(0x000000) gpu.fill(1, 1, w, h, " ") end local function buttonState() if state == 1 then gpu.setBackground(Green) gpu.set(5, 5, " ") gpu.set(5, 6, " Test ") gpu.set(5, 7, " ") gpu.setBackground(Black) gpu.set(5, 9, "green") rs.setBundledOutput(sides.left, colors.red, 0) os.sleep(0.1) rs.setBundledOutput(sides.left, colors.green, 255) os.sleep(0.1) state = 2 else gpu.setBackground(Red) gpu.set(5, 5, " ") gpu.set(5, 6, " Test ") gpu.set(5, 7, " ") gpu.setBackground(Black) gpu.set(5, 9, "red ") rs.setBundledOutput(sides.left, colors.green, 0) os.sleep(0.1) rs.setBundledOutput(sides.left, colors.red, 255) os.sleep(0.1) state = 1 end end local function default() gpu.setBackground(Blue) gpu.set(5, 5, " ") gpu.set(5, 6, " Test ") gpu.set(5, 7, " ") gpu.setBackground(Black) gpu.set(5, 9, "blue ") rs.setBundledOutput(sides.left, colors.red, 0) os.sleep(0.1) rs.setBundledOutput(sides.left, colors.green, 0) os.sleep(0.1) end os.sleep(0) gpu.setResolution(83, 30) gpu.setBackground(Black) gpu.fill(1, 1, w, h, " ") default() while true do local _, _, x, y = event.pull(touch) if x >= 5 and x <= 12 then if y >= 5 and y <= 7 then buttonState() else default() end else default() end end
×

Important Information

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