1

The problem is on the client side code (src: cl_hob.lua)

net.Receive("HobNetMsg", function(len) 
    local Queue = {}
    Queue = net.ReadTable()
    for I = 1 , #Queue do 
        local index = Queue[I]["index"]
        for Key , Value in pairs(Queue[I]) do
            HBeamTable[index][Key] = Value
        end
    end
end)

The code is supposed to take net messages from my server side code hob.lua which contains a table of all the updates I want to make to the client side table HBeamTable. what the above code is supposed to do is look at the recived table, and then based on whats in there update the relevent tables in the main table with the new data.

The new data does not have to contain information for every single field, but the main table Must have a full set of data for every index otherwise the render function breaks.

however the code above outputs an error:

/cl_hob.lua:16: attempt to index a nil value

I don't see any obvious problems with the above code so that error is really confusing...

hjpotter92
  • 78,589
  • 36
  • 144
  • 183
Hobnob11
  • 80
  • 13
  • That error means that one of `Queue[I]` or `HBeamTable[index]` returned `nil` for some value of `I` or `index`. You can add debugging to that loop to find out which one. – Etan Reisner Mar 13 '15 at 11:24

1 Answers1

3

The error as reported is in line #16. Your code snippet is not relevant at all.

At line #14, you have:

for I = 0 , #Changes do

and lua tables are not indexed from 0. This raises the error.

hjpotter92
  • 78,589
  • 36
  • 144
  • 183