Snoozy Posted January 8, 2011 Share Posted January 8, 2011 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
Antibird Posted January 8, 2011 Share Posted January 8, 2011 The loading is all fine I tried outputting to chatbox the value of row[1] and it was 1 as supposed. Then, by some reasons, 'VehicleInfo[idx]' is not a table even while 'VehicleInfo' is. Link to comment
Snoozy Posted January 8, 2011 Author Share Posted January 8, 2011 Do I have to define VehicleInfo[idx] of some sort? If so mind showing me how or giving me a hint? Link to comment
SDK Posted January 8, 2011 Share Posted January 8, 2011 Yes, VehicleInfo[idx] is nil, so you're trying to get nil["VehID"] which is impossible. You need to define a table inside the first table: VehicleInfo = {} .... VehicleInfo[idx] = {} VehicleInfo[idx].VehID = row[1] ... Link to comment
Snoozy Posted January 8, 2011 Author Share Posted January 8, 2011 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
Discord Moderators Zango Posted January 8, 2011 Discord Moderators Share Posted January 8, 2011 table index is nil > VehicleInfo[idx][VehID] = row[1] Link to comment
SDK Posted January 8, 2011 Share Posted January 8, 2011 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
Snoozy Posted January 8, 2011 Author Share Posted January 8, 2011 Doh... just doh didn't notice that it was [VehID] and not ["VehID"] haha sorry. Thanks Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now