Posted 03 May 2015 - 03:33 AM
I currently have this as my code (only posted cuz y'all always ask for it), look into the main loop for my problem.
as you can see, it should start a timer for 0.5 sec at the start then 10 sec every time after, however it looks like it pulls the timer every possible computer tick, since the printing of the os.time prints ~every tenth of a second. I need to slow that down to the specified time, which will eventually be 0.5 sec.
this has happened for another program of mine, but it wasn't a problem for that one's application.
Spoiler
for k,v in pairs(peripheral.getNames()) do
t = peripheral.getType(v)
if t == "BigReactors-Reactor" then
r = peripheral.wrap(v)
--print("found reactor!")
elseif t == "monitor" then
m = peripheral.wrap(v)
--print("found monitor!")
end
end
b = {}
tno = {"getControlRodName","getCoolantType","getControlRodLevel","getControlRodLocation","getHotFluidType"}
m.clear()
m.setCursorPos(1,0)
m.setTextScale(1)
function mprint(text)
xx,yy = m.getCursorPos()
m.setCursorPos(1,yy+1)
m.write(text)
end
function addButton(x,y,text,func)
b[x..y] = {x,y,text,func}
end
function testTable(k,t)
for i,y in pairs(t) do
if y == k then
return true
end
end
return false
end
function rawDiagnostics()
mprint("raw diagnostics!")
for k,v in pairs(r) do
tf = string.sub(k,0,2)
if tf == "ge" or tf == "is" then
if testTable(k,tno) == false then
x,y,z = v()
str = x
if y then
str = str..","..y
end
if z then
str = str..","..z
end
mprint(k..": "..tostring(str))
else
mprint(k..": args needed")
end
end
end
end
function checkxy(x, y)
for name, data in pairs(B)/>/> do
if y>=data[2] and y <= data[2] then
if x>=data[1] and x<= data[1]+#tostring(data[3]) then
data[4]()
return true
end
end
end
return false
end
function toggleActive()
r.setActive(not r.getActive())
end
function draw()
for h,j in pairs(B)/>/> do
m.setCursorPos(j[1],j[2])
m.write(j[3])
end
end
function addText(x,y,text)
--b[text] =
end
while true do
b = {}
addButton(2,2,r.getActive(),toggleActive)
m.clear()
draw()
timer = os.startTimer(0.5)
a,side,x,y = os.pullEvent()
if a == "monitor_touch" then
checkxy(x,y)
elseif a == "timer" then
timer = os.startTimer(10)
print("update!",os.time())
end
end
this has happened for another program of mine, but it wasn't a problem for that one's application.
Edited on 03 May 2015 - 01:34 AM