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: Scripting Challenge

Previous Thread :: Next Thread 
oxcool1 is not online. oxcool1
Joined: 05 Nov 2009
Total Posts: 15444
21 Jan 2012 12:01 AM
[ Content Deleted ]
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
21 Jan 2012 12:04 AM
Hm, nice challenge.. let me see what I can find in that nice little ROBLOX API.. hehe.
Report Abuse
oxcool1 is not online. oxcool1
Joined: 05 Nov 2009
Total Posts: 15444
21 Jan 2012 12:05 AM
[ Content Deleted ]
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
21 Jan 2012 12:05 AM
"How could you reWrtie "wait" "

You don't. . .
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
21 Jan 2012 12:06 AM
@smurf279

Actually, it's possible. :)
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
21 Jan 2012 12:07 AM
In fact, I've already found the solution. I'll just see what others post.

Hint: you have to use an uncommon service. :)
Report Abuse
oxcool1 is not online. oxcool1
Joined: 05 Nov 2009
Total Posts: 15444
21 Jan 2012 12:07 AM
[ Content Deleted ]
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
21 Jan 2012 12:08 AM
inb4h4x
Report Abuse
RenderSettings is not online. RenderSettings
Joined: 16 Aug 2010
Total Posts: 2560
21 Jan 2012 12:08 AM
Ok, here goes nothing:
time = 0;
tic=tick();
c = coroutine.create(function() print("Hello!") wait(5) print("Hi!") end)
getfenv(c)["wait"]=function(t) time = t or 0 c.yield() end
c.resume();
while coroutine.status(c)~="dead" do
if(time>0) then
time=time-tick();
if(time<=0)then
c.resume()
end
end
end


That *should* work. I think. Handles resuming the coroutine from the main thread, so it shouldn't hang itself.

Report Abuse
ElectricAxel is not online. ElectricAxel
Joined: 15 May 2009
Total Posts: 16239
21 Jan 2012 12:09 AM
Step service? :P
Report Abuse
oxcool1 is not online. oxcool1
Joined: 05 Nov 2009
Total Posts: 15444
21 Jan 2012 12:10 AM
[ Content Deleted ]
Report Abuse
RenderSettings is not online. RenderSettings
Joined: 16 Aug 2010
Total Posts: 2560
21 Jan 2012 12:11 AM
DOH'.
time = time - (tic-tick());
Report Abuse
oxcool1 is not online. oxcool1
Joined: 05 Nov 2009
Total Posts: 15444
21 Jan 2012 12:11 AM
[ Content Deleted ]
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
21 Jan 2012 12:12 AM
@RenderSettings

Nope, that doesn't work the same way as the wait function.

I'll wait a few more, and then I'll post my asnwer, if nobody answers correctly, hehe.
Report Abuse
ElectricAxel is not online. ElectricAxel
Joined: 15 May 2009
Total Posts: 16239
21 Jan 2012 12:13 AM
Why is this in SH and not in scripters?
Report Abuse
SCARFACIAL is not online. SCARFACIAL
Joined: 28 Jan 2010
Total Posts: 7970
21 Jan 2012 12:13 AM
function sleep(s)
local start = tick();
repeat until tick() >= start + s
return tick() - start
end

That's what I came up with, but that's about the definition of inefficiency >.<

"I WILL GIVE YOU BACON." - Deadmau5
~Scarfacial
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
21 Jan 2012 12:13 AM
Because oxcool thinks there are people here that can answer it correctly, and he's actually right.
Report Abuse
oxcool1 is not online. oxcool1
Joined: 05 Nov 2009
Total Posts: 15444
21 Jan 2012 12:13 AM
[ Content Deleted ]
Report Abuse
RenderSettings is not online. RenderSettings
Joined: 16 Aug 2010
Total Posts: 2560
21 Jan 2012 12:13 AM
Oxcool:I set wait to my custom one via setfenv. I did not use the default one.
Julien:He said to re-write it, I did. There doesn't have to be just one correct answer.
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
21 Jan 2012 12:15 AM
@SCARFACIAL

Nope. Doesn't work the same way as wait.

Hehe, my solution does, though. :)
Report Abuse
RenderSettings is not online. RenderSettings
Joined: 16 Aug 2010
Total Posts: 2560
21 Jan 2012 12:15 AM
Oxcool:You sure you can't do enviorment changes on coroutines? Ok then:
f = function() print("Hi!") wait(5) print("Bye!") end
wait2 = function(t)
--insert wait stuff here--
end
setfenv(f)["wait"]=wait2;
c = coroutine.create(f);
Report Abuse
oxcool1 is not online. oxcool1
Joined: 05 Nov 2009
Total Posts: 15444
21 Jan 2012 12:16 AM
[ Content Deleted ]
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
21 Jan 2012 12:16 AM
kinda wanna figure this out now :U
Give me a minute
Report Abuse
RenderSettings is not online. RenderSettings
Joined: 16 Aug 2010
Total Posts: 2560
21 Jan 2012 12:18 AM
Hm. Ok then:
function wait(t)
local tic = tick();
local f = t or 0;
repeat f=t-tick()-tic tic=tick() until f<=0
end
Report Abuse
RenderSettings is not online. RenderSettings
Joined: 16 Aug 2010
Total Posts: 2560
21 Jan 2012 12:19 AM
*f=tick()-tic
Don't know why I had a random t- there.
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