Mukul Latiyan has Published 474 Articles

string.format() function in Lua programming

Mukul Latiyan

Mukul Latiyan

Updated on 19-Jul-2021 12:16:06

11K+ Views

There are cases when we want to format strings which will help us to print the output in a particular format.When we use the string.format() function it returns a formatted version of its variable number of arguments following the description given by its first argument, the so-called format string.The format ... Read More

string.find() function in Lua

Mukul Latiyan

Mukul Latiyan

Updated on 19-Jul-2021 12:14:54

18K+ Views

string.find() is one of the most powerful library functions that is present inside the string library.Lua doesn’t use the POSIX regular expression for pattern matching, as the implementation of the same takes 4, 000 lines of code, which is actually bigger than all the Lua standard libraries together. In place ... Read More

string.char() function in Lua programming

Mukul Latiyan

Mukul Latiyan

Updated on 19-Jul-2021 12:12:08

5K+ Views

There are so many scenarios where you might want to convert a decimal value into a character representation. The character representation of a decimal or integer value is nothing but the character value, which one can interpret using the ASCII table.In Lua, to convert a decimal value to its internal ... Read More

string.byte() function in Lua programming

Mukul Latiyan

Mukul Latiyan

Updated on 19-Jul-2021 12:10:24

9K+ Views

The string.byte() function is one of the most widely used Lua string library functions that takes a character or a string as an argument and then converts that character into its internal numeric representations.The character to internal numeric representations can be easily interpreted from the ASCII table.Syntaxstring.byte(ch) or string.byte(ch, idx)In ... Read More

Sort function in Lua programming

Mukul Latiyan

Mukul Latiyan

Updated on 19-Jul-2021 12:09:16

8K+ Views

One of the most used functions in Lua is the sort function which is provided by the Lua library which tables a table as an argument and sorts the values that are present inside the table.The sort function also takes one more argument with the table and that argument is ... Read More

Semicolon Conventions in Lua Programming

Mukul Latiyan

Mukul Latiyan

Updated on 19-Jul-2021 12:07:32

409 Views

There are very few sections we will explore the possibility of making use of a semicolon in Lua. Majority of the code doesn’t require it, while there are some cases where we might need them.ExampleLet’s consider a case where the use of semicolon seems necessary. Consider the example shown below ... Read More

select() function in Lua programming

Mukul Latiyan

Mukul Latiyan

Updated on 19-Jul-2021 12:06:04

7K+ Views

The select function in Lua is used to return the number of arguments that are passed into it as an argument. It can be used in two forms, the first one includes passing an index and then it will return the numbers that are passed after that number into the ... Read More

Read-only tables in Lua programming

Mukul Latiyan

Mukul Latiyan

Updated on 19-Jul-2021 12:04:49

532 Views

While working with tables, we can easily access and modify the values present in the tables provided we know the key. But there are cases where we would like our tables to be in read-only format so that the values present inside the table cannot be modified.There are many benefits ... Read More

Passing Lua script from C++ to Lua

Mukul Latiyan

Mukul Latiyan

Updated on 19-Jul-2021 12:01:48

468 Views

The idea of passing Lua script from C++ to Lua includes the fact that we will have to load the libraries and header files as Lua is ANSI C, and if we are coding in C++, we will need to enclose the #includes in extern “C”.The old and mostly used ... Read More

math.modf() function in Lua programming

Mukul Latiyan

Mukul Latiyan

Updated on 19-Jul-2021 11:58:30

2K+ Views

There are several occurrences when we want to get the integer value of a number and also the fractional value that the number has if any, so that we can use either or both of these values.Lua provides us with a math.modf() function that we can use to find the ... Read More

Advertisements