LUA:Variable Types
From GMod Wiki
Lua: Types |
Description: | A tutorial about certain types in lua. This does not tell you much about variables |
Original Author: | KillerLUA |
Created: | October 13, 2010 |
Contents |
Introduction
Every variable in lua has to have a type, does it contain text, is it a yes or no, is it a number?
Most programming languages make you declare a variable and give it a type, but in LUA; You don't have to do this! You simply set the variable to any type you want. You can then change this it any time.
Types
Here is a lightly detailed list of some of the basic types in LUA:
A number in LUA is usally referenced as an Integer, however. All numbers in LUA are floats, floats can include decimal points. But integers cannot!
All numbers in lua are normally floats, a float can have decimal points. But an integer cannot as it is whole numbers only!
A string is basicly a line of characters, characters are single letters such as A, b, z or ;. Think of it as lot's of characters ties on strands connected by a string.
Vectors are used mostly to describe the position of an entity. You can also apply force to entitys using a vector with some maths; Vectors are always three floats in one variable.
Boolean is basicly an annoying word for yes/no or true and false. You can set booleans like this: var = true or var = false
Garrys Mod 10 LUA Specific
Angles are used to describe an "angular position". Angles bascily, is the angle of a object. Simple stuff. Angles are always three floats in one variable.
Physics object defines the physics of an entity, it is stored seperatly as some information is used by the source engine mostly.
An entity is the object for any item/block you see in the game, you can look around the wiki to see more information about the differant types of entitys you could come across
A player type has all the functions that an entity has, but a few more player specific ones. Such as Player:Kick(), Player:Freeze()
Contains all the data required to create an effect with specific options, you can find more information on this around the wiki.
Conclusion
Now you have mastered the types of Garrys Mod, go out there new coder. And make something useful!