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 » Club Houses » Let's Make a Deal
Home Search
 

Re: Lua Tutorial - Part 1

Previous Thread :: Next Thread 
DrVulcan is not online. DrVulcan
Joined: 15 Jul 2013
Total Posts: 320
05 Aug 2013 02:54 AM
--> Detailed Tutorial to scripting ROBLOX Lua, this guide has been wrote by Water Aura (drvulcan)
----> Variables

Learning variables is the first step to starting Lua, we first have to find out the two different variables

- Global
    - Global variables are variables that can be called or used throughout the script.

    - Example :
        a = true
- Local
    - Local variables are variables that are scoped or can only be used to a certain enviroment (functions, events, and others)
    - Example :
        local a = true
    - Example 2 (Will print nil instead of true) :
        function Test()
            local a = true
        end
        Test()
        print(a)
    - In Example 2 the script will error due to the fact that the variable "a" is scoped to function "test" so variable "a" would still be considered nil

Variables can be defined to a certain values, but values are classified differently, certain values could be classified as (strings,booleans,userdata,table) :

- String
    - To be classified as a string, the value has to be surrounded by quotations (") or (')
    - Example :
        local a = "string"
    In this example we define "a" as a local variable and its value is equal to the string "true"
- Booleans
    - To be classified as a boolean, the value has to be (true) or (false)
    - Example :
        local a = true
    - Example :
        local a = false
    - These two examples define "a" as either true or false and these booleans are used in arguments
- Userdata
    - To be classified as userdata, the value has to be a object in ROBLOX (As far as you should know)
    - Example :
        -- In this example we have a "Part" in the workspace
        local part = workspace.Part
    In this example we define the variable part as a "Part" in the workspace
- Tables
    - To be classified as a table, the value has to be in brackets
    - Example :
        local table = {"valueA","valueB"}
    - Example :
        local table = {true,false,true}
    - Example :
        local table = {workspace.Part}
    - In all these examples we can include every type of value inside of a table

----> Tables

As we learned in our last lesson tables are created in brackets, now we learn how to call the values
- Setting Variables to a table
    - Example :
        local a = {}
        a.string = "randomstring"
        --
        local b = {}
        b.randomvalue = "asd"
    - In this example we are setting a variable inside of table "a" and naming that variable "string", value is "randomstring"
    - Example 2 :
        local a = {}
        a[1] = true
    - In this example we are setting a variable inside of a table "a", that variable is in the position 1 inside the table to the boolean value true
    - Example 3 :
        local a = {}
        table.insert(a,"randomvalue")
    - In this example we are using a function "table.insert", this function makes it easier to insert a value into the table.
    - Function Arguments : table.insert(Table,Value)
- Calling Variables from a table
    - Lets use print to see what the string is
    - Example :
        -- Lets say we set the variable with a name! (Setting Variables to a table, Example 1)
        local a = {}
        a.string = "randomstring"
        print(a.string)
    - In this example it would print "randomstring", so we called a.string!
Report Abuse
DrVulcan is not online. DrVulcan
Joined: 15 Jul 2013
Total Posts: 320
05 Aug 2013 02:54 AM
u liek?
Report Abuse
Qeenofpie is not online. Qeenofpie
Joined: 12 Oct 2010
Total Posts: 9995
05 Aug 2013 02:55 AM
confusing
Report Abuse
Kamiyama is not online. Kamiyama
Joined: 09 Jan 2013
Total Posts: 8876
05 Aug 2013 02:55 AM
instruction aren't clear enough, got rocket stuck up ass

and are you v.2 of me, or am i mistakened
Report Abuse
Firebolt26 is not online. Firebolt26
Joined: 05 Nov 2009
Total Posts: 23438
05 Aug 2013 02:55 AM
nice tutorial but y lmad
Report Abuse
DrVulcan is not online. DrVulcan
Joined: 15 Jul 2013
Total Posts: 320
05 Aug 2013 02:56 AM
cus fak u
Report Abuse
DrVulcan is not online. DrVulcan
Joined: 15 Jul 2013
Total Posts: 320
05 Aug 2013 02:57 AM
ultra bump
Report Abuse
ProProfit is not online. ProProfit
Joined: 13 Nov 2012
Total Posts: 7678
05 Aug 2013 02:58 AM
"wana od"
Report Abuse
Kamiyama is not online. Kamiyama
Joined: 09 Jan 2013
Total Posts: 8876
05 Aug 2013 02:58 AM
dude
u know ur just gonna get vulcan deleted too
might as well send me a trade with all ur items to help me
theres no running away, the mods hate u
Report Abuse
ProProfit is not online. ProProfit
Joined: 13 Nov 2012
Total Posts: 7678
05 Aug 2013 02:59 AM
do u
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Club Houses » Let's Make a Deal
   
 
   
  • 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