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 » Roblox » Roblox News & Discussion
Home Search
 

Re: Learn Scripting in Ten Minutes Part One

Previous Thread :: Next Thread 
jackobility is not online. jackobility
Joined: 19 Mar 2017
Total Posts: 685
20 Aug 2017 11:53 AM
Hi I'm masterluacoder4475 and in this thread I'll show you part one of how to script in ten minutes.

Part 1: Math
Doing math in Lua is extremely easy. Here's how you do it:

s={}function push(...)if select('#',...)==0 then return end;s[#s+1]=(...)push(select(2,...))end;function pop()local _=s[#s]s[#s]=nil;return _;end;function add()local b=pop()local a=pop()push(a+b)end;function sub()local b=pop()local a=pop()push(a-b)end;function mul()local b=pop()local a=pop()push(a*b)end;function div()local b=pop()local a=pop()push(a/b)end;function pow()local b=pop()local a=pop()push(a^b)end;function mod()local b=pop()local a=pop()push(a%b)end;push(3,5,2)add()mul()print(pop())

As you can see from the above script Lua is very easy to understand in comparison to other languages such as C++ and Java. If you run the script (or just read it!) you should see that it prints out the solution to 3x(5+2), 21. I'm not going to spend any more time going over this as the rest of math in Lua should be self explanatory.
Report Abuse
jackobility is not online. jackobility
Joined: 19 Mar 2017
Total Posts: 685
20 Aug 2017 11:57 AM
Bump1. If you have any suggestions feel free to post reply with them.
Report Abuse
Ultra_07 is not online. Ultra_07
Joined: 22 Nov 2007
Total Posts: 1594
20 Aug 2017 11:59 AM
All the pushes and pops make it seem like assembly
Report Abuse
NinjaboySC is not online. NinjaboySC
Joined: 17 Sep 2010
Total Posts: 5738
20 Aug 2017 12:00 PM
i didnt even know lua supported pushing and popping data


https://www.roblox.com/triggered-item?id=476076352
Report Abuse
jackobility is not online. jackobility
Joined: 19 Mar 2017
Total Posts: 685
20 Aug 2017 12:02 PM
Don't worry, every new language looks like assembly at first. Once you get the hang of it writing Lua is no harder than writing English.
Report Abuse
jackobility is not online. jackobility
Joined: 19 Mar 2017
Total Posts: 685
20 Aug 2017 04:20 PM
Someone needs to make the block of code in the original post their siggy.
Report Abuse
Mattxew is not online. Mattxew
Joined: 27 Nov 2013
Total Posts: 1180
20 Aug 2017 04:22 PM
i dont understand this

im a bad scripter


its everday bro, i aint in disney any mo
Report Abuse
jackobility is not online. jackobility
Joined: 19 Mar 2017
Total Posts: 685
20 Aug 2017 04:26 PM
Here's a reverse polish notation version of what this script is basically doing: 3 5 2 + *
Report Abuse
Horrible_Pun is not online. Horrible_Pun
Joined: 13 May 2017
Total Posts: 5102
26 Aug 2017 09:38 PM
wait but you can just do print(3 * 5 + 2) right
Report Abuse
jackobility is not online. jackobility
Joined: 19 Mar 2017
Total Posts: 685
26 Aug 2017 10:03 PM
@Horrible_Pun

You could, but with a language like Lua that's only one of the many possible ways of doing it.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Roblox » Roblox News & Discussion
   
 
   
  • 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