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
 

Re: Tables help

Previous Thread :: Next Thread 
skate1011 is not online. skate1011
Joined: 13 Mar 2010
Total Posts: 688
08 Sep 2012 09:42 PM
well here I have a script that I made that should print the functions that are in the tables but it won't work. So here is the script anyone know anything?

funcs = {}
funcs.hi = function hi() print("Hi") end;
funcs.hello = function hello() print("Hello") end

for _, v in ipairs(funcs) do
print(v.hi, v.hello)
end


wiki.roblox.com
Report Abuse
adark is not online. adark
Joined: 13 Jan 2008
Total Posts: 6412
08 Sep 2012 09:47 PM
Nothing will print for two reasons:

1) 'ipairs' only allows for numerical identifiers. You should use 'pairs'
2) Your 'v' variable in the loop would *be* 'funcs.hi' or 'funcs.hello', so you would just do 'print(v)' to print the function.
Report Abuse
skate1011 is not online. skate1011
Joined: 13 Mar 2010
Total Posts: 688
08 Sep 2012 09:50 PM
so I have this so far. But it still errors.

funcs = {}
funcs.hi = function hi() print("Hi") end;
funcs.hello = function hello() print("Hello") end

for i, v in pairs(funcs) do
print(v)
end


wiki.roblox.com
Report Abuse
adark is not online. adark
Joined: 13 Jan 2008
Total Posts: 6412
08 Sep 2012 09:52 PM
Forgot this the first time, but you are naming your functions twice.
Report Abuse
skate1011 is not online. skate1011
Joined: 13 Mar 2010
Total Posts: 688
08 Sep 2012 09:53 PM
So what would it be?

wiki.roblox.com
Report Abuse
adark is not online. adark
Joined: 13 Jan 2008
Total Posts: 6412
08 Sep 2012 09:54 PM
function()
Report Abuse
skate1011 is not online. skate1011
Joined: 13 Mar 2010
Total Posts: 688
08 Sep 2012 09:57 PM
how would I call it from the string? Just like funcs.hi ?

wiki.roblox.com
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
08 Sep 2012 10:01 PM
local functions = {function hi() print("hi") end, function hello() print("hello") end}

functions[math.random(#functions)]()
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