The error: I keep getting "bios:267: Attempt to write to global" and I cannot track down the source
Spoiler
Ok I'm attempting to do some processing on a table but only when there is data in it. I have 2 threads, one is populating the table with data from a network connection, the other is processing the data in the table one at a time and removing it when done. I am having some issues at the moment checking if the table is empty. I have done everything I know possible, and even Googled how to do it, but all methods of checking return this "bios:267: Attempt to write to global". I have tried the following:
-- Table declaration
tasks = {}
-- Method of inserting
table.insert(tasks, message)
-- Attempt 1
function empty (self)
for _, _ in pairs(self) do
return false
end
return true
end
local function processor()
while true do
if (not empty(tasks)) then
-- Do stuff
end
end
end
-- Attempt 2
local function processor()
while true do
if (#tasks == 0) then
-- Do stuff
end
end
end
-- Attempt 3
local function processor()
while true do
if (table.len(tasks) == 0) then
-- Do stuff
end
end
end
-- Attempt 4
local function processor()
while true do
if ( not (next(tasks) == nil )) then
-- Do stuff
end
end
end
-- Attempt 5
local function processor()
while true do
if ( next(tasks) ~= nil ) then
-- Do stuff
end
end
end
-- Attempt 6 (I knew this wouldn't work due to my extensive knowledge in both procedural and OO programming, but I figured hey lets try everything)
local function processor()
while true do
if ( tasks == {} )) then
-- Do stuff
end
end
end
Any help here would be great. :)/>