Posted 06 July 2014 - 02:53 AM
hey guys im trying to stop a loop inside a function(on), using another function (0ff), on the code below:
http://pastebin.com/0BmmcrEs
can anybody give a hand? thanks!
--- Decorative Sonar by Gustavo Wizard
--- Monitor 2x2, btn API
os.loadAPI("btn")
m = peripheral.wrap("top")
local commandBlock = peripheral.wrap("left")
currentCommand = commandBlock.getCommand()
m.setTextScale(0.5)
m.setBackgroundColor(colors.black)
m.clear()
m.setTextColor(colors.red)
m.setCursorPos(8,2)
m.write("TYPHOON TK-208 SONAR")
term.redirect(m)
m.setTextColor(colors.white)
function fillTable()
btn.setTable("SONAR ON", on, 6,16,20,22)
btn.setTable("SONAR OFF", off,20,30,20,22)
btn.screen()
end
function getClick()
event,side,x,y = os.pullEvent("monitor_touch")
btn.checkxy(x,y)
end
function on()
btn.flash("SONAR ON")
while true do --- here is what i need to change, this loop must stop when i press the button of the function off
local image = paintutils.loadImage("r.nfp")
paintutils.drawImage(image,8,4)
sleep(.3)
local image = paintutils.loadImage("r2.nfp")
paintutils.drawImage(image,8,4)
sleep(.3)
local image = paintutils.loadImage("r3.nfp")
paintutils.drawImage(image,8,4)
sleep(.3)
local image = paintutils.loadImage("r4.nfp")
paintutils.drawImage(image,8,4)
commandBlock.setCommand("playsound wizard.sonar_low @a")
commandBlock.runCommand()
sleep(.3)
end
end
m.setBackgroundColor(colors.red)
m.setTextColor(colors.white)
function off()
btn.flash("SONAR OFF")
end
fillTable()
while true do
getClick()
end
http://pastebin.com/0BmmcrEs
can anybody give a hand? thanks!