| |
|
adark
|
  |
| Joined: 13 Jan 2008 |
| Total Posts: 6412 |
|
| |
|
|
| 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 |
|
|
| |
|
|
| 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 |
|
|
|
| 24 Feb 2013 05:16 PM |
| Try adding waits in the parentheses, and adding the variable into status's brackets. |
|
|
| Report Abuse |
|
|
| |
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|