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: Is there an easier way to find a "match" in a table

Previous Thread :: Next Thread 
KoreanBBQ is not online. KoreanBBQ
Joined: 06 Mar 2015
Total Posts: 1436
11 Aug 2015 12:41 PM
Other than something like,

local tableA={4,66,788,0}
for i,v in pairs(tableA)
if v==0 then
print("found 0")
end
end

~TreeBranch, Owner of Lady of the Federation x2+ Crown of Roses
Report Abuse
zarman3402 is not online. zarman3402
Joined: 18 May 2013
Total Posts: 1449
11 Aug 2015 12:50 PM
I think u did it easy enough, why?
Report Abuse
InsidersNetwork1001 is not online. InsidersNetwork1001
Joined: 25 Nov 2013
Total Posts: 1875
11 Aug 2015 01:01 PM
This is the Easiest way to do this type of thing.


InsidersNetwork1001 : Reskin Maker #NOFLOOR #DYNABLOX #NODEVENTS
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
11 Aug 2015 01:05 PM
local function getVal(tab, val)
for i, v in pairs(tab) do
if v == val then
return true
end
end
return false
end

local tab = {"yolo", 1337, "yos", workspace.Part}

if getVal(tab, workspace.Part) then
print("yes")
else
print("no")
end
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
11 Aug 2015 01:26 PM
Psst use rawequal it's more reliable
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
11 Aug 2015 01:31 PM
why rawequal yo
Report Abuse
cntkillme123 is not online. cntkillme123
Joined: 10 Feb 2013
Total Posts: 539
11 Aug 2015 01:32 PM
Don't do it! Don't use rawequal.
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
11 Aug 2015 01:50 PM
Because you're searching for a value in a table, not something that has an equivalence.
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
11 Aug 2015 01:52 PM
k then

local function getVal(tab, val)
for i, v in pairs(tab) do
if rawequal(v,val) then
return true
end
end
return false
end

local tab = {"yolo", 1337, "yos", workspace.Part}

if getVal(tab, workspace.Part) then
print("yes")
else
print("no")
end
Report Abuse
KoreanBBQ is not online. KoreanBBQ
Joined: 06 Mar 2015
Total Posts: 1436
11 Aug 2015 03:11 PM
Eh thought there would be something simplified like table.find() or i dont know what i was looking for


~TreeBranch, Owner of Lady of the Federation x2+ Crown of Roses
Report Abuse
LegitimatlyMe is not online. LegitimatlyMe
Joined: 30 Oct 2013
Total Posts: 1108
11 Aug 2015 03:12 PM
"table.find"

this is when warspy enters and tells about his module.
Report Abuse
lostend is not online. lostend
Joined: 21 Aug 2011
Total Posts: 8265
11 Aug 2015 03:28 PM
function tabFind(tab,val)
return table.concat(tab,' '):match(insertstringpatternhereo3o)~=nil
end
Report Abuse
BothAngles is not online. BothAngles
Joined: 01 Dec 2011
Total Posts: 9604
11 Aug 2015 03:29 PM
well unfortunately roblox wont be adding useful functions like those
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
11 Aug 2015 03:30 PM
Psst, warspy, perfect time to advertise
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
11 Aug 2015 03:32 PM
why should they add them when it takes less than a minute to make them yourself
either way yeah, warspy's ExtendedTable module is awesome.
Report Abuse
BothAngles is not online. BothAngles
Joined: 01 Dec 2011
Total Posts: 9604
11 Aug 2015 03:38 PM
^ That's not a valid argument
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