'LinKin Posted November 27, 2013 Share Posted November 27, 2013 Hello, I've a small trouble. local listMaps = exports.mapmanager:getMapsCompatibleWithGamemode(exports.mapmanager:getRunningGamemode() ) This is a complete list of the maps, in my case the gamemode is 'Race'. I created a table, and in it, I will insert some maps; Like this: local myTable = { } for i, map in ipairs (listMaps) do if getResourceInfo(map, "name") == mapName(*) then // custom code...Puts the map in myTable. end end So far works good. But when I want to remove a map from my custom table, I use the following: if getResourceInfo(myTable[1][1], "name") == mapSelected(*) then // custom code end But the in-game debugger tells me this error: ERROR: myscript\server.lua:145: attempt to index field '?' (a userdata value) The line 145 is if getResourceInfo(myTable[1][1], "name") == mapSelected then ______________________________________________________________________________________________________________ (*): mapName & mapSelected are strings that I give (i.e [DD] Cross) Link to comment
Castillo Posted November 27, 2013 Share Posted November 27, 2013 That doesn't really make much sense to me, could you post your code? if you don't want others to take the code, send it over PM. Link to comment
glowdemon1 Posted November 27, 2013 Share Posted November 27, 2013 Perhaps try https://wiki.multitheftauto.com/wiki/GetResourceName - but as solid said, it's kind of un-understandable atm. Link to comment
'LinKin Posted November 28, 2013 Author Share Posted November 28, 2013 Solved. I was treating 'myTable' as a vector, not a matrice. So by the time it was making this condition; if getResourceInfo(myTable[1][1], "name") == mapSelected then It was trying to access a position that did not exist. As a vector, when trying to access a position you gotta do it like this; myTable[index] That's why the error was similar to what Java says when you try accessing to a non-existing position; ERROR: myscript\server.lua:145: attempt to index field '?' (a userdata value) Thank you guys for the interest. - Little mistakes that we commit Link to comment
Woovie Posted November 29, 2013 Share Posted November 29, 2013 Userdata is elements iirc. It may be other things too. Link to comment
myonlake Posted November 29, 2013 Share Posted November 29, 2013 Userdata is elements iirc. It may be other things too. Lua provides a basic type specifically for this: userdata. A userdatum offers a raw memory area with no predefined operations in Lua. I've experienced userdata when outputting an array, an element, some weird variables. It's just about everything miscellaneous as far as I can see. And like it says ".. with no predefined operations..", so it's pretty much like that. But yeah, glad you got it fixed. 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