..:D&G:.. Posted March 2, 2016 Share Posted March 2, 2016 Hello guys, recently I noticed some scripts that used tables and pairs but I never seen them being used like this before. When I manipulate a table I do something like: for i, v in pairs(table) do v[1] = thePlayer v[2] = vehicle end But instead of using "v[number]", some scripts use "v.varName", like this one: for i,objectData in pairs(mapObjects) do local object = createObject(objectData.model,objectData.posX,objectData.posY,objectData.posZ,objectData.rotX,objectData.rotY,objectData.rotZ) May please someone explain to me how is this done? Thank you. Link to comment
Noki Posted March 2, 2016 Share Posted March 2, 2016 t = {["yes"] = 1, ["no"] = 0} t.yes --> 1 t["yes"] --> 1 t.no --> 0 t["no"] --> 0 It's just a different way of writing it. Link to comment
..:D&G:.. Posted March 2, 2016 Author Share Posted March 2, 2016 t = {["yes"] = 1, ["no"] = 0} t.yes --> 1 t["yes"] --> 1 t.no --> 0 t["no"] --> 0 It's just a different way of writing it. Lol, didn't know I could do that, 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