Dictionary.com is the world’s leading online source for English definitions, synonyms, word origins and etymologies, audio pronunciations, example sentences, slang phrases, idioms, word games, legal and medical terms, Word of the Day and more. Enjoy 5 free book each and every month with a Standard Account. Or upgrade to VIP status for Unlimited book and audiobook downloads. Either way, it's the best deal on the net!
Dictionaries are tables that use a key to identify values instead of numbered indexes Values store data related to that key. Use dictionaries when you need to label values, not just list them in order as an array does.
Coding a Dictionary
Like arrays, dictionaries are created with curly brackets {}
. Key value pairs are stored on separate lines followed by a comma. Keys and values can be any data type --including strings, numbers, and variable names. This dictionary uses string as keys.
Formatting Keys
If the key is not a string and is a valid name with no spaces, the brackets aren’t needed. Below, a dictionary uses booleans to track if a player has collected orbs needed for a quest.
Dictionaries are often used for organizing information for a character. Keys are used to label properties like name or health points. This examples uses a dictionary to do exactly that.
- Create a new Script.
- Type
local hero = {
and then press Enter to autocomplete the dictionary.
- Name the hero by setting the key’s value and end the line with a comma.
Don't Mix Dictionaries and Arrays
To use individual dictionary values in code, type the name of the dictionary followed by the key in brackets. Example: dictionaryName[key]
- Print the hero’s name and then playtest the code.
Use Unique Keys
Lua won’t stop you from trying to reuse the same key. Keep this in mind as you code. In the example below, the second value given for the key [“name”]
will be printed.
You’ll often need to add key-value pairs to an existing dictionary. For instance, adding players to a dictionary when they join the game, and then starting them off with 0 points.
Adding Key Value Pairs
- Type the name of the dictionary, followed by the name of the key in brackets.
- Example:
playerPoints['name']
- On the same line, set the value.
- Example :
playerPoints['name'] = 0
Removing Key Value Pairs
- Set the value to nil. This deletes the key.
- Example:
playerPoints['name'] = nil
Keys can also use variables. This example uses a variable to add a player’s name as a key when they join the game and then sets their points value to 0.
- In ServerScriptService, create a new script named PlayerPoints.
- Get the Players service and create an empty dictionary.
- Add a local function for setting player points with a parameter for a new player. Connect the function to the
Players.PlayerAdded
event.
- In the function, add a variable to get the player’s name and a print statement for testing.
Dictionaries> > Download Free Pdf Books Online
- Insert
name
into the playerPoints dictionary as a key, and set the value to 0.
- Use
name
to print the name of the player andplayerPoints[name]
to print the value of the key matching the variable.
Optional Challenges »
PreviousMaking Changes to ArraysNextpairs and iPairs
| |
---|---|
We need the prayers and financial support of visitors like you who are committed to increasing their knowledge by the use of the resources offered at the NTSLibrary. Prayerfully consider supporting this project with a financial gift of any size. Your contributions are highly appreciated and used toward the continued growth of this library. | |
NTSLibrary.com | |
Saveup to 98% of costs, when compared to private colleges and universities! To visit the Northwestern Theological Seminary Online Campus: Click Here |
Dictionary
IN THE SPOTLIGHT |
Theology Blogs >The Theology Exchange - a new theology focus blog by Dr. Samuel Galloza (Click) PDF Books >Repentance - by Thomas Watson (View Book) Other similar books (Go To Other books) Online Books >The Arthur Custance Library - The Doorway Papers by Arthur Custance - (Go to the Custance Library) Articles >The Doctrine of Original Sin, by Dean Harvey (View Article) Other articles (Go To Other Articles) Online Resources >Free Bible Commentary - Produced by the ministry of Dr. Bob Utley, these verse-by-verse, exegetical video, audio and printed commentaries are committed to the trustworthiness and authority of Scripture, emphasizing the intent of the original inspired author by means of their: Other resources (Go To Other Resources) Research Tools >Dictionary of Theology - Provided by The Christian Apologetics and Research Ministry (View Theology Dictionary) Other tools (Go To Other Library Tools) Website On The Spotlight >National Religious Leaders Release Historic Declaration on Christian Conscience >Power to Change - If you can change one thing in your life, what would it be? Online Bible - KJV Click banner to open PDF file! The NTSLibrary.com |
---|
| |
---|---|
'To collect, preserve, and make available theological resources for all in search | |
|
| |
---|---|
Theology Proper: | |
The word revelation is derived from the Greek word apokalupsis, which means 'disclosure' or 'unveiling.' Hence, revelation signifies God unveiling Himself to mankind. |