Difference between revisions of "Help:Lua Programming"

From Pathfinder Wiki
Line 3: Line 3:
 
<!--T:1-->
 
<!--T:1-->
 
Logical intensive Code was written in the script language Lua. Those scripts are in the Namespace Modules.
 
Logical intensive Code was written in the script language Lua. Those scripts are in the Namespace Modules.
 +
 +
==Coding Standard's==
 +
In this section the coding standard's we are using here on the wiki, are explained.
 +
===Variables and their naming===
 +
The names of the variables should be written in CamelCase.
 +
In Lua every variable which is defined is global, by default. So it is needed to define them with a ''local'' infront of the name.
 +
The variable scope is limited to section it is defined in. So if you define a variable inside of a function it's only usable inside of it, the same is for loops, if-Statement's and so on.
 +
 +
On the wiki we define constants that can be used inside of the whole Module, outside of every function right at the start of the Module and the need to be prefixed with ''C_''. That way everyone can recognize that it is a constant and it shouldn't be changed. (In future we could think about a module for all constants)
 +
 +
Tables should be prefixed with a small ''t''.
  
 
==Resources== <!--T:2-->
 
==Resources== <!--T:2-->

Revision as of 20:26, 29 August 2021

Other languages:
Deutsch • ‎English • ‎español • ‎français

Logical intensive Code was written in the script language Lua. Those scripts are in the Namespace Modules.

Coding Standard's

In this section the coding standard's we are using here on the wiki, are explained.

Variables and their naming

The names of the variables should be written in CamelCase. In Lua every variable which is defined is global, by default. So it is needed to define them with a local infront of the name. The variable scope is limited to section it is defined in. So if you define a variable inside of a function it's only usable inside of it, the same is for loops, if-Statement's and so on.

On the wiki we define constants that can be used inside of the whole Module, outside of every function right at the start of the Module and the need to be prefixed with C_. That way everyone can recognize that it is a constant and it shouldn't be changed. (In future we could think about a module for all constants)

Tables should be prefixed with a small t.

Resources