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: Calling the same function before it's finished

Previous Thread :: Next Thread 
brickbuilder74 is not online. brickbuilder74
Joined: 23 Jun 2008
Total Posts: 8810
28 Feb 2012 07:02 PM
What would happen. I need to sort of create the situation...
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
28 Feb 2012 07:03 PM
Nothing, assuming you won't be calling it repeatedly, which would create a stack overflow.

-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]-
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
28 Feb 2012 07:22 PM
Like...

function x()
x()
end
x()
?
In that case, you would get an error "Stack Overflow" and you'd continue on in life. However, to fix this problem return x().

What do you think recursion is?

"Bro five! Wear this to let everyone know you think they deserve a high five."
Report Abuse
brickbuilder74 is not online. brickbuilder74
Joined: 23 Jun 2008
Total Posts: 8810
28 Feb 2012 07:46 PM
No, like this:


function x()
-- long function
end

x()

blah.Changed:connect(function()
x()
end)
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
28 Feb 2012 07:47 PM
Why wouldn't it work?

"Bro five! Wear this to let everyone know you think they deserve a high five."
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
28 Feb 2012 07:59 PM
Make sure its not a local function either, but you can still use up-values:

#Yes

local x
do
local a = -1
function x()
a = a+1
print(a)
return a < 10 and x()
end
end

x()

#No

do
local a = -1
local function x()
a = a+1
print(a)
return a < 10 and x()
end
end

x()
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
28 Feb 2012 08:00 PM
Ignore my post >.<
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