Jump to content

Question !


Hero192

Recommended Posts

Hey guys, what's the different if i created a GUI defined like that

local myGUI =  guiCreateWindow(0.33, 0.30, 0.35, 0.40, "window", true) 

and GUI like that

  
local GUI = {} 
GUI["window"] = {} 
  
GUI["window"] =  guiCreateWindow(0.33, 0.30, 0.35, 0.40, "window", true) 

Link to comment

It means it's just created within a table.

We know that tables have two things inside of them, an index (sometimes called key) and a value. Think of it like a dictionary. The book itself is the table. Then each word is a key, and its meaning the value. You have the word name (the index, which in our case would be the string, "window") and it's corresponding meaning (the value, which in our case is the GUI window).

Now think of a variable like a small piece of paper that can only fit one word and one meaning. You write the word (which would be the variable name) and its meaning (which would be the GUI window). Unfortunately, you don't have enough space for anything else.

A variable can hold one value (can be a table of multiple values, but we don't need to worry about that) and a table can hold multiple values within itself.

The difference between your two piece of code is pretty much how you would access it later on. If I wanted to add a button to the first bit of code, I would have to do:

guiCreateButton(0, 0, 0, 0, "Button", false, myGUI) 

However, if I wanted to add a button to the second bit of code, I would have to do:

guiCreateButton(0, 0, 0, 0, "Button", false, GUI["window"]) 

myGUI and GUI["window"] are equal to the same thing. They both return a GUI window (if the function was successful and the GUI window was created). The only difference is how you made it and how you access the window.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...