Posted 20 September 2012 - 04:35 PM
Hello pros, My program was running fine with tekkit 3.1.1 but now with 3.1.2 it reboots the PC the program is setup to get a signal from 3 different Item detectors one detectors counts blocks of 64 then 10 then 1. This is part of a banking program. Here is my code (i removed the URL to my site)
Thanks for any help you can give me.
debug_char = "="
disk.eject("bottom")
term.clear()
term.setCursorPos(1,1)
function PrintCentered(sText)
local w, h = term.getSize()
local x, y = term.getCursorPos()
x = math.max(math.floor((w / 2) - (#sText / 2)), 0)
y = math.max(math.floor((h / 2)),0)
term.setCursorPos(x, y)
print(sText)
end
coin = 0
bOut = 0
mult = 0
mult2 = 0
coin2 = 0
coin3 = 0
function counting()
rsInput = rs.getBundledInput("back")
os.startTimer(20)
if colors.test(rsInput, colors.brown) == true then
coin = coin + 1
elseif colors.test(rsInput, colors.purple) == true then
coin2 = coin2 + 1
elseif colors.test(rsInput, colors.green) == true then
coin3 = coin3 + 1
end
end
function loop()
while true do
--event = os.pullEvent()
if event == "redstone" then
bOut = colors.combine(bOut, colors.white)
rs.setBundledOutput("back", bOut)
counting()
elseif event == "timer" then
bOut = colors.subtract(bOut, colors.yellow)
rs.setBundledOutput("back", bOut)
mult=coin*64
mult2=coin2*10
mult=coin3+mult+mult2
sleep(10)
break
end
end
end
PrintCentered("Please Insert Debit Card")
function mainLoop()
while(true) do
event, driveSide = os.pullEventRaw()
if(event=="disk" and driveSide) then
path = disk.getMountPath(driveSide)
if(path) then
path = path.."/id"
file = fs.exists(path) and io.open(path, "r") or nil
end
term.clear()
term.setCursorPos(1,1)
PrintCentered("Please Enter Account Pin Number")
pin = read("*")
sCode = file:read()
local response = http.get(
"/bank.php?task=check&id="..textutils.urlEncode( sCode ).."&pin="..textutils.urlEncode( pin )
)
if response then
local sResponse = response.readAll()
response.close()
if sResponse == "deny" then
term.clear()
term.setCursorPos(1,1)
print("Account or Password is wrong, Please try again")
disk.eject(driveSide)
sleep(5)
if(file) then file:close() file = nil end
os.reboot()
else
term.clear()
term.setCursorPos(1,1)
PrintCentered("Please Deposit Money into Chest on Right")
bOut = colors.subtract(bOut, colors.white)
rs.setBundledOutput("back", bOut)
sleep(8)
bOut = colors.combine(bOut, colors.white)
rs.setBundledOutput("back", bOut)
disk.eject(driveSide)
term.clear()
term.setCursorPos(1,1)
bOut = colors.combine(bOut, colors.yellow)
rs.setBundledOutput("back", bOut)
PrintCentered("Counting Money, This takes 20 seconds")
loop()
term.clear()
term.setCursorPos(1,1)
PrintCentered("You have Deposited $"..mult)
local response = http.get(
"/bank.php?task=deposit&id="..textutils.urlEncode( sCode ).."&pin="..textutils.urlEncode( pin ).."&amount="..textutils.urlEncode( mult )
)
if response then
sleep(3)
local sResponse1 = response.readAll()
term.clear()
term.setCursorPos(1,1)
PrintCentered("Your Current Balance is $"..sResponse1)
sleep(5)
if(file) then file:close() file = nil end
os.reboot()
end
end
end
if(file) then file:close() file = nil end
elseif(debug_char and event=="char" and driveSide==debug_char) then return("break") end
end
end
repeat
ok, err, val = pcall(mainLoop)
if(not ok and err) then
if(err=="Terminated") then print ("Access denied.")
else
print(err)
end
end
until(ok and err=="break")
It is failing as it should be counting the $$, I have been thrown a error once in a while something like vb issue not sure the exact code.Thanks for any help you can give me.