Jump to content

[HELP] Table question


Recommended Posts

Posted

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? xD

Thank you.

Posted
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.

Posted
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 :D

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...