hello everyone, i ask many questions but i'm sorry, they are my first steps for lua programing :) ...
so i try somthing new, i have this :
[CODE]AttachmentListObject =
{
[1] = { Key = "bg_ak74_rpkbarrel", Name = "RPK barrel", Material = "atts/ak74_rpkbarrel" , Value = 500 },
[2] = { Key = "bg_ak74_ubarrel", Name = "AK74U barrel", Material = "atts/ak74_ubarrel" , Value = 500 },
[3] = { Key = "bg_ak74foldablestock", Name = "AK Fold Stock", Material = "atts/ak74foldablestock" , Value = 200 },
[4] = { Key = "bg_ak74heavystock", Name = "AK Heavy Stock", Material = "atts/ak74heavystock" , Value = 300 },
[5] = { Key = "bg_ak74rpkmag", Name = "AK Big Mag", Material = "atts/rpkmag" , Value = 200 },
[6] = { Key = "bg_ar1560rndmag", Name = "AR15 big mag", Material = "atts/ar1560rndmag" , Value = 600 },
[7] = { Key = "bg_ar15heavystock", Name = "M16 Stock", Material = "atts/ar15heavystock" , Value = 250 },
[8] = { Key = "bg_ar15sturdystock", Name = "M4 Stock", Material = "atts/ar15sturdystock" , Value = 160 },
[9] = { Key = "bg_longris", Name = "M16 Ris", Material = "atts/ar15longris" , Value = 350 },
[10] = { Key = "bg_longbarrel", Name = "M16 Barrel", Material = "atts/ar15longbarrel" , Value = 500 },
[11] = { Key = "bg_bipod", Name = "Bipod", Material = "atts/bipod" , Value = 150 },
[12] = { Key = "bg_deagle_compensator", Name = "Deagle Comp..", Material = "atts/deagle_compensator" , Value = 300 },
[13] = { Key = "bg_foldsight", Name = "M4A4 Sight", Material = "atts/foldsight" , Value = 100 },
[14] = { Key = "bg_longbarrelmr96", Name = ".44 Big Barrel",Material = "atts/longbarrel_revolver" , Value = 500 },
[15] = { Key = "bg_magpulhandguard",Name = "15 Magpull", Material = "atts/ar15magpul" , Value = 300 },
[16] = { Key = "bg_mp530rndmag", Name = "MP5 30Clip", Material = "atts/mp530rnd" , Value = 100 },
[17] = { Key = "bg_mp5_kbarrel", Name = "MP5K", Material = "atts/mp5_kbarrel" , Value = 500 },
[18] = { Key = "bg_mp5_sdbarrel", Name = "MP5SD", Material = "atts/mp5_sdbarrel" ,Value = 500 },
[19] = { Key = "bg_nostock", Name = "MP5 No stock", Material = "atts/nostock" , Value = 50 },
[20] = { Key = "bg_retractablestock", Name = "MP5 retractable", Material = "atts/mp5_sdbarrel" ,Value = 300 }
}[/CODE]
and, for testing this i have try a loop like this :
[CODE]
for i = 1, 10 do -- i want only the 10 first keys
print(AttachmentListObject.[i].Key)
end [/CODE]
but i have this error [CODE][ERROR] addons/gunmenu/lua/autorun/client/cl_menucreation.lua:113: '<name>' expected near '['
1. unknown - addons/gunmenu/lua/autorun/client/cl_menucreation.lua:0
[/CODE]
i have also try to name my index object like this
[CODE]AttachmentListObject =
{
AttObj1 = { Key = "bg_ak74_rpkbarrel", Name = "RPK barrel", Material = "atts/ak74_rpkbarrel" , Value = 500 },
AttObj2 = { -- etcc etcc
}
for i = 1, 10 do
print(AttachmentListObject.["AttObj" .. i ].Key)
end [/CODE]
but the console drop the same error ... :/
so how i can index this ? for my loop function :)
( also if you can tell me what i'm doing ? a big table or an object ? )
thanks for incoming responses :v:
[CODE]AttachmentListObject =
{
AttObj1 = { Key = "bg_ak74_rpkbarrel", Name = "RPK barrel", Material = "atts/ak74_rpkbarrel" , Value = 500 },
AttObj2 = { -- etcc etcc
}
for i = 1, 10 do
print(AttachmentListObject["AttObj" .. i ].Key)
end[/CODE]
Remove the point between AttachmentListObject and ["AttObj" .. i ]
FOUND ! :
[CODE]
print(AttachmentListObject["AttObj" .. i].Key) -- just deleted the point bettwen " AttachmentListObject" and " [AttObj......] "
[/CODE]
i'm sorry facepunch, if you want to delete my post or ban me you can, i will understand ! :)
[editline]26th June 2016[/editline]
[QUOTE=markusmarkusz;50599060]
Remove the point between AttachmentListObject and ["AttObj" .. i ][/QUOTE]
i have found at the same time as you ha ha !
but thanks :cat: :weeb:
Sorry, you need to Log In to post a reply to this thread.