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: Question about loops

Previous Thread :: Next Thread 
Jellyfish403 is not online. Jellyfish403
Joined: 12 May 2010
Total Posts: 951
14 May 2012 04:27 PM
I've had a lot of questions lately.
Okay so lets say you have a loop like this:
for i = 0,1,0.1
Instead of i could you do i2 or b or whatever?
Report Abuse
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
14 May 2012 04:30 PM
You can make it whatever you want, as long as it's a valid variable.


for LOL_ThisIsWeird = 1,12 do
print(LOL_ThisIsWeird)
end
Report Abuse
Ravenshield is not online. Ravenshield
Joined: 21 Nov 2007
Total Posts: 4143
14 May 2012 04:34 PM
Or you can leave it unspecified

for _ = 1, 2 do
print("Hi!")
end

> Hi!
> Hi!
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
14 May 2012 04:34 PM
Creator of thread:

you don't need to worry about the variables name. It's just the variable. Its what matters what you do with it.

Think of it like math. You're solving a problem.

x = 2

5*x = 10

True. Does it have to be x? No, it doesn't

numbert = 2
5*numbert = 10

evaluates true.

Although, if you wanna be a professional one day name your variables as realistic as you can.
Report Abuse
Jellyfish403 is not online. Jellyfish403
Joined: 12 May 2010
Total Posts: 951
14 May 2012 04:35 PM
Now heres a crazy question, can you call a function from another script?
Report Abuse
Ravenshield is not online. Ravenshield
Joined: 21 Nov 2007
Total Posts: 4143
14 May 2012 04:37 PM
You can use BindableFunction (Object) and take a use of :Invoke() and :OnInvoke()
Or you could store the function as a global, and make the other script call the global function



_G.Function1 = function(val)
print(val)
end

_G.Function1("hi there!")
> "hi there!"
Report Abuse
Jellyfish403 is not online. Jellyfish403
Joined: 12 May 2010
Total Posts: 951
14 May 2012 04:38 PM
So you assign a global variable to a function?
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
14 May 2012 04:41 PM
This is a For statement, in "function form":



function For(Start, Stop, Step, Exec)
    if Start < Stop and Step <= 0 then return end
    if Start > Stop and Step >= 0 then return end
    Exec(Start)
    For(Start+Step, Stop, Step, Exec)
end


For( 1, 10, 2, print )

> 1
3
5
7
9
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
14 May 2012 04:43 PM
Anyway, back to being on topic ....

When using a for loop, you can use whatever variable you'd like. People love using single-character variables for that kind of stuff, simply because it's faster to type.
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
14 May 2012 04:44 PM
@miz - I'm going to take you literally, and point out that in mathematics, variables are always one letter, and one letter only. :D
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
14 May 2012 04:47 PM
@ElectricBlaze

Technically, using substitution, you still get 10.
This is because we assigned the product of n, u, m, b, e, r, and t as 2. ;P
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
14 May 2012 04:49 PM
If you separate each letter into a different variable, then yes. But what's the fun in that?
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
14 May 2012 04:51 PM
Go on, find the values of n, u, m, b, e, r, and t. There's the fun. :)


n = 6
u = 4
m = 0.5
b = 0.5
e = 1
r = 1/6
t = 2
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
14 May 2012 04:52 PM
Nah, that's boring. Try three dimensional quadratic equations. Now THAT is fun. :)
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
14 May 2012 04:52 PM
Ew.
Just stick with vectors.
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
14 May 2012 04:56 PM
Quadratic Equations make me happy. c:
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
14 May 2012 05:00 PM
While you guys do all the easy stuff I'm gonna try to figure out how to use x slopes and y slopes :P

So hard
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
14 May 2012 05:04 PM
WHAT PLANET ARE YOU FROM? WERE YOU DROPPED ON YOUR HEAD AS A CHILD? MY GOSH, SIR.

x and y slopes =/= harder than quadratic equations

LOL.
Report Abuse
jjjj1111222 is not online. jjjj1111222
Joined: 17 Aug 2009
Total Posts: 1282
14 May 2012 05:05 PM
@miz

"So hard???"

y = 1/2x + 3

Man, I wish I sitll had problems like that.

I have conics:

(x+4)^2 + (y+16)^2 = 81

And that's pretty easy.
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
14 May 2012 05:07 PM
^Agreed.
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
14 May 2012 05:12 PM
>.>

Do you not know what sarcasm means?
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
14 May 2012 05:14 PM
It's hard to tell when something is meant sarcastically or not without hearing someone's voice, and as you gave no sign of sarcasm in your word choice, it had not crossed my own mind, and probably those of everyone else viewing this thread.
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
14 May 2012 05:17 PM
Electricblaze. . .

As of a fact you still think it was real when it was just a prank I'm pretty sure you don't know what sarcasm means.

Ah, that was a funny day :P

Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
14 May 2012 05:18 PM
Nah, I just wanted an excuse not to re-add you on skyp3.
Report Abuse
Jellyfish403 is not online. Jellyfish403
Joined: 12 May 2010
Total Posts: 951
14 May 2012 05:20 PM
We just learned about slopes in math, It's really easy.
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