LUA:Variable Types

From GMod Wiki

Jump to: navigation, search
Lua: Types
Page white text.png Description:A tutorial about certain types in lua. This does not tell you much about variables
link=User:KillerLUA Original Author:KillerLUA
Calendar.png 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:

Number (Integer) - Number
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!



Decimal Number (Float) - Float
All numbers in lua are normally floats, a float can have decimal points. But an integer cannot as it is whole numbers only!



Text (String) - String
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.



Position (Vector) - Vector
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.



Yes/No (Boolean) - Boolean
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



Angle (Angle) - Angle
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 - PhysObj
Physics object defines the physics of an entity, it is stored seperatly as some information is used by the source engine mostly.



Entity (Ent) - Entity
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



Player (Ent) - Player
A player type has all the functions that an entity has, but a few more player specific ones. Such as Player:Kick(), Player:Freeze()



Effect (CEffectData) - CEffectData
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!



Yarin Kaul Icon ArrowSquare32.png Back to KillerLUA Tutorials


Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox