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
 

I am on my journey to learn how to script.

Previous Thread :: Next Thread 
Riffdis is not online. Riffdis
Joined: 20 Nov 2010
Total Posts: 1345
10 Jan 2012 09:53 PM

I know basics, I'm currently working on a little script that prints out 1,20 and shows witch numbers are odd or even. I'm not sure if I use an array for this, and I need some help.

help plox?
Report Abuse
Riffdis is not online. Riffdis
Joined: 20 Nov 2010
Total Posts: 1345
10 Jan 2012 10:01 PM
anyone?
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
10 Jan 2012 10:02 PM
I remember this question from when I was trying to learn to script lol. . .

Forgot how the wiki showed you how yo do it but here's how I would solve the problem.

for i = 2,20,2 do
print(i-1.." odd")
print(i.." even")
end

Let me look at the wiki version so I can explain it easier
Report Abuse
grimm343 is not online. grimm343
Joined: 18 Sep 2008
Total Posts: 2796
10 Jan 2012 10:08 PM
function check(n)
if n/2 == math.floor(n/2) then
return "even"
else
return "odd"
end
end

So, that's just checking it. You wanted to print out numbers 1-20?

for i=1,20,1 do
print(i..", "..check(i))
wait()
end
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
10 Jan 2012 10:17 PM
for i = 2,20,2 do
print(i-1.." odd")
print(i.." even")
end

Ehhh nvm I think this one is easier and better than the wiki's version of showing you how to do it. Anyways what the script does is it uses a for loop to get up to 20 counting every other number:
-------------------------
for i =
2--[[Starts at 2]],
20--[[Ends at 20]],
2--[[Counts by twos (2, 4, 6, 8. . .)]]
do
-------------------------
The current number(i) is always even(counts by twos) so we know the number under it is going to be odd so we can do:
-------------------------
print(i-1.." odd")
-------------------------
Then we print i since is going to be even:
-------------------------
print(i.." even")
-------------------------
and then we use an end to close the for loop:
--------------------------
end
--------------------------
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
10 Jan 2012 10:18 PM
@grimm;

Hes learning how to script >.<
Anyways most of that is just unneccesary
Report Abuse
grimm343 is not online. grimm343
Joined: 18 Sep 2008
Total Posts: 2796
10 Jan 2012 10:20 PM
This could teach him, if he didn't already know, about math.floor, as well as calling functions.

Yeah, I know it's unnecessary to have the majority of that. >.>
Report Abuse
pwnedu46 is not online. pwnedu46
Joined: 23 May 2009
Total Posts: 7534
10 Jan 2012 10:24 PM
Forevenand odd, just use mod (aka remainder of division).


if n%2==0 then print("even") else print("odd") end
Report Abuse
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
10 Jan 2012 10:25 PM
print("hi")

I script. Trololol.

Lol, nah. Have fun coding. I'm too tired to help much right now.
Report Abuse
pwnedu46 is not online. pwnedu46
Joined: 23 May 2009
Total Posts: 7534
10 Jan 2012 10:25 PM
Sorry.
For even and odd*
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