generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Go through table

Previous Thread :: Next Thread 
haskjdfsask is not online. haskjdfsask
Joined: 08 Jun 2014
Total Posts: 810
10 Feb 2017 09:45 PM
table={
a=23
v=38
hehe="lol"
sos=workspace.Part
}

for i=1,#table do
print(table[i])
end


Al table contents are nil values? what? How do I iterate through a table like this without knowing the variable name?
Report Abuse
Intended_Pun is not online. Intended_Pun
Joined: 10 Aug 2016
Total Posts: 4384
10 Feb 2017 09:47 PM
for i,v in pairs (table) do

end

????
Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
10 Feb 2017 09:47 PM
for index, value in pairs(table) do
end

iterating through a dictionary with a numerical for loop doesn't work because table[1] doesn't exist; only table[a], table[v] and so on


Report Abuse
haskjdfsask is not online. haskjdfsask
Joined: 08 Jun 2014
Total Posts: 810
10 Feb 2017 09:51 PM
table={
a=23
v=38
hehe="lol"
sos=workspace.Part
}

for index, value in pairs(table) do
print(table[index])
print(table[value])
end


prints nil...
Report Abuse
haskjdfsask is not online. haskjdfsask
Joined: 08 Jun 2014
Total Posts: 810
10 Feb 2017 09:52 PM
wait I've got it, thanks

Report Abuse
Intended_Pun is not online. Intended_Pun
Joined: 10 Aug 2016
Total Posts: 4384
10 Feb 2017 09:53 PM
for i,v in pairs (table) do
print(i)
print(v)
end

i is the table index, v is the value.
Report Abuse
Equilibristic is not online. Equilibristic
Joined: 03 Sep 2010
Total Posts: 750
10 Feb 2017 09:54 PM
define val of i


Report Abuse
haskjdfsask is not online. haskjdfsask
Joined: 08 Jun 2014
Total Posts: 810
10 Feb 2017 10:02 PM
wait

table={
a={"a","b","c"}
b={"d","e","f"}
c={"g","h","i"}
}

for i,v in pairs (table) do
print(table[i][math.random(1,#table[i])]))
end


this only prints a,d,g? Never prints b,e,h,c,f,i
Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
10 Feb 2017 10:03 PM
seed the generator with math.randomseed(tick())


Report Abuse
haskjdfsask is not online. haskjdfsask
Joined: 08 Jun 2014
Total Posts: 810
10 Feb 2017 10:13 PM
DOESN'T work for some odd reason. It chooses one random character from the subtables, then reuses it again without choosing random, while I instructed it to INDIV={ --ignore the dots, they're just for style O={"o.1","o.2","o.3","o.4","o.5","o.6"}, E={"e.1","e.2","e.3","e.4","e.5","e.6"}} input="OOOOeeeeOOOOOOOooooOOOOOOOOOO" local str=string.upper(input) for i,v in pairs (INDIV) do print(i,INDIV[i][1])--words to replace, replacements if ################## then ################################################## end end output: #################################################################################
Report Abuse
haskjdfsask is not online. haskjdfsask
Joined: 08 Jun 2014
Total Posts: 810
10 Feb 2017 10:14 PM
You've got to be kidding me, worthless good-for-nothing filter ####### ######################################## ####################################### } input="OOOOeeeeOOOOOOOOOOOOOOOOOOO" local str=string.upper(input) for i,v in pairs (INDIV) do ########################### to replace, replacements if ################## then ################################################## end end ########## OUTPUT: #######################################################################
Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
10 Feb 2017 10:14 PM
the hell u tryna do bro


Report Abuse
haskjdfsask is not online. haskjdfsask
Joined: 08 Jun 2014
Total Posts: 810
10 Feb 2017 10:17 PM
oh my GOD! WHAT, I'M NOT EVEN SWEARING!!!!!!! I'll send you a link to # model instead, this is hopeless. ############################################# ##### last try ####### ######################################## ######################################## input="eeeeOOOOOOOOOOOOOOOOOOO" local str=string.upper(input) for i,v in pairs (INDIV) do ########################### to replace, replacements if string.find(str,i) then ################################################## end end ##########
Report Abuse
haskjdfsask is not online. haskjdfsask
Joined: 08 Jun 2014
Total Posts: 810
10 Feb 2017 10:17 PM
https://www.roblox.com/library/649598183/same-result-weird
Report Abuse
Intended_Pun is not online. Intended_Pun
Joined: 10 Aug 2016
Total Posts: 4384
10 Feb 2017 10:17 PM
LOL
Sorry man I know it sucks
Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
10 Feb 2017 10:18 PM
dude put it in pastebin or something i'm too lazy to go into studio


Report Abuse
haskjdfsask is not online. haskjdfsask
Joined: 08 Jun 2014
Total Posts: 810
10 Feb 2017 10:20 PM
pastebin
.
com
/uYNnwGWF
Report Abuse
haskjdfsask is not online. haskjdfsask
Joined: 08 Jun 2014
Total Posts: 810
10 Feb 2017 10:21 PM
I think I know what's going on here. string:gsub replaces them all at once with the same value. How do I change that?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image