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: A During function()

Previous Thread :: Next Thread 
snowwolf is not online. snowwolf
Joined: 23 Nov 2006
Total Posts: 357
26 Dec 2011 09:41 PM
When you start a function, example:
-------------------------------------------------
if IntValue.Value == true then
something()
end
-------------------------------------------------
Now since the function is running, in case somethign else happens:
-------------------------------------------------
if IntValue.Value == true then
something()
end

during something()
if OtherIntValue.Value == false then <---- that ending something()
partytime() <---- starting another function
end
end <---- extra end because the "during" is like an "if" or a "function"
-------------------------------------------------
So is there a way of making a function stop if something happens? Top one is a bad way of describing it but I tried
-------------------------------------------------
something()
print("hi")
wait(1)
print("hello)
wait(1)
print("har")
wait(1)
end
-------------------------------------------------
This means that where ever in that function, it stops and does another function, in this case, partytime()

I dont know if this is confusing or not but please try and help
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
26 Dec 2011 09:46 PM
Do you mean like:

function FirstOne()
for i = 1,3 do
wait(1)
print(i)
end
SecondOne()
end

function SecondOne()
print('all done :D')
end

FirstOne()

?

-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]-
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
26 Dec 2011 09:49 PM
function FirstOne()
for i = 1,3 do
wait(1)
print(i)
end
return SecondOne() --nu stack overflow. . .
end

function SecondOne()
print('all done :D')
end

FirstOne()
Report Abuse
snowwolf is not online. snowwolf
Joined: 23 Nov 2006
Total Posts: 357
26 Dec 2011 09:49 PM
No, thats implying both function 1 and 2 complete their function, Im wondering if, when activating function 1, you can cancel it in the function's process (wherevere) and do function 2
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
26 Dec 2011 09:50 PM
@smurf

It won't overflow because it's not a recursive function :P
If I did

function one()
two()
end

function two()
one()
end

one()

Then it would overflow

-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]-
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
26 Dec 2011 09:54 PM
you mean

function makeMe()
for i = 1, 10 do
print(i)
if i == 7 then return a() end
end

function a()
for i = 8, 10 do
print(i)
if i == 10 then return trololol() end
end
print'lllllllllllllllllllllllllllllllllll'
end

function trololol()
print("makeMeASandwitch")
end

or coroutines?
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
26 Dec 2011 09:58 PM
@Swim
I know but it took me like a week to figure out one of the major problems in my maze generator was that I wasn't using tail calls and that was causing stack overflow. I fixed the code so that it wouldn't get stack overflow without using tail calls but now whenever I see functions that call on each other I always use 'return function()'
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