Jump to content

attempt to index field '?' (a nil value)


Snoozy

Recommended Posts

I got a problem with attempting to store data.

VehicleInfo = {}; 

I'm currently creating a vehicle loading system but have been having problems making it work so I've debugged every single line in the loading and now I have reached a part I'm unable to fix.

The location that I receive this error is:

VehicleInfo[idx].VehID = row[1] 

There are serveral of those ofcourse but that is the first and that's where the error starts.

The loading is all fine I tried outputting to chatbox the value of row[1] and it was 1 as supposed.

Link to comment

Just tried to do following, don't know if that's what you mean tho:

for idx=1, maxve do 
VehicleInfo[idx] = {}; 

A bit later up in the script after a few querys and if statements

VehicleInfo[idx][VehID] = row[1] 

Tho now I receive the error:

table index is nil 

EDIT: and also VehicleInfo = {};

is at start of the whole function

Link to comment

Yes, but now you changed your index name, that's some basic Lua table stuff.

VehicleInfo[idx].VehID = row[1]  -- this is the same as : 
VehicleInfo[idx]["VehID"] = row[1] 
-- but NOT the same as: 
VehicleInfo[idx][VehID] = row[1] 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...