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: doing something multiple times in a loop

Previous Thread :: Next Thread 
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
23 Aug 2015 11:00 AM
say I have

for i = 1, 100 do
--stuff
end

I forgot how I could make it sometimes do something twice without waiting, to compensate for time lost, cos .3 is the limit, so if I wanted to do something faster than that, steven recommended me to sometimes do it twice without waiting, and I forgot what his code looked like, I can't even find it, since my "MyForums" inbox is flooded... how do I make it sometimes do it twice per time? so I want to do something 50 times per second, just as an example... how can I do it with this? I know, I feel so stupid for not just, not being able to do it by myself, but also for forgetting steven's code :/

"My Life is going Good... but..."
Report Abuse
someonedie is online. someonedie
Joined: 19 Mar 2011
Total Posts: 1710
23 Aug 2015 11:01 AM
Your question caused my butt hole to bleed a gallon worth of blood.
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
23 Aug 2015 11:04 AM
whatever -_-
would this work?

local last = 0
for i = 1, 100 do
--stuff
if i * .3 <= (1 / fireRate) * i then last = last + wait() end
end
end

"My Life is going Good... but..."
Report Abuse
someonedie is online. someonedie
Joined: 19 Mar 2011
Total Posts: 1710
23 Aug 2015 11:04 AM
WHAT IS YOUR QUESTION
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
23 Aug 2015 11:05 AM
READ!
I said I want to do something 50 times per second, but wait() only allows like 33 times!
and so I want to compensate at some stages of the loop for time lost -_- what's so hard to understand? -_-

"My Life is going Good... but..."
Report Abuse
AdvancedDrone is online. AdvancedDrone
Joined: 17 Apr 2010
Total Posts: 2599
23 Aug 2015 11:07 AM
put no wait



suport http://www.roblox.com/Forum/ShowPost.aspx?PostID=170559579
Report Abuse
ironrobot914 is not online. ironrobot914
Joined: 08 Jan 2010
Total Posts: 183
23 Aug 2015 11:07 AM
wait(.02)???
Report Abuse
AdvancedDrone is online. AdvancedDrone
Joined: 17 Apr 2010
Total Posts: 2599
23 Aug 2015 11:08 AM
try wait(0.02)
that should work



suport http://www.roblox.com/Forum/ShowPost.aspx?PostID=170559579
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
23 Aug 2015 11:14 AM
dudes... really... .3 is the limit for wait() :P

"My Life is going Good... but..."
Report Abuse
AdvancedDrone is online. AdvancedDrone
Joined: 17 Apr 2010
Total Posts: 2599
23 Aug 2015 11:15 AM
no



suport http://www.roblox.com/Forum/ShowPost.aspx?PostID=170559579
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
23 Aug 2015 11:16 AM
no what?

"My Life is going Good... but..."
Report Abuse
FutureWebsiteOwner is online. FutureWebsiteOwner
Joined: 29 Jul 2014
Total Posts: 468
23 Aug 2015 11:18 AM
only way to go faster than 1/30th of a second is to use RenderStepped
Report Abuse
teamkilled is not online. teamkilled
Joined: 14 Apr 2013
Total Posts: 1748
23 Aug 2015 11:18 AM
local tick2 = tick()
wait()
print(tick()-tick2)

> 0.0348961353302

I think you might have messed up the decimal place there
Report Abuse
teamkilled is not online. teamkilled
Joined: 14 Apr 2013
Total Posts: 1748
23 Aug 2015 11:20 AM
local last_tick = tick()
game:GetService("RunService").RenderStepped:connect(function()
print(tick()-last_tick)
last_tick = tick()
end)

0.016360759735107
0.018282890319824
0.014783620834351
0.015764951705933
0.016812086105347

there's something small enough
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
23 Aug 2015 11:27 AM
Modulo is the answer.

for i = 1,100 do
if i%2 == 0 then wait() end -- waits every even number
end
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
23 Aug 2015 11:36 AM
team, oh yeah, thnx for correcting me, but I'm using ServerScripts :P

chim, hmmm, have u tested this?

"My Life is going Good... but..."
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
23 Aug 2015 11:39 AM
steven made me a new scripts although, this one for some reason fires from 8 to 20 rps :/

local fireDelay = 1/50
local fireTime = 0

while firing do
fire()
fireTime = fireTime + fireDelay
if fireTime > 1/30 then
wait(fireTime)
fireTime = 0
end
end

"My Life is going Good... but..."
Report Abuse
Ripepperoni is not online. Ripepperoni
Joined: 04 Jul 2010
Total Posts: 5715
23 Aug 2015 11:40 AM
for i = 1, 100 do
if i % 2 == 0 then
wait()
end
--code
end
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
23 Aug 2015 11:50 AM
bad thing is about % though, if I set my rps to some other number, it wont follow, meaning it's not compatible, meaning it's not what I want :/

"My Life is going Good... but..."
Report Abuse
Ripepperoni is not online. Ripepperoni
Joined: 04 Jul 2010
Total Posts: 5715
23 Aug 2015 04:55 PM
for i = 1, 100 do
if (i*some_number_that_will_make_it_work) % 2 == 0 then
wait()
end
end
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
24 Aug 2015 08:57 AM
and em, what do u suggest to make some_number_that_will_make_it_work?
my math skills are down right now, I'm damn tired to think :/

"My Life is going Good... but..."
Report Abuse
Ripepperoni is not online. Ripepperoni
Joined: 04 Jul 2010
Total Posts: 5715
24 Aug 2015 11:10 AM
depends what i is my dyde
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
24 Aug 2015 11:38 AM
Guys, just don't use a wait. If you want to do it almost instantly, don't use a wait. For anything even over 100,000 iterations this is plausible.
Report Abuse
Ripepperoni is not online. Ripepperoni
Joined: 04 Jul 2010
Total Posts: 5715
24 Aug 2015 11:40 AM
@jarod

depends how heavy le loop is
I usually don't have loops unless i want a delay or i am doing something heavy
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
24 Aug 2015 12:40 PM
I need wait()s though :/ a gun doesn't fire unlimited rps :/

"My Life is going Good... but..."
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