Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I get an array without using a i,v loop?

Asked by 5 years ago
Edited by M39a9am3R 5 years ago

So I know in a table

Table = {ScriptingHelperAdminsAreSoBad = 'I Know Right', DevForumAdminsAreBetter = 'Yes'}

-- You can just do

print(Table.DevForumAdminsAreBetter)
--or
print(Table['DevForumAdminsAreBetter'])


But what if I had a table array like this


local Tab = {'G','F','G','E','C','T',"T",'G','I','F',"F",'R','GucciGang',"I",'D','A','Y'}

How would I print GucciGang right away since I cant just do

Tab.GucciGang since there is no key

0
"Table = {ScriptingHelperAdminsAreSoGay = 'I Know Right'", lol LoganboyInCO 150 — 5y
0
Well, if you would follow the rules and not do stuff that would break them, there would not be a problem. Post edited for content in violation of Global Guidelines Rule #1. M39a9am3R 3210 — 5y

2 answers

Log in to vote
1
Answered by 5 years ago

Here, the index position would actually be just sequential numbers, but if you don't want to use in pairs, you could do this:

local Tab = {'G','F','G','E','C','T',"T",'G','I','F',"F",'R','GucciGang',"I",'D','A','Y'}

for index = 1, #Tab do
if Tab[index] == "GucciGang" then
    print(index, "GucciGang")
end
Ad
Log in to vote
0
Answered by
Abandion 118
5 years ago

You can't find a table entry with a specific value without iteration, iirc.

Answer this question