[ home / board list / faq / random / create / bans / search / manage / irc ] [ ]

/prog/ - Programming

Programming board

Catalog

8chan Bitcoin address: 1NpQaXqmCBji6gfX8UgaQEmEstvVY7U32C
The next generation of Infinity is here (discussion) (contribute)
A message from @CodeMonkeyZ, 2ch lead developer: "How Hiroyuki Nishimura will sell 4chan data"
Name
Email
Subject
Comment *
File
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Embed
(replaces files and can be used instead)
Options
Password (For file and post deletion.)

Allowed file types:jpg, jpeg, gif, png, webm, mp4, pdf
Max filesize is 8 MB.
Max image dimensions are 10000 x 10000.
You may upload 1 per post.


File: 1430309721244.png (6.57 KB, 128x128, 1:1, Lua-logo.png)

068133 No.2316

Hey /prog/ at school we have to do some procedural writing activity, I decided to do Lua, you guys think this is a good TUTORIAL for BEGINNERS, and people with 0% experience with coding? inb4 ur spelling is shit

Commands:

= math.pi –Will print first 14 digits of pie.

= math.random(1,100) –Makes a random number gen.

a = 1

b = 2

= a+b

print(_VERSION)

+: addition

-: subtraction

*: multiplication

/: float division –(Standard Division.)

//: floor division

%: modulo –(Remainder.)

^: exponentiation –(To the power of)

-: unary minus

==:equality

~=:inequality

<:less than

>:greater than

<=:less or equal

>=:greater or equal

random = math.random(0,100)

print(random)

–This prints a valid point.

–Where as.

F = math.random(0,100)

print(f)

–Will have an error.

Introduction: Lua, what is it? Well you see Lua is a coding language, what is code? Code is what you use, to communicate with your computer. Lua is a lightweight addon to C. So where is it used? Lua has been used to make such applications and games as:

Adobe Photoshop Lightroom uses Lua for its user interface.

Cheat Engine, a memory editor/debugger, enables Lua scripts to be embedded in its "cheat table" files, and even includes a GUI designer.

Damn Small Linux uses Lua to provide desktop-friendly interfaces for command-line utilities without sacrificing lots of disk space.

Games that use Lua include:

Angry Birds

Crysis

Dark Souls

Garry's Mod

S.T.A.L.K.E.R: Call of Pripyat

S.T.A.L.K.E.R: Clear Sky

S.T.A.L.K.E.R: Shawdow

Saints Row 2

Saints Row 4

Saint Row 3

SimCity 4

Star Wars: Battlefront

Star Wars: Battlefront 2

The Sims 2: Nightlife

World of Warcraft

So, why lua? Well you see Lua is relatively easy to learn, thus my reasoning.

Today your going to be doing math, and making your own calculator for calculating, probability, and calculate the circumference of a circle.

Alright Step one, here we go.

First step make sure your computer is on. I'm expecting to much of you already aren't I?

Second step connect to internet, via bottom right then, click on the desired WIFI host. (HWDCSB-guest)

Third step open up the terminal via, bottom right, then click on accessories, then LXTerminal.

Forth step type in the terminal. “sudo apt-get install lua5.1” then allow it to run.

Fifth step type in “Lua5.1”

Sixth step Your lua interpreter has been opened, and your ready to code. What do we want to code though? Well today were going to make a calculator for doing probability and circumference of a circle.

Seventh step Alright, time to play around with your, interpreter. Type print(“Hello world”) congrats, you've joined the million of coders who have typed this first, as they begin to set out on there journey to create great things, like well this whole operating system was created by a coder.

Eighth step now that you've done that you can play around with some commands.

Example assign a to 1 via a=1 then do b=2 then do = a+b

Ninth step Now for our Probability calculator, we simple take any question involving probability, anyone got one? Question=false if question == false then print(“Alright lets do the chances of rolling a 5 on a 6 sided die”) end (do = math.random(0,6) if answer equals 5 then boom you won.)

Easy right?

Tenth step Now for that, circumference calculator. So say your trying to find the circumference of a circle with a 10cm long radius? Well this is easy actually. Simply do r = 10 then do = r/math.pi

your answer is? 3.18cm.

Eleventh step Alright guys now its your time to get to play around with your interpreter. What can you do? Well you can write some more calculations with those calculators you recently made, or you could try adding, a+b. Or simply just print some words, you can also use io.write“nil”

If you want to write something more complex you could do a couple of things

With if, then, or else.

And that is how to make a calculator for calculating circumference and probability, in Lua.

068133 No.2317

>>2316

I'm just asking for your opinion on if this is to easy or not.

inb4 neckbeard comes in and says they should be coding the next gmod.


6a05bd No.2318

Separate the installation instructions from the programming tutorial.

Show that you can do assignments like a = a + 1 or a = a - b. Stress the difference between assignment and equality.

Your probability code is illegible.

Introduce the ideas of printing and selection before you use them.

C = 2*pi*r. (How did you fuck this up?)

Your formatting could be better.


068133 No.2325

>>2318

I presented this and I also over rided the shitty windows xp it had, then I had to watch as the casuals all thought that doing.

"Hack the government" would actually do something, i.e you know those hacking video spoofs, well they basically thought that was legit, gg no re.




[Return][Go to top][Catalog][Post a Reply]
Delete Post [ ]
[]
[ home / board list / faq / random / create / bans / search / manage / irc ] [ ]