now i will upload the code and give you the issue
----modified version of progress bar api from hawkee.com/snippet/10100 just made it work over network-----------------------------------------
batch=1
status= loading
local monitor
local hasMonitor = false
local ProgressBar = {}
local FillColor = colors.orange
local EmptyColor = colors.blue
local TextColor = colors.white
function SetPeripheral(Pname)
monitor = peripheral.wrap(Pname)
hasMonitor = true
end
function SetTable(name, maxVal, curVal, xmin, xmax, y)
ProgressBar[name] = {}
ProgressBar[name]["Max"] = maxVal
ProgressBar[name]["Current"] = curVal
ProgressBar[name]["XMin"] = xmin
ProgressBar[name]["XMax"] = xmax
ProgressBar[name]["YVal"] = y
end
function ClearTable()
if (hasMonitor) then
ProgressBar = {}
end
end
function SetFillColor(color)
if (colors.combine(color,color)) then
FillColor = color
end
end
function SetEmptyColor(color)
if (colors.combine(color,color)) then
EmptyColor = color
end
end
function SetTextColor(color)
if (colors.combine(color,color)) then
TextColor = color
end
end
function SetMaxValue(name, intVal)
if (ProgressBar[name]) then
ProgressBar[name]["Max"] = intVal
end
end
function SetCurValue(name, intVal)
if (ProgressBar[name]) then
ProgressBar[name]["Current"] = intVal
end
end
function DrawToPeripheral(status)
if (hasMonitor) then
for name, data in pairs(ProgressBar) do
DrawBar(name, data)
end
end
monitor=peripheral.wrap("monitor_1")
monitor.setCursorPos(1,18)
monitor.write("status:" ..status )
end
function DrawBar(name, arr)
local y = arr["YVal"]
local fill = math.floor((arr["XMax"] - arr["XMin"]) * (arr["Current"] / arr["Max"]))
monitor.setBackgroundColor(FillColor)
monitor.setTextColor(TextColor)
for x = arr["XMin"], arr["XMax"] do
local num = math.floor(x - arr["XMin"])
monitor.setCursorPos(x,y)
if (num > fill) then
monitor.setBackgroundColor(EmptyColor)
end
if (num == 0) then
monitor.write("[")
end
if (x == arr["XMax"]) then
monitor.write("]")
else
monitor.write(" ")
end
end
monitor.setBackgroundColor(colors.black)
end
------------------------------------------
-------------------------
function bucket()
print(r)
redstone.setAnalogOutput("right",15)
sleep(1)
redstone.setAnalogOutput("right",0)
end
-------------------------
function pickPotion(side,potion)
SetCurValue("Test",2)
DrawToPeripheral("choosing potions")
redstone.setAnalogOutput(side,potion)
sleep(1)
redstone.setAnalogOutput(side,0)
end
-------------------------
function items()
redstone.setAnalogOutput("right",5)
sleep(1)
redstone.setAnalogOutput("right",0)
SetCurValue("Test",3)
DrawToPeripheral("dispensing items")
end
-------------------------
function bottle()
redstone.setAnalogOutput("right",1)
sleep(1)
redstone.setAnalogOutput("right",0)
end
-------------------------------------
function extras()
redstone.setAnalogOutput("right",2)
sleep(1)
redstone.setAnalogOutput("right",0)
SetCurValue("Test",7)
DrawToPeripheral("removing excess bottles")
end
-------------------------------------
-------------------------------------
function Brew(side,potion)
r=redstone.getInput("left")
redstone.setOutput("right",false)
redstone.setOutput("left",false)
redstone.setOutput("top",false)
redstone.setOutput("bottom",false)
bucket()
SetCurValue("Test",1)
DrawToPeripheral("dispensing water")
if r==false then
while r==false do
r=redstone.getInput("left")
print("system not ready waiting")
sleep(1)
end
pickPotion(side,potion)
else
pickPotion(side,potion)
end
sleep(3)
if r==false then
while r==false do
r=redstone.getInput("left")
print("system not ready waiting")
sleep(1)
end
items()
else
items()
end
sleep(1)
if r==false then
while r==false do
r=redstone.getInput("left")
print("system not ready waiting")
sleep(1)
end
x=3
while x >= 1 do
if x==3 then
SetCurValue("Test",4)
elseif x==2 then
SetCurValue("Test",5)
elseif x==1 then
SetCurValue("Test",6)
else
end
bottle()
sleep(2)
x=x-1
DrawToPeripheral()
end
else
x=3
while x >= 1 do
if x==3 then
SetCurValue("Test",4)
elseif x==2 then
SetCurValue("Test",5)
elseif x==1 then
SetCurValue("Test",6)
else
end
bottle()
sleep(2)
DrawToPeripheral("dispensing bottle "..x)
x=x-1
end
end
sleep(1)
print("removing extra bottles")
if r==false then
while r==false do
r=redstone.getInput("left")
print("system not ready waiting")
sleep(1)
end
extras()
else
sleep(1)
extras()
end
print("extras removed")
monitor.clear()
DrawToPeripheral("processing complete")
sleep(3)
monitor.clear()
SetCurValue("Test",0)
DrawToPeripheral("")
end
-----------------------------------------
os.loadAPI("button")
SetPeripheral("monitor_1")
monitor.clear()
ClearTable()
SetTable("Test", 7, 1, 1,20,19)
--------------------------------------
function fillTable()
button.setTable("page1", page1, 1,7,1,3)
button.setTable("page2", page2, 33,39,1,3)
button.setTable("batch", batch, 22,28,1,3)
button.setTable("vines", vines, 1,7,5,7)
button.screen()
end
function fillTable2()
button.setTable("page1", page1, 1,7,1,3)
button.setTable("page2", page2, 33,39,1,3)
button.setTable("batch", batch, 22,28,1,3)
button.screen()
end
function batch()
button.ClearTable()
monitor.clear()
button.setTable("page1", page1, 1,7,1,3)
button.setTable("page2", page2, 33,39,1,3)
button.setTable("t1",batch1,9,11,1,3)
button.setTable("t2",batch2,13,15,1,3)
button.setTable("t3",batch3,17,19,1,3)
button.setTable("t4",batch4,21,23,1,3)
button.setTable("t5",batch5,25,27,1,3)
button.screen()
end
------------------------------------
function page1()
button.ClearTable()
monitor.clear()
fillTable()
button.flash("page1")
end
function page2()
button.ClearTable()
monitor.clear()
fillTable2()
button.flash("page2")
end
function batch1()
name = t1
for name,data in pairs(button) do
button.toggleButton(t1)
local on = data["active"]
if on == true then
batch=1
else
batch=1
end
end
end
function batch2()
name = t2
for name,data in pairs(button) do
button.toggleButton(t2)
local on = data["active"]
if on == true then
batch=2
else batch=1
end
end
name = t1
for name,data in pairs(button) do
local on = data["active"]
if on == true then
button.toggleButton(t1)
end
end
end
--------------------------------
function getClick()
event,side,x,y = os.pullEvent("monitor_touch")
button.checkxy(x,y)
end
---------------------------------------------------
function batchs(side,potion,batch)
print("batch processing enabled")
batch=batch+1
while batch >=2 do
batch=batch-1
Brew(side,potion)
if batch > 1 then print("batch processing enabled")
else print("batch processing disabled")
end
sleep(2)
end
end
------------------------------------------------------
button.heading("witchery auto brewing")
fillTable()
while true do
getClick()
end
note this is not complete yet as i have alot to add. for each of the witchery potions. kind of looking to find if i can put that data in a table and pull it some how. so any advice and ways to make the code more simple is appreciated as well. but the problem i am having is in
function batch1()
name = t1
for name,data in pairs(button) do
button.toggleButton(t1)
local on = data["active"]
if on == true then
batch=1
else
batch=1
end
end
end
function batch2()
name = t2
for name,data in pairs(button) do
button.toggleButton(t2)
local on = data["active"]
if on == true then
batch=2
else batch=1
end
end
when i run this part it calls an error in the button api and i cannot find out why. is there anything i can do to fix this. if anyone who knows a lot is out there i would appreciate the help