robber4
|
  |
| Joined: 20 Jun 2008 |
| Total Posts: 203 |
|
|
| 13 Aug 2013 10:04 AM |
I try to call 2 functions at once, using one function.
function main() derp() derp2() end
It never works. The first one, derp() in this case is the only one that is fired. I did this:
derp() wait() derp2()
but that didn't work either. Is there a way to do this? |
|
|
| Report Abuse |
|
|
| |
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 13 Aug 2013 10:08 AM |
function derp() print("Derp") end function derp2() print("Derp2") end function main() print("Main") derp() derp2() end main()
Did you have both derp functions? And did you remember to call the main function? What I pasted runs. |
|
|
| Report Abuse |
|
|
robber4
|
  |
| Joined: 20 Jun 2008 |
| Total Posts: 203 |
|
|
| 13 Aug 2013 10:10 AM |
| I just figured it out. It was coroutines that did the trick. |
|
|
| Report Abuse |
|
|
|
| 13 Aug 2013 10:10 AM |
@Lord
function derp() wait(1) print("Derp") end function derp2() print("Derp2") end function main() print("Main") derp() derp2() end main()
He wants it to print Derp2 before Derp1 |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 13 Aug 2013 10:20 AM |
No, I believe he wants it to print Derp before Derp2, and your code does exactly the same thing as mine except it won't print the two derps until a second after.
Furthermore, I don't think he really cares about printing "Derp". I think he just wanted to see how/if it is possible to call a function that calls two functions inside of it. |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 13 Aug 2013 10:21 AM |
| And now he's using coroutines to solve a problem that does not need them. |
|
|
| Report Abuse |
|
|
| |
|
|
| 13 Aug 2013 10:21 AM |
| Hence "Two functions at once" |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 13 Aug 2013 10:25 AM |
| He wanted to call two functions at once, not necessarily run two functions at once. It's very possible that he was unclear and wanted to run two functions at once, but I can only go off of what he told us in the thread. Each way could produce very different results. |
|
|
| Report Abuse |
|
|