AndLua+ English
171 subscribers
6 photos
9 links
➡️Only English💐
AndLua+ Tutorial
AndLua+ Function
AndLua+ Source codes
AndLua+ Videos
AndLua+ App's
keep_support
Download Telegram
Title :- Software Basic Operation
Engineering structures
init. lua project configuration file
main,lua works the main entry file
layout. aly works created by default in the layout file

Basic functions
The Left arrow undo: to undo the contents of the input
Save: save the current file
New: new lua code file or aly layout file, code file and the layout file name can not be the same
Compilation: the current file is compiled to luac file, usually with less than
Open: in the project list Open Project
Package: the current project is compiled to an apk, use by default debug signature
New: create a new project
Backup: the current engineering backup for AndLua+file
Edit: edit the current project's attributes, such as name, permissions, etc.
Formatting: re-indent the current file to make it more easy to read
Import Analysis: Analysis of the current file and the reference file you need to import the java class
Troubleshooting: check whether the current file has a syntax error
The layout of the assistant editor to open aly files for the design layout, the current function is not perfect
Title :- Early Identification AndLua+
AndLua+can on Android with Lua the development of the Android app, not only supports calling Java API, and support for writing Android interface program, you can also write your own Lua programs packaged into the apk installation file to install. The Lua language is simple without any programming experience of the user in a short period of time to develop a Android program, therefore, in the learning AndLua+before we need to first learn Lua language.
Title :- Lua introduction
Lua is a lightweight and compact scripting language, using standard C language and in source code form Open, which is designed for embedded applications, thus allowing applications to provide flexible expansion and customization features.
Lua is Rio de Janeiro, Brazil Catholic University of Pontifical Catholic University of Rio de Janeiro in a study group, by Roberto Ierusalimschy, And Waldemar Celes and Luiz Henrique de Figueiredo of the composition and in 1993 developed.
Then we nonsense not much to say to write first Lua program now!
Title :- First Lua program
Next we use Lua to output"Hello World"

print("Hello World")

After running, it will display on the screen Hello world
Title :- Comment
Single-line comments:
Of the two the minus sign is a single line comment:

- -Comment
Title :- Identifier
Lua represents the identifier used to define a variable, the function gets other user-defined item. Identifier with a letter A to Z or a to z or an underscore _ at the beginning followed by 0 or more letters, underscore, numbers 0 to 9 in.
Best not to use underscores to increase the letters of the identifier, because of Lua's reserved words are also like this.
Lua does not allow the use of special characters such as @, $, and % to define the identifier. Lua is a case sensitive programming language. Therefore, in Lua the W3c and the w3c are two different identifiers. The following lists some of the correct identifier to:

mohd zara abc move_name

myname50 _temp j a23b9
Title :- Keywords
The following lists Lua reserved keywords. Reserved keywords cannot be used as constant or variable or other user-defined identifiers: the

and break do else elseif end false
for function if in local nil not
or repeat return then true until while

The General Convention, the underscore at the beginning of the connection a string of uppercase letters of the name, such as _VERSION, are reserved for Lua internal global variables.
Title :- Global Variables
In the default case, variables are always considered to be global.
Global variables do not need declarations to a variable assignment that created this global variable, to access a not initialized the global variable is also not an error, but the results obtained are: nil.

print(b)
--nil
b=10
print(b)
--10

If you want to remove a global variable, you'll need to assign values to variables to nil.

b = 2
b = nil
print(b)
--nil

Thus the variable b as if never been used just the same. In other words, if and only if a variable is not equal to nil, the variables that exist.
Title :- Lua Data Types
Lua is a dynamically typed language, variables do not define the type,only needed for variable assignment. Values can be stored in variables, passed as parameters or results returned.
Lua has 8 basic types are:

nil, boolean, number, string, userdata, function, thread, and table.

We can use the type function to test a given variable or value of type:

print(type("Hello world"))
--string
print(type(10.4*3))
--number
print(type(print))
--function
print(type(type))
--function
print(type(true))
--boolean
print(type(nil))
--nil
print(type(type(X)))
--string
Title :- Nill (empty)
the nil type represents an absence of any effective value, it is only one value, nil, for example, to print a there is no assignment of variables, will output a nil value:

print(type(a))
--nil

For global variables, and table, nil there is a"Delete"action, to the global variable or the table sheet variable is assigned a nil value, equivalent to bring them out.
Title :- boolean (Boolean)
the boolean type has only two optional values: true and false, in Lua the false and nil as"false", other are"true."
Title :- Number ( digital )
Lua by default there is only one number type-double, as a double type is the default type can be modified luaconf. h in the definitions, the following wording is seen as a number type.
Title :- string (String)
String by a pair of double quotation marks or single quotation marks to represent.

string1 = "this is string1"
string2 = 'this is string2'

In a string of numbers on the row arithmetic operation, the Lua will try to this number will be the string converted to a number, the string connection used to be ..such as:

print("a" .. 'b')
--ab
print(157 .. 428)
--157428

Used # to calculate the length of the string, put the string in front, as in the following example:

len = "www.AndLua+. com"
print(#len)
--12
Title :- Table
In Lua, the table was created by the"constructor expression"to complete, the most simple structure of the expression is {}, used to create an empty table. Can also be in the table add some data directly to initialize the table:

-- Create an empty table
local tbl1 = {}

- Direct the initial table
local tbl2 = {"apple", "pear", "orange", "grape"}

Lua table in table it is an"associative arrays"and associative arrays, the array index can be numeric or string. Unlike other languages, the array put 0 as the array initial index, on Lua in the table of default initial index is generally 1 to start. table is not fixed length size, the new data is added When the table length will grow automatically, not the initial table is nil.
Title :- Function
In Lua, a function is regarded as"first class values First-Class Value", function there may be variables:

function factorial1(n)
if n == 0 then
return 1
else
return n * factorial1(n - 1)
end
end
print(factorial1(5))
factorial2 = factorial1
print(factorial2(5))

function can be an anonymous function, the anonymous function the way through the parameters passed:

function anonymous(tab, fun)
for k, v in pairs(tab) do
print(fun(k, v))
end
end
tab = { key1 = "val1", key2 = "val2" }
anonymous(tab, function(key, val)
return key .. " = " .. val
end)
Title :- The Thread
In Lua, the main thread is a cooperative program coroutines on. It is with the thread(thread)almost, has its own stack, local variables and the instruction pointer, you can talk to other collaborative program shared global variables, and most of the other stuff.
Threads with co-routines the difference: the threads can be simultaneously more to run, and the coroutine at any time can run only one, and is in the running state of the coroutine only suspends the suspend time will be suspended.
Title :- The Userdata From The Defined Type
userdata is a user-defined data, is used to represent a by an application or C/C++ Language Library, The created type can be any C/C++ for any data type of the data, typically a struct and a pointer store to a Lua variable in the call.
Title :- Lua Variables
Variables before use, must be in the code statement that creates the variable.
To compile the program before executing the code the compiler needs to know how to statement variables to open up the storage area for storing the variable value.
Lua variables are of three types: global variables, local variables, table in the domain.
Lua variables in total is a global variable, even if it is a statement block or function, unless the use of a local display is declared as a local variable.
Local variables are scoped to a statement from the start position to where the statement Block ends.
Variable's default value is nil.

a = 5 -- global variable
local b = 5 -- local variable

function joke()
c = 5 -- global variable
local d = 6 -- a local variable
end
Title :- The Assignment Statement
The assignment is to change the value of a variable and changing table field of the most basic methods.

a = "hello" .. "world"
t. n = t. n + 1

Lua can be on multiple variables at the same time assignment, the list of variables and list of values of each element separated by a comma, the assignment statement to the right of the values will be successively assigned to the left variable.

a, b = 10, 2*x <--> a=10; b=2*x

Encounter an assignment statement Lua will first calculate the right all the values and then perform the assignment operation, so we can swap variable values:

x, y = y, x -- swap 'x' for 'y'
a[i], a[j] = a[j], a[i] -- swap 'a[i]' for 'a[j]'

When the number of variables and the number of values is inconsistent, Lua would have been to the number of variables as the basis to take the following strategy:
a. The number of variables > number of values according to the number of variables to make up the nil
b. The number of variables < the number of values of the excess values will be ignored
For example:

a, b, c = 0, 1
print(a,b,c) --> 0 1 nil

a, b = a+1, b+1, b+2 -- value of b+2 is ignored
print(a,b) --> 1 2

a, b, c = 0
print(a,b,c) --> 0 nil nil

The above last example is a common error situation, Note: If you want to have multiple variable assignment must be followed for each variable assignment.

a, b, c = 0, 0, 0
print(a,b,c) --> 0 0 0

Multi-valued assignment is often used to exchange variable, or the function call is returned to the variable:

a, b = f()
f()

Returns two values, the first one is assigned to a, the second is assigned to b.
It should be possible to use local variables, there are two benefits:
1. To avoid naming conflicts.
2. To access the local variables faster than global variables faster.
Title :- Index
The table index using the square brackets [] in. Lua also provides . Operation.

t[i]
t. i -- when the index is of type string when a simplified wording
gettable_event(t,i) -- using the index to access is essentially a similar such function calls

For example:

site = {}
site["key"] = "www.AndLua+. cn"
print(site["key"])
--www.AndLua+. cn
print(site. key)
--www.AndLua+. cn