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 » Scripters
Home Search
 

Re: best way to learn tables?

Previous Thread :: Next Thread 
kritiki is not online. kritiki
Joined: 12 Jul 2012
Total Posts: 12323
28 Jul 2017 12:48 PM
I'd use YouTube but every single time they take a hour to get to the script
Report Abuse
Darklord7092 is not online. Darklord7092
Joined: 21 Jan 2015
Total Posts: 5
28 Jul 2017 01:01 PM
There is one youtuber who I watched that taught me how to script. I'd recommend him. he get's to the point but makes it simple.His names Peas Factory (without the SPACE). Go to his advanced scripting playlist, it's the first vid. He speaks quite quietly but is experienced with scripts! Hope this helps. Reply if it did!


Report Abuse
kritiki is not online. kritiki
Joined: 12 Jul 2012
Total Posts: 12323
28 Jul 2017 01:02 PM
Thanks
Report Abuse
HansJutter is not online. HansJutter
Joined: 31 Dec 2016
Total Posts: 204
28 Jul 2017 01:03 PM
darklord's advice is okay, but heres a quick rundown:


local WowSwagCoolJoushua = YOLOSWAGLMAOXD

while true do
wait()

game.Workspace.Baseplate.Name = "Table"
wait()
game.Workspace.Baseplate.Name = "Table4"
wait()
game.Workspace.Baseplate.Name = "Table5"
end

YOLOSWAGLMAOXD:()

game.Lighting.TimeOfDay = 0
Report Abuse
kritiki is not online. kritiki
Joined: 12 Jul 2012
Total Posts: 12323
28 Jul 2017 01:08 PM
that is confusing Hans lol
Report Abuse
ahwz is not online. ahwz
Joined: 01 Apr 2010
Total Posts: 3230
28 Jul 2017 01:10 PM
@Kritiki
Either Hans is a troll or can't code.


Report Abuse
Darklord7092 is not online. Darklord7092
Joined: 21 Jan 2015
Total Posts: 5
31 Jul 2017 01:56 PM
np


Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
31 Jul 2017 02:09 PM
My expanaition might not be the best but let me give it a go. All tables do is hold data. Each table is "indexed" with 1 in lua. That means each "element" can be assesed with a number. They are by default handled as "arrays" which is simply a list of numbers for each element. Tables have certain properties with them and lua comes with some special built in functions you can use to manipulate these tables. Tables can hold anything,from numbers,userdata,strings,booleans,etc.

--Define a new table
local tab = {}

--lets add a new element with the string "Hello"
table.insert(tab,"Hello")

--lets print the first element
print(tab[1]) --> Hello --the first index is 1 with a string element "Hello"

--lets add another element, as a number
table.insert(tab,20)

print(tab[1],tab[2]) --> Hello 20 --there are now 2 indexes with elements "Hello" and 20

--lets remove one of the elements.

table.remove(tab,1) --will remove the first element, then shift the rest down.

print(tab[1]) --> 20 --20 is now the first element because we removed the string "Hello"

Thats the very basics of tables. Tables are probably one of the most powerful tools you can use.








Report Abuse
BrendonTheWizard is online. BrendonTheWizard
Joined: 28 Jul 2010
Total Posts: 25709
31 Jul 2017 02:19 PM
if you know what arrays are you already know what a table is

my computer science teacher described them as shelves where each holds information that can be found in a specific location

so:

local myArray = {}

myArray[1] = "hello"
myArray[2] = " "
myArray[3] = "world"
myArray[4] = "!"

so if you use a loop (i'd recommend a for loop) you can iterate through this array

for i,v in pairs(myArray) do
print(myArray[i])
end

this should print "hello world!"

something very useful if you explore object oriented programming is that you can place objects with their own properties into these arrays and utilize the generic for loop

the ability to access any data you put into the table can be used for anything
here's something that i came up with as i was typing this

local 8ball = {}

8ball[1] = "yes"
8ball[2] = "no"
8ball[3] = "ask later"

print(8ball[math.random(1,#8ball)]) -- this should print a random answer

i hope this helps
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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