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 » Scripters
Home Search
 

Re: Theoretical - Lagtime-less Scripts?

Previous Thread :: Next Thread 
Davidii is not online. Davidii
Joined: 17 Jul 2008
Total Posts: 1282
08 Nov 2011 06:23 PM
We all know the classic

while true do
end

crash ROBLOX thingy. I think we can all agree that this was a design flaw - forcing us to constantly use a wait() statement, keeping our scripts only running once every two processes.

Is it possible to overcome this? To create a script that runs every frame, instead of every other?

Here's something I think might work.

function runEveryFrame()
print("This should run every frame.")
end

function loop()
while true do
runEveryFrame()
wait() --keeps us down to every other process
end
end

delay(0, loop())
loop()

The second loop call will begin immediately, whereas the first loop call will start while the second is "pausing," therefore running everything in runEveryFrame once per frame. Would this work?
Report Abuse
SecureDatabase is not online. SecureDatabase
Joined: 12 Dec 2010
Total Posts: 392
08 Nov 2011 06:27 PM
I think the only use of this would be in camera manipulation.

But yes, I believe that would work.
Report Abuse
Davidii is not online. Davidii
Joined: 17 Jul 2008
Total Posts: 1282
08 Nov 2011 06:27 PM
Well, if you wanted to make a REALLY fast gun. Or something...
Report Abuse
NecroBumpist is not online. NecroBumpist
Joined: 12 Sep 2010
Total Posts: 4198
08 Nov 2011 06:32 PM
>delay(0, loop())

--> starting loop before calling delay

nope.avi

delay(0, loop)
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
08 Nov 2011 06:34 PM
But... if you run that, wouldn't it make EVERY other thread unable to run?
Report Abuse
Davidii is not online. Davidii
Joined: 17 Jul 2008
Total Posts: 1282
08 Nov 2011 06:35 PM
Whoopsie. Well, correct that error and it would still work.
Report Abuse
JulienDethurens is not online. JulienDethurens
Joined: 11 Jun 2009
Total Posts: 11046
08 Nov 2011 06:36 PM
You say it's a design flaw to prevent users from taking all the CPU, leaving no CPU for other threads?

If I was the one that designed it, it'd be intended...
Report Abuse
Davidii is not online. Davidii
Joined: 17 Jul 2008
Total Posts: 1282
08 Nov 2011 06:37 PM
This creates two identical threads, running every other process, so that the same function is run every process.
Report Abuse
XlegoX is not online. XlegoX
Joined: 16 Jun 2008
Total Posts: 14955
08 Nov 2011 06:51 PM
Bad idea. As soon as the game lags even slightly you'll have have no guarantees anymore. Remember, wait() waits AT LEAST the time you pass it, but possibly much much longer if the game has a lag-spike. With sufficient synchronization you should be able to keep them running out of phase, but it won't be anywhere near that trivial.

That's ASSUMING THAT WAIT WAITS MINIMUM TWO FRAMES of course, which I don't believe is the case!

As far as I know wait() will correctly run the script once every single frame. When you see artifacts trying to do stuff with the camera it's because the game-step happens BETWEEN the script execution step and the render step. That means that even if you have your script do it's thing every frame, it will always be at least one physics step behind the render.
Report Abuse
popinman322 is not online. popinman322
Joined: 04 Mar 2009
Total Posts: 5184
08 Nov 2011 07:05 PM
game:GetService("RunService").Heartbeat:connect(function() print("Frame?") end)
Report Abuse
Radioaktiivinen is not online. Radioaktiivinen
Joined: 25 Apr 2009
Total Posts: 18629
09 Nov 2011 08:34 AM
@XLegoX

I think its because the rendering is 60 fps and the physics and scripts are 30?
Report Abuse
HotThoth is not online. HotThoth
Forum Moderator
Joined: 24 Aug 2010
Total Posts: 1176
09 Nov 2011 12:59 PM
This sounds like an experiment in crashing ROBLOX. RUN AWAYYYY!

This type of system does not seem very helpful, but there are cases where you're doing a lot of computation in-script, and it can be useful to delegate when you want your script to yield (to find the balance between freezing ROBLOX and having your script take longer than necessary). For an example of this, check out some of the terrain plug-ins-- operations over the entire Terrain object require a careful allotment of wait() statements: too few and ROBLOX would appear to crash until the calculations are done (annoying), too many and the calculations would take tons more time than necessary. One way to balance this is to see how many operations you're doing, and just put a wait() statement every 100,000 operations or so, depending on how costly those operations are. [This assumes that the "doOperation" function call takes a lot more time than the line beneath it].

local waitCount = 0
for i = 1, giantLoopOfCalculation do
doOperation()
if waitCount > 100,000 then waitCount = 0 wait() else waitCount = waitCount + 1 end
end
Report Abuse
Radioaktiivinen is not online. Radioaktiivinen
Joined: 25 Apr 2009
Total Posts: 18629
09 Nov 2011 01:12 PM
@hotthot

eww thats ugly

local count=0
for i=1,giantloopofcalc do
doOp()
count=(count+1)%100000
if count==0 then
wait()
end
end
Report Abuse
RATEXmegaGAMER is not online. RATEXmegaGAMER
Joined: 10 Dec 2010
Total Posts: 4046
09 Nov 2011 01:36 PM
    waitCount = waitCount ​> 100000 and 0 or waitCount + 1

Instead of the if statement couldn't you use that?
Report Abuse
Davidii is not online. Davidii
Joined: 17 Jul 2008
Total Posts: 1282
09 Nov 2011 06:05 PM
I got a mod post. Hooah.

Well, EGO, if we can't really fix up the Camera at all... well then... Bwaaargh. Hopefully the mods are working on something to fix up the Camera, make it more usable.
Report Abuse
jeditkacheff is not online. jeditkacheff
Joined: 25 Mar 2010
Total Posts: 231
09 Nov 2011 06:15 PM
we have some ideas as to how to make it easier for you guys to manipulate the camera. Also, I love hearing the problems/suggestions you guys have with the current camera.
Report Abuse
Slizerd is not online. Slizerd
Joined: 15 Jun 2011
Total Posts: 113
09 Nov 2011 06:16 PM
@jedi;

Make cutscenes easier; give us some method for making the camera glide smoothly to a certain CFrame.
Report Abuse
xSIXxStorage is not online. xSIXxStorage
Joined: 22 Aug 2010
Total Posts: 1811
09 Nov 2011 06:19 PM
@jedi

problem: no camerascope.
Report Abuse
Davidii is not online. Davidii
Joined: 17 Jul 2008
Total Posts: 1282
09 Nov 2011 06:20 PM
Kind of like the Tween functions for GUIs. You know - if I knew that suggestions actually got noticed here, I'd put them here instead of the Ideas and Suggestions forum...
Report Abuse
jeditkacheff is not online. jeditkacheff
Joined: 25 Mar 2010
Total Posts: 231
09 Nov 2011 06:59 PM
The other one does, I just read this forum a lot.
Report Abuse
xSIXxStorage is not online. xSIXxStorage
Joined: 22 Aug 2010
Total Posts: 1811
09 Nov 2011 07:00 PM
@David

>assuming that the suggestions their are not drained out by hat requests.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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