Posted 22 May 2013 - 07:49 AM
I'm creating a monitor for all my farms but i cant get my bundle cable working
What does it need to do : When i touch the first button it needs to turn on the bundled cable color.(then the button on the screen is green) then by pressing it again it is turning red and it disables the bundled cable
Script
I hope i can get some help because i cant get it working
Also sorry for my bad english :P/>
~Kev
What does it need to do : When i touch the first button it needs to turn on the bundled cable color.(then the button on the screen is green) then by pressing it again it is turning red and it disables the bundled cable
Script
local bcable = "back"
local mon = peripheral.wrap("top")
mon.setTextScale(1)
mon.setTextColor(colors.white)
local button={}
mon.setBackgroundColor(colors.black)
function setTable(name, func, bcolor, xmin, xmax, ymin, ymax)
button[name] = {}
button[name]["func"] = func
button[name]["active"] = false
button[name]["bcolor"] = bcolor
button[name]["xmin"] = xmin
button[name]["ymin"] = ymin
button[name]["xmax"] = xmax
button[name]["ymax"] = ymax
end
function Chicken()
print("Chicken")
redstone.setBundledOutput("back",colors.black)
sleep(1)
redstone.setBundledOutput("back",0)
end
function Cow()
print("Cow")
redstone.setBundledOutput("back",colors.blue)
sleep(1)
redstone.setBundledOutput("back",0)
end
function Pig()
print("Pig")
end
function Sheep()
print("Sheep")
end
function Blaze()
print("Blaze")
redstone.setBundledOutput("back",colors.white)
sleep(100)
redstone.setBundledOutput("back",0)
end
function Creeper()
print("Creeper")
end
function Skeleton()
print("Skeleton")
end
function Spider()
print("Spider")
end
function Zombie()
print("Zombie")
end
function fillTable()
setTable("Blaze", Blaze, 5, 20, 4, 6)
setTable("Chicken", Chicken, 30, 45, 4, 6)
setTable("Creeper", Creeper, 5, 20, 8, 10)
setTable("Cow", Cow, 30, 45, 8, 10)
setTable("Skeleton", Skeleton, 5, 20, 12, 14)
setTable("Pig", Pig, 30, 45, 12, 14)
setTable("Spider", Spider, 5, 20, 16, 18)
setTable("Sheep", Sheep, 30, 45, 16, 18)
setTable("Zombie", Zombie, 5, 20, 20, 22)
end
function fill(text, color, bData)
mon.setBackgroundColor(color)
local yspot = math.floor((bData["ymin"] + bData["ymax"]) /2)
local xspot = math.floor((bData["xmax"] - bData["xmin"] - string.len(text)) /2) +1
for j = bData["ymin"], bData["ymax"] do
mon.setCursorPos(bData["xmin"], j)
if j == yspot then
for k = 0, bData["xmax"] - bData["xmin"] - string.len(text) +1 do
if k == xspot then
mon.write(text)
else
mon.write(" ")
end
end
else
for i = bData["xmin"], bData["xmax"] do
mon.write(" ")
end
end
end
mon.setBackgroundColor(colors.black)
end
function screen()
local currColor
for name,data in pairs(button) do
local on = data["active"]
if on == true then currColor = colors.lime else currColor = colors.red end
fill(name, currColor, data)
end
end
function checkxy(x, y)
for name, data in pairs(button) do
if y>=data["ymin"] and y <= data["ymax"] then
if x>=data["xmin"] and x<= data["xmax"] then
data["func"]()
data["active"] = not data["active"]
print(name)
end
end
end
end
function heading(text)
w, h = mon.getSize()
mon.setCursorPos((w-string.len(text))/2+1, 1)
mon.write(text)
end
fillTable()
while true do
mon.clear()
heading("Mobspawner Control")
screen()
local e,side,x,y = os.pullEvent("monitor_touch")
print(x..":"..y)
checkxy(x,y)
sleep(.1)
end
I hope i can get some help because i cant get it working
Also sorry for my bad english :P/>
~Kev