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: how to run functions in table

Previous Thread :: Next Thread 
Xnite515 is not online. Xnite515
Joined: 18 Feb 2011
Total Posts: 22763
13 Jun 2013 10:47 PM
local table = {

"blah",
--blah

}

how to run "blah"? i've seen xsixx do it.
Report Abuse
BlueTaslem is not online. BlueTaslem
Joined: 11 May 2008
Total Posts: 11060
13 Jun 2013 10:56 PM
What do you mean by 'run'?
A string is not a function, so it can't be 'run'.
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
13 Jun 2013 10:57 PM
local Table = {Blah = function() print("Blah") end}
Table.Blah()
Report Abuse
Xnite515 is not online. Xnite515
Joined: 18 Feb 2011
Total Posts: 22763
13 Jun 2013 10:57 PM
execute

"blah"
--blah holds all of this code

how to run code in blah in table

adasdasd
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
13 Jun 2013 10:58 PM
local tab {
        blah = function(val)
                print(val)
        end
}

tab.blah("lol")

http://wiki.roblox.com/index.php/User:ElectricBlaze
Report Abuse
Xnite515 is not online. Xnite515
Joined: 18 Feb 2011
Total Posts: 22763
13 Jun 2013 10:58 PM
@mr

will it work for string as the name?
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
13 Jun 2013 10:59 PM
No.
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
13 Jun 2013 10:59 PM
Typo:

local tab {
        blah = function(val)
                 print(val)
        end
}

tab.blah("lol")

http://wiki.roblox.com/index.php/User:ElectricBlaze
Report Abuse
Xnite515 is not online. Xnite515
Joined: 18 Feb 2011
Total Posts: 22763
13 Jun 2013 11:04 PM
http://www.roblox.com/xSIXx-Admin-item?id=119023775

please tell me how xsixx did it then..
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
13 Jun 2013 11:06 PM
Take a good look at the GetCmd function starting on line 534.

http://wiki.roblox.com/index.php/User:ElectricBlaze
Report Abuse
Xnite515 is not online. Xnite515
Joined: 18 Feb 2011
Total Posts: 22763
13 Jun 2013 11:09 PM
i dont see were he is calling it though
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
13 Jun 2013 11:16 PM
Here's an example.

for i,v in pairs(commands) do
        if cmd == v[1] then
                finalcmd = v[1]
                funccmd = v[2]
                break
        end
end

Now, the structure of the table commands is:

local commands = {
        {
                "name",
                function func_name()
                        --code here
                end
        },
        {
                "name2",
                function func2_name()
                        --code here
                end
        }
}

Now, the variable v would be the tables inside the main table. v[1] would be the strings "name" and "name2". v[2] would be the two functions. Both the variables finalcmd (the name) and funccmd (the function) are returned.

Then look at the function OnChat starting at line 591. Here's a snippet.

cmd, func, args = GetCmd(msg)
if cmd and func and args then
        if cmd == "script" then
                       func(spe, args[1])

cmd is the name from before. func is the function from before. Ignore args. If the name is script, it calls the function.

And that answers your question.

http://wiki.roblox.com/index.php/User:ElectricBlaze
Report Abuse
mummymark is not online. mummymark
Joined: 10 Sep 2011
Total Posts: 610
13 Jun 2013 11:24 PM
local message = Instance.new('Message', game.Workspace)
message.Text = "blah blah blah blah blah functions are cool"
Report Abuse
Xnite515 is not online. Xnite515
Joined: 18 Feb 2011
Total Posts: 22763
13 Jun 2013 11:25 PM
THANK YOU

I GOT IT TO WORK.

Report Abuse
Xnite515 is not online. Xnite515
Joined: 18 Feb 2011
Total Posts: 22763
13 Jun 2013 11:25 PM
@elec
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
13 Jun 2013 11:27 PM
No problem. ;)

http://wiki.roblox.com/index.php/User:ElectricBlaze
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