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
 

Can this loop be turned into an equation?

Previous Thread :: Next Thread 
Clirex is not online. Clirex
Joined: 22 Jun 2012
Total Posts: 2477
11 Feb 2016 03:52 PM
local DistanceLeft = 0

while Distance > SegmentLength do

DistanceLeft = DistanceLeft + SegmentLength

Distance = Distance - SegmentLength

end
Report Abuse
SimulationCreation is not online. SimulationCreation
Joined: 12 Jun 2012
Total Posts: 2425
11 Feb 2016 03:52 PM
add numbers and yes it can
Report Abuse
Clirex is not online. Clirex
Joined: 22 Jun 2012
Total Posts: 2477
11 Feb 2016 03:55 PM
can you help
Report Abuse
Clirex is not online. Clirex
Joined: 22 Jun 2012
Total Posts: 2477
11 Feb 2016 03:55 PM
distance is the only thing i need
Report Abuse
SimulationCreation is not online. SimulationCreation
Joined: 12 Jun 2012
Total Posts: 2425
11 Feb 2016 03:57 PM
add variables. each var has a certain #.
Report Abuse
Clirex is not online. Clirex
Joined: 22 Jun 2012
Total Posts: 2477
11 Feb 2016 03:58 PM
what i mean is can you solve it for me because i dont know how

Distance = Distance > SegmentLength and
Report Abuse
SimulationCreation is not online. SimulationCreation
Joined: 12 Jun 2012
Total Posts: 2425
11 Feb 2016 04:01 PM
that would be an infinite loop, imposible.
Report Abuse
Clirex is not online. Clirex
Joined: 22 Jun 2012
Total Posts: 2477
11 Feb 2016 04:04 PM
what on earth are you talking about

i want a formula (like a 1 line equation) to replace this loop
Report Abuse
Clirex is not online. Clirex
Joined: 22 Jun 2012
Total Posts: 2477
11 Feb 2016 04:07 PM
i guess a better word would be an algorithm
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
11 Feb 2016 04:09 PM
That is an algorithm.
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
11 Feb 2016 04:10 PM
What are you trying to do with this algorithm?
Report Abuse
Clirex is not online. Clirex
Joined: 22 Jun 2012
Total Posts: 2477
11 Feb 2016 04:10 PM
well

i tried it on my own, not sure if it works or not but here it is:

Distance = Distance > SegmentLength and Distance - (SegmentLength/Distance * SegmentLength) or Distance

Report Abuse
Clirex is not online. Clirex
Joined: 22 Jun 2012
Total Posts: 2477
11 Feb 2016 04:11 PM
@eLunate i want to avoid pointless loops
Report Abuse
Clirex is not online. Clirex
Joined: 22 Jun 2012
Total Posts: 2477
11 Feb 2016 04:12 PM
@TimeTicks make distance >= segment length by subtracting segment length until that is achieved.
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
11 Feb 2016 04:12 PM
It's fine because as that stands, that'll only run once. As soon as you remove SegmentLength from Distance, it's assured to be less than SegmentLength.
Report Abuse
Clirex is not online. Clirex
Joined: 22 Jun 2012
Total Posts: 2477
11 Feb 2016 04:14 PM
@eLunate i feel like there is a better way to go about it
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
11 Feb 2016 04:27 PM
How about we do

local lim = Distance/SegmentLength
DistanceLeft = math.floor(lim)*SegmentLength;
Distance = Distance - math.ceil(lim)*SegmentLength
Report Abuse
Clirex is not online. Clirex
Joined: 22 Jun 2012
Total Posts: 2477
11 Feb 2016 04:29 PM
no that didnt work
Report Abuse
Clirex is not online. Clirex
Joined: 22 Jun 2012
Total Posts: 2477
11 Feb 2016 04:33 PM
thanks for your contribution
fixed:

local lim = Distance/SegmentLength
local DistanceLeft = Distance > SegmentLength and math.floor(lim)*SegmentLength or 0
Distance = Distance > SegmentLength and Distance - math.ceil(lim)*SegmentLength or Distance
Report Abuse
Craftero is online. Craftero
Joined: 24 Jun 2011
Total Posts: 1451
11 Feb 2016 04:52 PM
I don't know if this will help, but I thought I'd throw the idea out there in case it does help you out after all.

There is such a thing as the algebraic distance formula (or b-formula as it is sometimes referred to as). It's easy enough to find on the internet, if you're interested in looking into it more.
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
11 Feb 2016 05:03 PM
repeat thing until thing
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
11 Feb 2016 05:28 PM
You know, my code does exactly what your original code does. And now you're telling me that my code is wrong and that your revised code is obviously right.
Report Abuse
Clirex is not online. Clirex
Joined: 22 Jun 2012
Total Posts: 2477
11 Feb 2016 05:57 PM
you're wrong.
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