DuFraN Posted May 11, 2014 Share Posted May 11, 2014 Hi guys, i have a problem, can't get a table value, here is my table. local Tabla_Marcadores = { { [1]={2893,-911,10,"cylinder",5,255,150,0,255},{2993,-911,10,"cylinder",5,255,150,0,255} }, { [2]={2793,-911,10,"cylinder",5,255,150,0,255},{2693,-911,10,"cylinder",5,255,150,0,255} } } i want calculate a random value, later calculate the first and second table of the random value and also introduce these arguments of the table here: createMarker. Can someone give me an example? Link to comment
Mr_Moose Posted May 11, 2014 Share Posted May 11, 2014 You have two indexes to access each single value in that table, first one is the number within [ and ] and secondly you have the comma separated list of values: Tabla_Marcadores[1][1] -- Returns the following value: 2893 Tabla_Marcadores[2][4] -- Returns the following value: "cylinder" #Tabla_Marcadores -- returns the number of rows (2) #Tabla_Marcadores[1] -- returns the number of columns in row 1 math.random(#Tabla_Marcadores) -- a random index from 1 to the length of your table. Beside this it seems like your table has syntax errors. Try change it into this: local Tabla_Marcadores = { [1]={2893,-911,10,"cylinder",5,255,150,0,255}, [2]={2993,-911,10,"cylinder",5,255,150,0,255}, [3]={2793,-911,10,"cylinder",5,255,150,0,255}, [4]={2693,-911,10,"cylinder",5,255,150,0,255} } And apply the above methods to access the values in it. 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