Jump to content

[HELP] need help with createObject from table


kuwalda

Recommended Posts

Nevermind, fixed it by myself :)

Okey, so I have this table which stores all my objects and some aditional info.

Table info stored like this (shortened for better understanding):

SafeHouseGarageV1 = { } 
SafeHouseGarageV1["info"] = { .., .., .. } 
SafeHouseGarageV1[1] = createObject(..) 
SafeHouseGarageV1[2] = createObject(..) 
SafeHouseGarageV1[3] = createObject(..) 

I have script, where I need to find which checkpoint player hit. After script have found it out, I replace that long code with variable. And my problem is - how can I create those objects using "for" loop? I have tried to do it countless times, still failing.

My code (shortened for better understanding):

  
local garage = _G[getElementData(source, "representingGarage")] 
  
if garage and type(garage) == 'table' then 
    for id, object in pairs(garage) do 
        setElementDimension(_G[object], representingGarageID) 
    end 
return id, object 
end 
  

Any help would be appriciated, because this is driving me crazy, for countless attempts to fix it.

EDIT:

I found out example in forums and it looked like this:

    local tMarkers = 
    { 
        { nX = 0, nY = 0, nZ = 10 }; 
        { nX = 200, nY = 200, nZ = 20 }; 
    } 
      
    for _, t in pairs( tMarkers ) do 
        createMarker ( t.nX, t.nY, t.nZ ) 
    end 

How can I just make this example work, without those nX,nY,nZ prefixes?

Link to comment

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