Jump to content

[HELP]Table Problems


Dreamer

Recommended Posts

Hello!, I'm kinda new on this forums, but always look at topics about scripting, before asking.

So now i can't find answer to my question.

Here is the question:

How i can get tables used in order? For example, I want to use tables on gridlist. When i choose item in 1st gridlist(items from Table1), it triggers another table(Table2) to be used in 2nd gridlist, and then when i choose element on 2nd gridlist, it triggers new table(Table3) to be used in 3rd gridlist.

every item item in Table 1 (from gridlist) Triggers another table with specific data. I need atlest one way to trigger these tables. I could do with checking which table data been pressed on gridlist with if, but it would take a lot of space.

  
Table1 = { 
    [1] = "Table1:Data1", 
    [2] = "Table1:Data2", 
    [3] = "Table1:Data3", 
    [4] = "Table1:Data4", 
} 
Table2 = { 
    [1] = "Table2:Data1", 
    [2] = "Table2:Data2", 
    [3] = "Table2:Data3", 
    [4] = "Table2:Data4", 
} 
Table3 = { 
    [1] = "Table3:Data1", 
    [2] = "Table3:Data2", 
    [3] = "Table3:Data3", 
    [4] = "Table3:Data4",, 
} 
  
  
  
for key, value in ipairs(Table1) do 
                local rowc = guiGridListAddRow(Gridlist) 
                local ItemText = gettok(value, 1, string.byte(':')) 
                local ItemData = gettok(value, 2, string.byte(':')) 
                outputChatBox(tostring(value)) 
                guiGridListSetItemText(Gridlist,rowc,1,tostring(ItemText),false,false) 
                guiGridListSetItemData(Gridlist,rowc,1,tostring(ItemData)) 
            end 

i've been using this part of code, with much more tables.

Also as you can see i've been using numbers in table data keys, so i could use ipairs() function(i need to show data from tables shown in gridlist in order.

Hope you understood my question.

Link to comment
Hello!, I'm kinda new on this forums, but always look at topics about scripting, before asking.

So now i can't find answer to my question.

Here is the question:

How i can get tables used in order? For example, I want to use tables on gridlist. When i choose item in 1st gridlist(items from Table1), it triggers another table(Table2) to be used in 2nd gridlist, and then when i choose element on 2nd gridlist, it triggers new table(Table3) to be used in 3rd gridlist.

every item item in Table 1 (from gridlist) Triggers another table with specific data. I need atlest one way to trigger these tables. I could do with checking which table data been pressed on gridlist with if, but it would take a lot of space.

  
Table1 = { 
    [1] = "Table1:Data1", 
    [2] = "Table1:Data2", 
    [3] = "Table1:Data3", 
    [4] = "Table1:Data4", 
} 
Table2 = { 
    [1] = "Table2:Data1", 
    [2] = "Table2:Data2", 
    [3] = "Table2:Data3", 
    [4] = "Table2:Data4", 
} 
Table3 = { 
    [1] = "Table3:Data1", 
    [2] = "Table3:Data2", 
    [3] = "Table3:Data3", 
    [4] = "Table3:Data4",, 
} 
  
  
  
for key, value in ipairs(Table1) do 
                local rowc = guiGridListAddRow(Gridlist) 
                local ItemText = gettok(value, 1, string.byte(':')) 
                local ItemData = gettok(value, 2, string.byte(':')) 
                outputChatBox(tostring(value)) 
                guiGridListSetItemText(Gridlist,rowc,1,tostring(ItemText),false,false) 
                guiGridListSetItemData(Gridlist,rowc,1,tostring(ItemData)) 
            end 

i've been using this part of code, with much more tables.

Also as you can see i've been using numbers in table data keys, so i could use ipairs() function(i need to show data from tables shown in gridlist in order.

Hope you understood my question.

You don't need to add indexes if they're numbers and you can just use "next, table" in for-loop because it works for number and string indexed tables.

But I could not understand your problem, can you explain better?

Link to comment

ok, so tables could be like this Table1 = {"Table1:Data1","Table1:Data2","Table1:Data3",}.

I'll try to explain better, but i dont know how to do that.xD

I made up a gui window where is 3 gridlists.

when i click on item from 1st gridlist, then it takes table which is ment to that object in 1st gridlist and show up on 2nd gridlist its values.

for example:

 Table1 = {"Table1:Data1","Table1:Data2","Table1:Data3",} 
  
TableData1 = {} 
TableData2 = {} 
TableData3 = {} 
  
  

for each value in Table1 have thei own table with other values.

i'm making a window from wich to choose trucker job - Cargo, location from which have to deliver, and loacation to where to deliver)

Can someone give me link to upload screenshots? mine isnt working here :/

Hope this make a better sense.

Link to comment
ok, so tables could be like this Table1 = {"Table1:Data1","Table1:Data2","Table1:Data3",}.

I'll try to explain better, but i dont know how to do that.xD

I made up a gui window where is 3 gridlists.

when i click on item from 1st gridlist, then it takes table which is ment to that object in 1st gridlist and show up on 2nd gridlist its values.

for example:

 Table1 = {"Table1:Data1","Table1:Data2","Table1:Data3",} 
  
TableData1 = {} 
TableData2 = {} 
TableData3 = {} 
  
  

for each value in Table1 have thei own table with other values.

i'm making a window from wich to choose trucker job - Cargo, location from which have to deliver, and loacation to where to deliver)

Can someone give me link to upload screenshots? mine isnt working here :/

Hope this make a better sense.

Create in XML, it's easier.

Do something in this style:

<jobs> 
    <job name='Trucker'> 
        <location> 
            <from name='Somewhere in Los Santos' posX='2222' posY='2222' posZ='2222'/> 
            <delivery name='Somewhere in Las Venturas' posX='5555' posY='5555' posZ='5555'/> 
        </location> 
        <location> 
            <from name='Somewhere in San Fierro' posX='3333' posY='3333' posZ='3333'/> 
            <delivery name='Somewhere in Los Santos' posX='1111' posY='1111' posZ='1111'/> 
        </location> 
    </job> 
</jobs> 

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