ROBOFROG
|
  |
| Joined: 04 Jan 2009 |
| Total Posts: 1519 |
|
|
| 07 Jul 2015 01:35 AM |
| Basically, if you create an if statement which is reliant on a return from a function (such as if testfunction(x) == "true"), will the if statement wait for the called function to return something, or will it only take its current value into consideration and move on? |
|
|
| Report Abuse |
|
|
|
| 07 Jul 2015 01:40 AM |
| You call a function after it has already been created. So therefore it's already true. |
|
|
| Report Abuse |
|
|
AnimeWiki
|
  |
| Joined: 26 Oct 2014 |
| Total Posts: 460 |
|
|
| 07 Jul 2015 01:46 AM |
I wish you could do this but it returns thread :(
local x = coroutine.create(function() wait(1) return true end)
coroutine.resume(x)
repeat wait() until coroutine.status(x) == "dead"
print(x == true) |
|
|
| Report Abuse |
|
|
ROBOFROG
|
  |
| Joined: 04 Jan 2009 |
| Total Posts: 1519 |
|
|
| 07 Jul 2015 01:57 AM |
| So basically, in that context, it will always return true as long as the function exists, no matter its return? |
|
|
| Report Abuse |
|
|
AnimeWiki
|
  |
| Joined: 26 Oct 2014 |
| Total Posts: 460 |
|
| |
|
ganger800
|
  |
| Joined: 06 Dec 2012 |
| Total Posts: 427 |
|
|
| 07 Jul 2015 03:56 AM |
first let me fix it unless your function returns a string containing the word "true" I don't think this is what you want if testfunction(x) == "true" then end
you probably want this: if testfunction(x) then end
answer to the question: yes it will wait, since it will do something like this: - if statement started - calls function - uses return to fill the statement, continues however this is try with a function call
when you do if testfunction then end you take the memory address (no function call) and your script will run without waiting |
|
|
| Report Abuse |
|
|
|
| 07 Jul 2015 04:03 AM |
if its in a function it waits
<3 cats <3 |
|
|
| Report Abuse |
|
|
AnimeWiki
|
  |
| Joined: 26 Oct 2014 |
| Total Posts: 460 |
|
|
| 07 Jul 2015 04:05 AM |
@ganger800
ganger chan did i make bad thing :( |
|
|
| Report Abuse |
|
|
ROBOFROG
|
  |
| Joined: 04 Jan 2009 |
| Total Posts: 1519 |
|
|
| 07 Jul 2015 01:45 PM |
| I appreciate the help, everybody! It was a confusing for a bit, but it's now cleared up with the best outcome possible. |
|
|
| Report Abuse |
|
|