Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I check if a function finishes or not?

Asked by 7 years ago

Hello. I would like to see if a function finishes or not. For example, this passed through

while true do wait() end

would return false, because it never finishes. But this

print("hello")

would return true, because it does finish. Any ideas?

0
Not sure you can. Why would you need to? You can always spawn() a function so that even if it never does end, the script could still continue. OldPalHappy 1477 — 7y
0
I'm making a Script Builder place, and I want the player to know their script won't finish and ask if they still want to execute it. This is a highly demanded feature people have asked for. Kampfkarren 215 — 7y
0
It can be done in Haskell, which is a functional programming language. NotInventedHere 158 — 7y
0
" I want the player to know their script won't finish" Infinite loops are usually not an error but a standard practice in all games to keep things moving. There's no need for that. cabbler 1942 — 7y
View all comments (4 more)
0
But sometimes a player doesn't intend to. That's why they asked me to create this feature to warn them. Kampfkarren 215 — 7y
0
I can only think of possible ways to be if you can scan the code and detect if a while loop or any loop that wont end is being used. Like if a condition will never be met by searching for key words, don't know if this helps you though. alphawolvess 1784 — 7y
0
I hate to be the one to break it to you, but this is impossible. This is a variation of the infamous 'Halting Problem' by Alan Turing, the father of theoretical computer science. https://en.wikipedia.org/wiki/Halting_problem duckwit 1404 — 7y
0
One way to understand it in this context is thus: in the general case, you can only check if a loop terminates by running the loop. But if the loop doesn't terminate, then neither will the program which is trying to check if it terminates. duckwit 1404 — 7y

1 answer

Log in to vote
-1
Answered by 7 years ago

check the command bar and run the game...see if it says "hello"

0
This doesn't answer the question. Kampfkarren 215 — 7y
Ad

Answer this question