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 » Scripting Helpers
Home Search
 

Return Table Match

Previous Thread :: Next Thread 
thumper10 is not online. thumper10
Joined: 17 Apr 2009
Total Posts: 3304
21 Nov 2012 05:55 PM
I'm currently working on a Command Script for a group I'm in, but I have quite a few tables, and I was wondering if is possible to use one, global method than to create multiple methods for each table. I looked into it, and it sometimes works, sometimes doesn't. Code:
-- This method sometimes returns nil even if I enter the same exact value and table name
local users = { "thumper10", "DeltaSabre" }
local banned = { "Shedletsky" }

function isInTable(tableName, stringToFind)
local s = stringToFind
if (tableName == nil) then return nil end
local t = tableName
for a = 1, #t do
if (s:lower() == t[a]:lower()) then
return true
end
return false
end
end

OUTPUT:
print(isInTable(users, "thumper10"))
> true
FIVE OR SO TIMES LATER:
print(isInTable(users, "thumper10"))
> nil

Any idea what's causing this? Thanks in advance!

= C# All Day Everyday =
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
21 Nov 2012 06:11 PM
function isInTable(tableName, stringToFind)
local s = stringToFind
if (tableName == nil) then return nil end
local t = tableName
for a = 1, #t do
if (s:lower() == t[a]:lower()) then
return true
end
end
return false
end








?
Report Abuse
thumper10 is not online. thumper10
Joined: 17 Apr 2009
Total Posts: 3304
21 Nov 2012 06:17 PM
^ That did it. I guess having the return false there was causing random issues. Thank you.

= C# All Day Everyday =
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
21 Nov 2012 07:34 PM
It doesn't make sense though. It should still have returned nil. o.o
Report Abuse
thumper10 is not online. thumper10
Joined: 17 Apr 2009
Total Posts: 3304
21 Nov 2012 07:53 PM
I think ROBLOX is playing mind games...

= C# All Day Everyday =
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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