Posted 22 January 2013 - 12:33 PM
I am trying to make a dispenser program for foods in a cafeteria.
The program once totalled up and the signal to start the dispensing will only dispense one of each item only if there is any in the que for it.
I cannot get it to dispense the correct amount.
Here is the coding I have.
The program once totalled up and the signal to start the dispensing will only dispense one of each item only if there is any in the que for it.
I cannot get it to dispense the correct amount.
Here is the coding I have.
inside = "back"
outside = "bottom"
p = 0
pstat = 0
b = 0
bstat = 0
c = 0
cstat = 0
term.clear()
term.setCursorPos(1,1)
print("Order Calculations")
print("Porkchops: "..p)
print("Beef: "..B)/>
print("Chicken: "..c)
while true do
os.pullEvent("redstone")
if rs.testBundledInput(inside, colours.white) then
p = p + 1
pstat = pstat + 1
elseif rs.testBundledInput(inside, colours.orange) then
b = b + 1
bstat = bstat + 1
elseif rs.testBundledInput(inside, colours.magenta) then
c = c + 1
cstat = cstat + 1
elseif rs.testBundledInput(inside, colours.yellow) then
p = 0
b = 0
c = 0
elseif rs.testBundledInput(inside, colours.lightBlue) then
repeat
if pstat > 0 then
p = 0
for i=1, pstat do
rs.setBundledOutput(outside, 1)
sleep(1)
rs.setBundledOutput(outside, 0)
end
pstat = 0
elseif bstat > 0 then
b = 0
for i=1, bstat do
rs.setBundledOutput(outside, 2)
sleep(1)
rs.setBundledOutput(outside, 0)
end
bstat = 0
elseif cstat > 0 then
c = 0
for i=1, cstat do
rs.setBundledOutput(outside, 4)
sleep(1)
rs.setBundledOutput(outside, 0)
end
cstat = 0
elseif cstat == 0 and bstat == 0 and pstat == 0 then
print("Finished Order. New Order may be made.")
sleep(1)
end
until pstat == 0 and bstat == 0 and cstat == 0
else
term.clear()
term.setCursorPos(1,1)
print("Order Calculations")
print("Porkchops: "..p)
print("Beef: "..B)/>
print("Chicken: "..c)
end
end