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: Can tables be put in a function

Previous Thread :: Next Thread 
LuaScriptCoding is not online. LuaScriptCoding
Joined: 23 Feb 2013
Total Posts: 38
24 Feb 2013 04:55 PM
?
Report Abuse
adark is not online. adark
Joined: 13 Jan 2008
Total Posts: 6412
24 Feb 2013 05:01 PM
How do you mean?
Report Abuse
LuaScriptCoding is not online. LuaScriptCoding
Joined: 23 Feb 2013
Total Posts: 38
24 Feb 2013 05:04 PM
Im new to tables but would this work.

status = {}

function alarm()

table.insert(status,1,"Activated")
table.insert(status,2,"Off")
wait()
if game.Workspace.Status.Value == 1 then
wait()
print(status[1])
-- more stuff
Report Abuse
animatedRobloxwinner is not online. animatedRobloxwinner
Joined: 28 Apr 2012
Total Posts: 997
24 Feb 2013 05:12 PM
Full code please
Report Abuse
LuaScriptCoding is not online. LuaScriptCoding
Joined: 23 Feb 2013
Total Posts: 38
24 Feb 2013 05:14 PM
status = {}
light = script.Parent
table.insert(status,1,"Activated")
table.insert(status,2,"Off")

function light()
wait()

if game.Workspace.Status.Value == 1 then
wait()
table.insert(status,1,"Activated")
table.insert(status,2,"Off")
wait()
light.BrickColor = BrickColor.new("Really red")
wait(0.9)
light.BrickColor = BrickColor.new("Really black")
print(status[1])
wait()
end
elseif game.Workspace.Status.Value == 0 then
wait()

print(status[2])

light.BrickColor = BrickColor.new("Really black")

game.Workspace.Status.Changed:connect(light)
end
end
Report Abuse
animatedRobloxwinner is not online. animatedRobloxwinner
Joined: 28 Apr 2012
Total Posts: 997
24 Feb 2013 05:16 PM
Try adding waits in the parentheses, and adding the variable into status's brackets.
Report Abuse
LuaScriptCoding is not online. LuaScriptCoding
Joined: 23 Feb 2013
Total Posts: 38
24 Feb 2013 05:17 PM
Can you even
Report Abuse
animatedRobloxwinner is not online. animatedRobloxwinner
Joined: 28 Apr 2012
Total Posts: 997
24 Feb 2013 05:20 PM
"Can you even"
status = {print"Bob"}
light = script.Parent
table.insert(status,1,"Activated")
table.insert(status,2,"Off")

function light()
wait(2)

if game.Workspace.Status.Value == 1 then
wait(0.3)
table.insert(status,1,"Activated")
table.insert(status,2,"Off")
wait(0.8)
light.BrickColor = BrickColor.new("Really red")
wait(0.9)
light.BrickColor = BrickColor.new("Really black")
print(status[1])
wait(0.3)
end
elseif game.Workspace.Status.Value == 0 then
wait(0.4)

print(status[2])

light.BrickColor = BrickColor.new("Really black")

game.Workspace.Status.Changed:connect(light)
end
end

Although this wouldn't work, you could.
Report Abuse
adark is not online. adark
Joined: 13 Jan 2008
Total Posts: 6412
25 Feb 2013 09:07 PM
Looking at that code, you phrased your question wrong. :P

Yes, functions can be put inside tables, after all, a function can be saved to a variable!

a = function() -- stoof end

is the same as

function a() -- stoof end

So the following statements work:

table = {}
table.functionAdd = function() -- stoof end
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
25 Feb 2013 10:07 PM
Do you mean can you put a function inside a table?

tab = {
blah = function(ex)
print(ex)
end
}
tab.blah("egggs")
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