|
Yeah with delay, didn't the script delay until the functions was run?
Would it go like:
delay(function() script.Parent.Enabled.Changed:connect(function(prop)
--blah
Or if theres an easier way to delay a script until something is changed, plz post that.
Er another thing, please post ASAP, I need this answered very soon. |
|
MicroUserJoin Date: 2009-03-29 Post Count: 3601 |
[ Content Deleted ] |
|
sncplay42Join Date: 2008-11-27 Post Count: 11891 |
delay(time, function) calls function after time seconds, without pausing the current thread. |
|
JORDOFFJoin Date: 2008-09-10 Post Count: 2479 |
just
delay = script.Parent.BoolValue
while delay == true do
wait(1)
end
--rest of script here |
|
MicroUserJoin Date: 2009-03-29 Post Count: 3601 |
[ Content Deleted ] |
|
JORDOFFJoin Date: 2008-09-10 Post Count: 2479 |
hey it whoud stop the script till script.Parent.BoolValue = false right |
|
MicroUserJoin Date: 2009-03-29 Post Count: 3601 |
[ Content Deleted ] |
|
JORDOFFJoin Date: 2008-09-10 Post Count: 2479 |
never mind that whould never stop it needs to be
delay = script.Parent.BoolValue
while delay == true do
delay = script.Parent.BoolValue --if you don't have this delay won't update
wait(1)
end
--rest of script here |
|
JORDOFFJoin Date: 2008-09-10 Post Count: 2479 |
@MicroUser right i see what your saying... |
|
MicroUserJoin Date: 2009-03-29 Post Count: 3601 |
[ Content Deleted ] |
|
JORDOFFJoin Date: 2008-09-10 Post Count: 2479 |
@MicroUser ok... |
|
|
Argh, I forgot about coroutines....
So say I had this:
Text = {Blah, blah, blah}
Cor = coroutine.create(function()
while true do --Just a Rough little thing
wait(8)
for i,v in ipairs(Text) do
coroutine.yield(v)
end
end
while true do
if condition then
wait()
else
Somehint.Text = coroutine.resume(Cor) --Something like that?
end
end
Something like that? |
|
MicroUserJoin Date: 2009-03-29 Post Count: 3601 |
[ Content Deleted ] |
|
|
Oh now I see that lol
Ill try it |
|
|
This is the actual script,Do you think it will cause any running errors?
game.Players.PlayerAdded:connect(function(playa)
local Text = {"Welcome to The Hardest/Longest Obby in Roblox "..playa.Name.." !", "Theres are currently "..#game.Teams:GetChildren().." Courses in this game", "Pay attention the the small, Red balls with the excalmation point decals in the game", "They might be helpful to you"}
local h = Instance.new("Hint")
h.Parent = playa
h.Name = "Hint"
h.Text = ""
local Cor = coroutine.create(function()
local pos = 0
while true do
if pos == #Text then
pos = 0
end
pos = pos + 1
wait(8)
playa.Hint.Text = Text[pos]
coroutine.yield()
end
end)
function Resume()
wait()
playa.Hint.Text = coroutine.resume(Cor)
end
function WaitUntil()
while playa.Enabled do
wait()
end
end
while true do
if playa.Enabled then
WaitUntil()
else
Resume()
end
end
end)
|
|
MicroUserJoin Date: 2009-03-29 Post Count: 3601 |
[ Content Deleted ] |
|
|
Not exactly.
Normally when the player enters, the text in the table would be cycled through and displayed in the players Hint every 8 second.
But I encountered that ni some cases, I need that cycle to be paused until a condition is passed.
Thats what Im gunning for |
|
MicroUserJoin Date: 2009-03-29 Post Count: 3601 |
[ Content Deleted ] |
|
|
delay(time, function)
as in
delay(3, function()
print("This message was delayed 3 seconds.")
end) |
|
LPGhatguyForum ModeratorJoin Date: 2008-06-27 Post Count: 4725 |
I create the coroutine and run it in the same function. For example:
coroutine.resume(coroutine.create(function()
--Do my stuff here.
end)) |
|
MicroUserJoin Date: 2009-03-29 Post Count: 3601 |
[ Content Deleted ] |
|
skullorzJoin Date: 2008-03-22 Post Count: 2209 |
I think delay()s might be useful in my broken bit of code.
I'm trying to make it so if the 'flag' is in the character, the code stops.
x=0
function onFlagChanged(property, flag, set)
if property=="Parent" then
repeat
if flag.Parent.className == "Backpack" then return end
wait(1)
x=x+1
print(x)
until x==6
x=0
flag:Remove() --Returns the flag..
end
end
And yes, there is a connection.
If the flag hasn't been taken in any of those six seconds, return it.
What it does :
I dropped the flag, picked it up.
5 seconds later it returns itself.
Can you fix it?
I tried Scripting Helpers, and no one posts.
|
|
zac352Join Date: 2009-02-20 Post Count: 4657 |
[ Content Deleted ] |
|
mattchewyJoin Date: 2008-02-19 Post Count: 7300 |
function FUNCTION(a,b,c)
print(a,b,c)
end
assert(coroutine.resume(coroutine.create(FUNCTION),1,2,3)) |
|
|
Lol no duh Matt, I believe even a novice scripter knows howto use coroutines.
Anyways, it works, and it incorporates somehow metatables, the delay function, and coroutines :D |
|