This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Ridous's profile picture

Register Code help

Started by Ridous, 12 March 2012 - 03:00 AM
Ridous #1
Posted 12 March 2012 - 04:00 AM
At vacation home right now and I have no access to minecraft right now (the site's blocked for some reason)

and I wrote this out of when I was thinking about upgrading my quarries to a tunnel register

I know its riddled with bugs but I don't have a clue to where to find them right now.

Spoiler

--Ore counter
--This program goes to Computer #47 : "Quarry Fine Register"
--This program uses all 16 colors in RP2:D
--Uses Diamond gates and outputs from the top using rednet to transfer all
--information to main server : Computer #13 : "Master Control : Dream Realm"
--This program will archive all ores that pass through it.
--the right side counts all incoming ore to storage and
--the left side counts all outgoing resources.
--This program makes a log of all ore every 5 minutes and resets the
--log information every session

local right = rs.getBundledInput("right") --Servo to the right, inbound ore
local left = rs.getBundledInput("left") --Servo to the left, outbound resources


Ore = {Iron, Gold, Redstone, Coal, Diamond, Copper, Tin, Silver, Appitite,
Uranium, Nikalite, Ruby, Saphire, Emerald}

Ore_Value = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
Ore_Sent = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

function Income_Counter()
while true do

--adds 1 everytime an ore passes through its gate
if colors.test(right, 1 ) == true then
Ore_Value[1] = Ore_Value[1] + 1

elseif colors.test(right, 2 ) == true then
Ore_Value[2] = Ore_Value[2] + 1

elseif colors.test(right, 4 ) == true then
Ore_Value[3] = Ore_Value[3] + 1

elseif colors.test(right, 8 ) == true then
Ore_Value[4] = Ore_Value[4] + 1

elseif colors.test(right, 16 ) == true then
Ore_Value[5] = Ore_Value[5] + 1

elseif colors.test(right, 32 ) == true then
Ore_Value[6] = Ore_Value[6] + 1

elseif colors.test(right, 64 ) == true then
Ore_Value[7] = Ore_Value[7] + 1

elseif colors.test(right, 128 ) == true then
Ore_Value[8] = Ore_Value[8] + 1

elseif colors.test(right, 256 ) == true then
Ore_Value[9] = Ore_Value[9] + 1

elseif colors.test(right, 512 ) == true then
Ore_Value[10] = Ore_Value[10] + 1

elseif colors.test(right, 1024 ) == true then
Ore_Value[11] = Ore_Value[11] + 1

elseif colors.test(right, 2048 ) == true then
Ore_Value[12] = Ore_Value[12] + 1

elseif colors.test(right, 4096 ) == true then
Ore_Value[13] = Ore_Value[13] + 1

elseif colors.test(right, 8192 ) == true then
Ore_Value[14] = Ore_Value[14] + 1

end
end
end

function Spending_Counter()
while true do

--adds 1 for every resource sent
if colors.test(left, 1 ) == true then
ore_sent[1] = ore_sent[1] + 1

elseif colors.test(left, 2 ) == true then
ore_sent[2] = ore_sent[2] + 1

elseif colors.test(left, 4 ) == true then
ore_sent[3] = ore_sent[3] + 1

elseif colors.test(left, 8 ) == true then
ore_sent[4] = ore_sent[4] + 1

elseif colors.test(left, 16 ) == true then
ore_sent[5] = ore_sent[5] + 1

elseif colors.test(left, 32 ) == true then
ore_sent[6] = ore_sent[6] + 1

elseif colors.test(left, 64 ) == true then
ore_sent[7] = ore_sent[7] + 1

elseif colors.test(left, 128 ) == true then
ore_sent[8] = ore_sent[8] + 1

elseif colors.test(left, 256 ) == true then
ore_sent[9] = ore_sent[9] + 1

elseif colors.test(left, 512 ) == true then
ore_sent[10] = ore_sent[10] + 1

elseif colors.test(left, 1024 ) == true then
ore_sent[11] = ore_sent[11] + 1

elseif colors.test(left, 2048 ) == true then
ore_sent[12] = ore_sent[12] + 1

elseif colors.test(left, 4096 ) == true then
ore_sent[13] = ore_sent[13] + 1

elseif colors.test(left, 8192 ) == true then
ore_sent[14] = ore_sent[14] + 1

end
end
end

function Saving()

local update_timer = os.startTimer(1)
local full_timer = os.startTimer(60*5)
local timeleft = (60*5)
    
while true do

event, param = os.pullEvent()

if event == "timer" and param == update_timer then
update_timer = os.startTimer(1)
	    timeleft = timeleft - 1
	    end
	    if event == "timer" and param == full_timer then
	    print "Saving..."
        io.open("Quarry Log.txt", "r+")
        write(Ore[]"/n", Ore_Value[]"/n", Ore_Sent[]"/n")
        flush()
	    break
end
end

end

function Register_Menu()
while true do
term.clear()
term.setCursorPos(1,1)

Income_Counter()
Spending_Counter()

print "-------------------------------------------------"
print ("|			    Quarry Resister   "...timeleft..."	    |")
print "-------------------------------------------------"
print "|	   Ores	    Inbound	    Shipped	  |"
print ("| "Ore[1]"    "Ore_Value[1]"		  "Ore_Sent[1]"   |")
print ("| "Ore[2]"    "Ore_Value[2]"		  "Ore_Sent[2]"   |")
print ("| "Ore[3]"    "Ore_Value[3]"		  "Ore_Sent[3]"   |")
print ("| "Ore[4]"    "Ore_Value[4]"		  "Ore_Sent[4]"      |")
print ("| "Ore[5]"    "Ore_Value[5]"		  "Ore_Sent[5]"   |")
print ("| "Ore[6]"       "Ore_Value[6]"             "Ore_Sent[6]"     |")
print ("| "Ore[7]"    "Ore_Value[7]"          "Ore_Sent[7]"     |")
print ("| "Ore[8]"    "Ore_Value[8]"          "Ore_Sent[8]"     |")
print ("| "Ore[9]"    "Ore_Value[9]"	       "Ore_Sent[9]"     |")
print ("| "Ore[10]"   "Ore_Value[10]"	        "Ore_Sent[10]"   	  |")
print ("| "Ore[11]"   "Ore_Value[11]"		 "Ore_Sent[11]"	  |")
print ("| "Ore[12]"   "Ore_Value[12]"		 "Ore_Sent[12]"   	  |")
print ("| "Ore[13]"   "Ore_Value[13]"		 "Ore_Sent[13]"	  |")
print ("| "Ore[14]"   "Ore_Value[14]"		 "Ore_Sent[14]"	  |")
print "-------------------------------------------------"


event, param1, param2, param3 = os.pullEvent()
if event == "char" and param1 == "x" then break end
end
end

Register_Menu()
 
Advert #2
Posted 12 March 2012 - 04:17 AM
You need to keep track of the delta for the redstone changes: If the redstone is on two ticks in a row, you'll count twice.
You just want to count when it turns from off to on.
You'll also want to use fs./io. file handles; and "r+" is not supported (and, you can't write to r+ opened files).
These are from a glance, but I'll make a longer post in a bit (4:15 am :mellow:/>/>).


Edit: some more (potential) problems:

You'll want to remove the loop from Income_Counter and Spelding_Counter, since they'll lock the program.


Here are some code examples:

[post='2368']Using fs/fs objects[/post]

Getting delta:

--Doing with standard redstone; should be simple enough to convert it.
local last = false -- default to off
local counter = 0

if rs.testInput("back") and not last then
 -- Delta is 1; back input is true and last is false (not false -> true)
 counter = counter + 1
 print("Counter increased: ", counter)
end

last = rs.testInput("back")

You'll also want to put either sleep, or os.pullEvent() in there, to avoid termination:

local timerTable = os.startTimer(0.05) -- one tick
while true do
 -- your functions here;
 countIncoming()
 countOutgoing()
 displayStuff()
 for sEvent, a, b in os.pullEvent do -- This is a neat trick we can use to save some space:
   -- sEvent will be set to the first result when calling os.pullEvent
   -- a the second value, b the third, (c) the third, if we chose to capture it, etc.
   -- Note that we aren't calling os.pullEvent here! (no ()) - Closing ' to fix highlighting.
   -- We just want to pass the function to the for loop, so it can call it every new loop for us.
  if sEvent == "timer" and a == timerTable then
   -- It's the next tick; we can break out of this loop - Closing ' to fix highlighting.
   break
  end
 end
end
Ridous #3
Posted 12 March 2012 - 06:31 AM
No idea if what I just edited in did more damage than fix it xD
also put in some notes.

Spoiler

local right = rs.getBundledInput("right") --Servo to the right, inbound ore
local left = rs.getBundledInput("left") --Servo to the left, outbound resources


Ore = {Iron, Gold, Redstone, Coal, Diamond, Copper, Tin, Silver, Appitite,
Uranium, Nikalite, Ruby, Saphire, Emerald}

Ore_Value = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
Ore_Sent = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

function Income_Counter()
--incoming mechinism is using a powered golden
--not entirely sure that the gates can update and
--send a pipe signal to another gate to send the
--redstone cable signal.


--adds 1 everytime an ore passes through its gate
if colors.test(right, 1 ) == true then
Ore_Value[1] = Ore_Value[1] + 1
elseif colors.test(right, 2 ) == true then
Ore_Value[2] = Ore_Value[2] + 1
elseif colors.test(right, 4 ) == true then
Ore_Value[3] = Ore_Value[3] + 1
elseif colors.test(right, 8 ) == true then
Ore_Value[4] = Ore_Value[4] + 1
elseif colors.test(right, 16 ) == true then
Ore_Value[5] = Ore_Value[5] + 1
elseif colors.test(right, 32 ) == true then
Ore_Value[6] = Ore_Value[6] + 1
elseif colors.test(right, 64 ) == true then
Ore_Value[7] = Ore_Value[7] + 1
elseif colors.test(right, 128 ) == true then
Ore_Value[8] = Ore_Value[8] + 1
elseif colors.test(right, 256 ) == true then
Ore_Value[9] = Ore_Value[9] + 1
elseif colors.test(right, 512 ) == true then
Ore_Value[10] = Ore_Value[10] + 1
elseif colors.test(right, 1024 ) == true then
Ore_Value[11] = Ore_Value[11] + 1
elseif colors.test(right, 2048 ) == true then
Ore_Value[12] = Ore_Value[12] + 1
elseif colors.test(right, 4096 ) == true then
Ore_Value[13] = Ore_Value[13] + 1
elseif colors.test(right, 8192 ) == true then
Ore_Value[14] = Ore_Value[14] + 1

end
end

function Spending_Counter()
--this part will be using the same thing as the
--income counter. But connected to logistic pipes.
--Can't really tell which is faster, logistic or gold.'

--adds 1 for every resource sent
if colors.test(left, 1 ) == true then
Ore_Sent[1] = Ore_Sent[1] + 1
elseif colors.test(left, 2 ) == true then
Ore_Sent[2] = Ore_Sent[2] + 1
elseif colors.test(left, 4 ) == true then
Ore_Sent[3] = Ore_Sent[3] + 1
elseif colors.test(left, 8 ) == true then
Ore_Sent[4] = Ore_Sent[4] + 1
elseif colors.test(left, 16 ) == true then
Ore_Sent[5] = Ore_Sent[5] + 1
elseif colors.test(left, 32 ) == true then
Ore_Sent[6] = Ore_Sent[6] + 1
elseif colors.test(left, 64 ) == true then
Ore_Sent[7] = Ore_Sent[7] + 1
elseif colors.test(left, 128 ) == true then
Ore_Sent[8] = Ore_Sent[8] + 1
elseif colors.test(left, 256 ) == true then
Ore_Sent[9] = Ore_Sent[9] + 1
elseif colors.test(left, 512 ) == true then
Ore_Sent[10] = Ore_Sent[10] + 1
elseif colors.test(left, 1024 ) == true then
Ore_Sent[11] = Ore_Sent[11] + 1
elseif colors.test(left, 2048 ) == true then
Ore_Sent[12] = Ore_Sent[12] + 1
elseif colors.test(left, 4096 ) == true then
Ore_Sent[13] = Ore_Sent[13] + 1
elseif colors.test(left, 8192 ) == true then
Ore_Sent[14] = Ore_Sent[14] + 1

end
end

function Saving()

local update_timer = os.startTimer(1)
local full_timer = os.startTimer(60*5)
local timeleft = (60*5)
local sFile = "Quarry Log.txt" --will change it to a desktop dirctory folder
							   --keeping it short for now.
							  
while true do --will I need this loop?

event, param = os.pullEvent()

if event == "timer" and param == update_timer then
update_timer = os.startTimer(1)
	timeleft = timeleft - 1
	end
if event == "timer" and param == full_timer then
	if fs.exists(sFile) then
	print "Saving..."
	
	hWrite = fs.open(sFile, "a") -- "a" can be used to add onto the log right?
	hWrite.write("c%/n",Ore[]"/n", Ore_Value[]"/n", Ore_Sent[]"/n")
	--will I need to fill in the [ ] with the numbers or will it write them out?
	--eg. 12, 2, 45, 12, 66, 3, 4, 2, 1, 1, 0?
	
	flush()
	break
	
	else --this part is if I forget to make the file in the first place.
	print "Please create a log file titled.'Quarry Log.txt'/nThank you."

end
end
end
end

function Quick_Save()
--you never now when you'll b called away right?'

if fs.exists(sFile) then
	print "Quick Saving the current archive, please wait..."
	sleep(2)
	hWrite = fs.open(sFile, "a")
	hWrite.write("c%/n",Ore[]"/n", Ore_Value[]"/n", Ore_Sent[]"/n")
	flush()
	break
	
	else
	print "Please create a log file titled.'Quarry Log.txt'/nThank you."	
end
break --this goes here right?
end

function Register_Menu()

while true do
term.clear()
term.setCursorPos(1,1)

Income_Counter()
Spending_Counter()
Saving() -- <-- is it needed here at all or will the ...timeleft...
		 -- call for it by itself?

print "-------------------------------------------------"
print ("|				Quarry Resister   "...timeleft..."		|")
print "-------------------------------------------------"
print "|	   Ores		Inbound		Shipped	  |"
print ("| "Ore[1]"	"Ore_Value[1]"		  "Ore_Sent[1]"  |")
print ("| "Ore[2]"	"Ore_Value[2]"		  "Ore_Sent[2]"  |")
print ("| "Ore[3]"	"Ore_Value[3]"		  "Ore_Sent[3]"  |")
print ("| "Ore[4]"	"Ore_Value[4]"		  "Ore_Sent[4]"  |")
print ("| "Ore[5]"	"Ore_Value[5]"		  "Ore_Sent[5]"  |")
print ("| "Ore[6]"	"Ore_Value[6]"		  "Ore_Sent[6]"	 |")
print ("| "Ore[7]"	"Ore_Value[7]"		   "Ore_Sent[7]"	 |")
print ("| "Ore[8]"	"Ore_Value[8]"		   "Ore_Sent[8]"	 |")
print ("| "Ore[9]"	"Ore_Value[9]"			"Ore_Sent[9]"	 |")
print ("| "Ore[10]"   "Ore_Value[10]"		 "Ore_Sent[10]"	  |")
print ("| "Ore[11]"   "Ore_Value[11]"		 "Ore_Sent[11]"	  |")
print ("| "Ore[12]"   "Ore_Value[12]"		 "Ore_Sent[12]"	  |")
print ("| "Ore[13]"   "Ore_Value[13]"		 "Ore_Sent[13]"	  |")
print ("| "Ore[14]"   "Ore_Value[14]"		 "Ore_Sent[14]"	  |")
print "-------------------------------------------------"


event, param1, param2, param3 = os.pullEvent()
if event == "char" and param1 == "x" then Quick_Save() end
end
end

function Core()

--use Core() to run the whole thing or use Register Menu?
--I'm over thinking on this if the Menu terminates by itself thanks to
--line 150 'break' in Quick_Save()

local CoreTimer = os.statTimer(0.05)

	while true do

	Register_Menu()

		for sEvent, a, b in os.pullEvent do
			if sEvent == "timer" and a == CoreTimer then
			break
			end
		end
	end
end
	
Core()

Also, where can I find out how to use the handles properly? like the s in sEvent
Advert #4
Posted 12 March 2012 - 08:14 AM
No idea if what I just edited in did more damage than fix it xD
also put in some notes.

Spoiler

local right = rs.getBundledInput("right") --Servo to the right, inbound ore
local left = rs.getBundledInput("left") --Servo to the left, outbound resources


Ore = {Iron, Gold, Redstone, Coal, Diamond, Copper, Tin, Silver, Appitite,
Uranium, Nikalite, Ruby, Saphire, Emerald}

Ore_Value = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
Ore_Sent = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

function Income_Counter()
--incoming mechinism is using a powered golden
--not entirely sure that the gates can update and
--send a pipe signal to another gate to send the
--redstone cable signal.


--adds 1 everytime an ore passes through its gate
if colors.test(right, 1 ) == true then
Ore_Value[1] = Ore_Value[1] + 1
elseif colors.test(right, 2 ) == true then
Ore_Value[2] = Ore_Value[2] + 1
elseif colors.test(right, 4 ) == true then
Ore_Value[3] = Ore_Value[3] + 1
elseif colors.test(right, 8 ) == true then
Ore_Value[4] = Ore_Value[4] + 1
elseif colors.test(right, 16 ) == true then
Ore_Value[5] = Ore_Value[5] + 1
elseif colors.test(right, 32 ) == true then
Ore_Value[6] = Ore_Value[6] + 1
elseif colors.test(right, 64 ) == true then
Ore_Value[7] = Ore_Value[7] + 1
elseif colors.test(right, 128 ) == true then
Ore_Value[8] = Ore_Value[8] + 1
elseif colors.test(right, 256 ) == true then
Ore_Value[9] = Ore_Value[9] + 1
elseif colors.test(right, 512 ) == true then
Ore_Value[10] = Ore_Value[10] + 1
elseif colors.test(right, 1024 ) == true then
Ore_Value[11] = Ore_Value[11] + 1
elseif colors.test(right, 2048 ) == true then
Ore_Value[12] = Ore_Value[12] + 1
elseif colors.test(right, 4096 ) == true then
Ore_Value[13] = Ore_Value[13] + 1
elseif colors.test(right, 8192 ) == true then
Ore_Value[14] = Ore_Value[14] + 1

end
end

function Spending_Counter()
--this part will be using the same thing as the
--income counter. But connected to logistic pipes.
--Can't really tell which is faster, logistic or gold.'

--adds 1 for every resource sent
if colors.test(left, 1 ) == true then
Ore_Sent[1] = Ore_Sent[1] + 1
elseif colors.test(left, 2 ) == true then
Ore_Sent[2] = Ore_Sent[2] + 1
elseif colors.test(left, 4 ) == true then
Ore_Sent[3] = Ore_Sent[3] + 1
elseif colors.test(left, 8 ) == true then
Ore_Sent[4] = Ore_Sent[4] + 1
elseif colors.test(left, 16 ) == true then
Ore_Sent[5] = Ore_Sent[5] + 1
elseif colors.test(left, 32 ) == true then
Ore_Sent[6] = Ore_Sent[6] + 1
elseif colors.test(left, 64 ) == true then
Ore_Sent[7] = Ore_Sent[7] + 1
elseif colors.test(left, 128 ) == true then
Ore_Sent[8] = Ore_Sent[8] + 1
elseif colors.test(left, 256 ) == true then
Ore_Sent[9] = Ore_Sent[9] + 1
elseif colors.test(left, 512 ) == true then
Ore_Sent[10] = Ore_Sent[10] + 1
elseif colors.test(left, 1024 ) == true then
Ore_Sent[11] = Ore_Sent[11] + 1
elseif colors.test(left, 2048 ) == true then
Ore_Sent[12] = Ore_Sent[12] + 1
elseif colors.test(left, 4096 ) == true then
Ore_Sent[13] = Ore_Sent[13] + 1
elseif colors.test(left, 8192 ) == true then
Ore_Sent[14] = Ore_Sent[14] + 1

end
end

function Saving()

local update_timer = os.startTimer(1)
local full_timer = os.startTimer(60*5)
local timeleft = (60*5)
local sFile = "Quarry Log.txt" --will change it to a desktop dirctory folder
							   --keeping it short for now.
							  
while true do --will I need this loop?

event, param = os.pullEvent()

if event == "timer" and param == update_timer then
update_timer = os.startTimer(1)
	timeleft = timeleft - 1
	end
if event == "timer" and param == full_timer then
	if fs.exists(sFile) then
	print "Saving..."
	
	hWrite = fs.open(sFile, "a") -- "a" can be used to add onto the log right?
	hWrite.write("c%/n",Ore[]"/n", Ore_Value[]"/n", Ore_Sent[]"/n")
	--will I need to fill in the [ ] with the numbers or will it write them out?
	--eg. 12, 2, 45, 12, 66, 3, 4, 2, 1, 1, 0?
	
	flush()
	break
	
	else --this part is if I forget to make the file in the first place.
	print "Please create a log file titled.'Quarry Log.txt'/nThank you."

end
end
end
end

function Quick_Save()
--you never now when you'll b called away right?'

if fs.exists(sFile) then
	print "Quick Saving the current archive, please wait..."
	sleep(2)
	hWrite = fs.open(sFile, "a")
	hWrite.write("c%/n",Ore[]"/n", Ore_Value[]"/n", Ore_Sent[]"/n")
	flush()
	break
	
	else
	print "Please create a log file titled.'Quarry Log.txt'/nThank you."	
end
break --this goes here right?
end

function Register_Menu()

while true do
term.clear()
term.setCursorPos(1,1)

Income_Counter()
Spending_Counter()
Saving() -- <-- is it needed here at all or will the ...timeleft...
		 -- call for it by itself?

print "-------------------------------------------------"
print ("|				Quarry Resister   "...timeleft..."		|")
print "-------------------------------------------------"
print "|	   Ores		Inbound		Shipped	  |"
print ("| "Ore[1]"	"Ore_Value[1]"		  "Ore_Sent[1]"  |")
print ("| "Ore[2]"	"Ore_Value[2]"		  "Ore_Sent[2]"  |")
print ("| "Ore[3]"	"Ore_Value[3]"		  "Ore_Sent[3]"  |")
print ("| "Ore[4]"	"Ore_Value[4]"		  "Ore_Sent[4]"  |")
print ("| "Ore[5]"	"Ore_Value[5]"		  "Ore_Sent[5]"  |")
print ("| "Ore[6]"	"Ore_Value[6]"		  "Ore_Sent[6]"	 |")
print ("| "Ore[7]"	"Ore_Value[7]"		   "Ore_Sent[7]"	 |")
print ("| "Ore[8]"	"Ore_Value[8]"		   "Ore_Sent[8]"	 |")
print ("| "Ore[9]"	"Ore_Value[9]"			"Ore_Sent[9]"	 |")
print ("| "Ore[10]"   "Ore_Value[10]"		 "Ore_Sent[10]"	  |")
print ("| "Ore[11]"   "Ore_Value[11]"		 "Ore_Sent[11]"	  |")
print ("| "Ore[12]"   "Ore_Value[12]"		 "Ore_Sent[12]"	  |")
print ("| "Ore[13]"   "Ore_Value[13]"		 "Ore_Sent[13]"	  |")
print ("| "Ore[14]"   "Ore_Value[14]"		 "Ore_Sent[14]"	  |")
print "-------------------------------------------------"


event, param1, param2, param3 = os.pullEvent()
if event == "char" and param1 == "x" then Quick_Save() end
end
end

function Core()

--use Core() to run the whole thing or use Register Menu?
--I'm over thinking on this if the Menu terminates by itself thanks to
--line 150 'break' in Quick_Save()

local CoreTimer = os.statTimer(0.05)

	while true do

	Register_Menu()

		for sEvent, a, b in os.pullEvent do
			if sEvent == "timer" and a == CoreTimer then
			break
			end
		end
	end
end
	
Core()

Also, where can I find out how to use the handles properly? like the s in sEvent

sEvent just stands for "string Event"; it just makes the code more readable.

If you mean file handles, then read the post I linked you; if you have any questions or uncertainties about them, post in the tutorial thread, and I'll try to improve it.


Also; I forgot to add this to the code sample (currently it'll just do the timer once then do nothing):


  if sEvent == "timer" and a == timerTable then
   -- It's the next tick; we can break out of this loop - Closing ' to fix highlighting.
   timerTable = os.startTimer(0.05)
   break
  end