Most voted "lua" questions
Lua is a fast and lightweight scripting language designed to extend applications. It is typed dynamically, interpreted from bytecodes, and has automatic memory management with incremental garbage collection. Its features make Lua an ideal language for configuration, automation and rapid prototyping. (visit lua.org).
Learn more…203 questions
Sort by count of
-
12
votes5
answers1943
viewsIs it possible to program to web with Lua?
I see many tutorials on the Internet that assimilate the use of language Lua to the development of games. But I’d like to know the following: It is possible to develop for web using the language…
-
11
votes2
answers324
viewsHow to make an object jump only once. in the LÖVE framework?
I’m trying to make a game using the framework LÖVE for Lua, where the player is a ball and has to overcome obstacles and enemies but I’m having a problem making the jumps. function love.keypressed(…
-
11
votes2
answers1551
viewsWhat is the difference between repeat and while on the moon?
Is there any difference as to the usability of repeat and while on the moon? In my opinion, the two appear to have the same purpose. Not taking syntax into account, there is some difference between…
luaasked 8 years, 11 months ago Wallace Maxters 102,340 -
9
votes2
answers209
viewsIs there a package management system on the Moon?
Many languages have package management system. This greatly facilitates the life of the programmer, making development more agile. For example, in the Python we have the pip and the easy_install, in…
luaasked 8 years, 10 months ago Wallace Maxters 102,340 -
8
votes3
answers644
viewsInsert string data into a table
I have a text file that I read and adjusted in a string texto so that it would stay that way: {nome="Cassio",sexo="M",idade=19} {nome="Paula",sexo="F",idade=20} And I used the following code to add…
-
7
votes3
answers392
viewsString contains a certain word
I’d like to check if a string contains a certain word. String = "oi\ntchau\nhi\nbye" To string is divided by \n (jumps line), I would like to check between each line, if it contains the whole word,…
-
7
votes1
answer125
viewsLoop with array + string
I’m trying to do something like: a = {move1="oi", move2="oi2"} for x=1, #a do print(a.move..x) end I can’t explain it very well, but what I’m trying to do is this: print(a.move..x) getting…
-
7
votes2
answers413
viewsHow do I return a particular character from a text?
How do I return a particular character from a text? For example: text = "Eu sou vegano" How do I detect the 5th letter of text? If anyone would help me, I’d be grateful.…
luaasked 7 years, 11 months ago arthurgps2 411 -
6
votes1
answer234
viewsHow to use a Lua variable in C++?
I can’t get value from a Lua matrix to use in C++. So I take the value of the variable M: //No LUA M = 85 //No C++ L = lua_open(); luaL_loadfile(L, "teste.lua"); lua_pcall(L, 0, 0, 0); int m;…
-
6
votes1
answer850
viewsHow to "call" a function from a Lua table in C++
I’m trying to "call" a function of a table written in Lua. The problem is that I’m not managing to pass three arguments to this function. When I pass the arguments, it’s as if the Lua skip the first…
-
6
votes1
answer206
viewsSort table by contained value
I want to sort such a table by a value contained in it. Ex: tabela = { {pessoa="Joao", idade=20}, {pessoa="Pedro", idade=22}, {pessoa="Lucas", idade=19}, {pessoa="Derp", idade=25} } I want to sort…
-
6
votes1
answer114
viewsAccented letters returning invalid character
Well, I realized that in Lua, you can’t use accented letters. print("á") Returns an invalid character. Is there any way to avoid this?
luaasked 10 years, 1 month ago Gabriel Sales 1,257 -
6
votes1
answer263
viewsInsert into an array between certain values
I have two values in time format, 20:03:02 and 20:03:35, who are in a array in Lua. hora_array={"20:03:02", "20:03:35"} The difference between the two values is 33 seconds (20:03:02 - 20:03:35 =…
-
6
votes2
answers213
viewsDifference between ":" and "." in the methods of a Lua table
I came across two different statements that left me confused. obj = {} function obj.Create(name) end function obj:GoGoGo(name) end What is the difference between the declared function and the .…
-
6
votes2
answers509
viewsHow does the Table declaration instance work in Lua?
In object orientation, the class is usually created first and then the same. PHP example: class Test{ public function __construct() { // inicia as parada aqui } } $test = new Test; But in the Lua it…
-
6
votes3
answers488
viewsWhat is the 'do' statement’s function?
What the 'do' alone waits and makes? do ... end
-
6
votes2
answers141
viewsHow do I make some image invisible in love2d?
How do I set the visibility of an image in Love2d? For example, make it 10%, 25% or 50% visible.
-
5
votes1
answer190
viewsPlay in Löve does not work after compiling
I recently created a game based on löve, that once finished and tested, I decided to try to compile. I followed the tutorial compilation of the löve wiki, using: copy /b love.exe+GhostShield.love…
-
5
votes1
answer365
viewsWhat does "introspection at runtime" mean?
Looking for information about a graphic Toolkit in Lua, I found an explanation about lgi (GTK) that presented a great advantage: "...because it was written in C and has the ability to introspect at…
-
5
votes1
answer498
viewsCheck values in txt
Well, I want to save a value in a txt file, checking if there is already some value with 2 similar things. Ex: local file = io.open("arquivo.txt", "a+") local oi = {dia=os.date(),…
luaasked 10 years, 3 months ago Gabriel Sales 1,257 -
5
votes1
answer445
viewsHow to apply/search for global/local transformations in Opengl
I am programming a simple Game Engine using the graphical API Opengl. But I have a problem that I can’t solve. The problem is that the transformations in world (world) do not work properly. The…
-
5
votes1
answer680
viewsLua print(table) in string (taking all its values)
I created a system quickly to test a new variable, but I do not know how to print the users inserted in the table, and when I give print he shows it: table: 0035AE18 My code: Conta = {balance = 0}…
-
5
votes1
answer122
viewsUnexpected result in Lua test code
I wrote a little code to test a statement from the book I’m studying, Programming in Lua (3rd Edition). The statement, which is found on page 10 of the book, translated is as follows: Conditional…
luaasked 9 years, 8 months ago Raul FuGaDe 53 -
5
votes3
answers1079
viewsHow to format numbers in Lua?
I would like to know how to format the variable: local n = 100000000 So you can come back like this: 100.000.000 Separated by dots, someone knows how to do?…
-
5
votes2
answers232
viewsGet LUA IP address
I want to get the IP address through the LUA code. I have an example code that works but I get the IP from the LAN interface. local hote, _ = socket.dns.toip(socket.dns.gethostname()) How can I get…
-
5
votes1
answer525
viewsLUA, Separate string with numbers in a table!
I have a code rescue system, in case I would put something like this in a text file: HFGD65,{2454,2454},1,1 would be: CODE to redeem -- string {items} -- items within the table in numbers points --…
-
4
votes3
answers1327
viewsPlace information in field fields of a URL and send to the server with a program language
You can, using a programming language, access a web page with login and password data, set the login and password information and "click" the send button, and can enter the site with your…
-
4
votes1
answer211
viewsHow to detect the mouse, in Lua?
I recently managed to solve a problem related to the control of screen coordinates in a terminal (thanks to the answer found here in Sopt). Now I need to detect the movements and clicks of a…
-
4
votes1
answer165
viewsSave table value
I would like to save the value assigned to a table in real time, I will explain. I have 2 files: Main moon. dofile("tester.lua") io.write("blabla") table.insert(oi, io.read()) print(oi[1]) io.read()…
-
4
votes1
answer946
viewsArray size
How do I get the size of an array with this structure: A = { ["b"] = {c=1, d=2}, ["e"] = {f=1, g=2}, } I want to take the size of A, in this case, 2.
-
4
votes1
answer58
viewsTwo simultaneous routines
How do I run two routines simultaneously in the same program? I’m trying to download a file, and print a value while downloading. Exactly that: http = require "socket.http" function…
luaasked 10 years ago Gabriel Sales 1,257 -
4
votes1
answer229
viewsSrlua - Problem after compiling
I’m trying to compile a simple script that contains: require 'classlib' human = class() function human:__init(name) self.name = name end gabriel = human("Gabriel") print(gabriel.name) With srlua,…
luaasked 9 years, 11 months ago Gabriel Sales 1,257 -
4
votes1
answer92
viewsHow to know the last weekend of a month in LUA
How to get the last weekend of the month of March to change your time to daylight saving time. Code to identify if it is the month of March and if it is a Sunday. month_now=os.date("%m")…
-
4
votes1
answer1541
viewsSend array by GET
I’m sending by GET one array in Javascript to another page through a button calling the function. The problem is that sending is in string and not in array. I want to pass this array for the Lua…
-
4
votes2
answers340
viewsRead only last characters of a LUA string
I have a string, I just want to read the last characters after the last one ";". Example: "12/5/2015;00:00:05;90" -> Read only "90"
-
4
votes2
answers729
viewsPOO tables in Lua!
I wonder why it is not returning a table in the code I made: TP = {} function TP:new(pos, newpos, effect) return setmetatable({pos = pos, newpos = newpos, effect = effect}, { __index = self }) end…
-
4
votes1
answer689
viewsCall C++ from Lua
I wonder if there is a way to make a moon extension with a C++ blibioteca, ie the script moon access functions in C++. Ex: add.lua file -- add two numbers function add ( x, y ) CHAMAR AQUI uma…
-
4
votes1
answer291
viewsHow to list variables within a table in Lua?
For example: minion = { hp = 1000, x = 10, y = 25 } Is there a function I can know how many variables there are within this table?
-
4
votes1
answer105
viewsList three-dimensional table
I have a table that I intend to print out all your values. Example: local table_2 = { ["tabela1"] = "360Mhz", "demo", "teste", ["tabela2"] = "360Mhz", "demo", "teste" } for k,v in pairs(table_2) do…
-
4
votes2
answers212
viewsWhat is the # (fence) in the Lua language for?
I’m watching this one tutorial about creating a game and came across something I didn’t understand about the language Lua. There is an excerpt from the code where there is the following expression:…
-
4
votes1
answer261
viewsHow to read JSON with moon?
I wonder how to read this JSON down through language Lua. json = '{"nome" : "Wallace de Souza"}'
luaasked 8 years, 11 months ago Wallace Maxters 102,340 -
4
votes1
answer111
viewsHow to iterate with a table in Lua?
How to iterate with a table in Lua? Example: dados = { nome = 'Wallace', idade = 25 }
-
4
votes1
answer458
viewsHow to find the lowest value of a moon matrix?
I made this code that makes an Array (at least I think it’s doing) and then writes all the values in it. Obs: The values are random. I need to find the lowest matrix value, but the logic I’ve always…
-
4
votes2
answers661
viewsExecute code in Lua language
I downloaded the Lua language interpreter, created a file hello.lua with the code below: print("Hello World") But I can’t compile this code and display the output. I downloaded version 5.3.3 and ran…
-
4
votes1
answer73
viewsWhat error in while loop? moon turn on
What’s the error in the loop? I wrote this code to print the sum of the first 10 prime numbers, I’ve reviewed the loops but I couldn’t find the error. It was to print the sum of the cousins until 29…
-
4
votes1
answer664
viewsAccess local variable outside an if
How to create/modify a variable within a if and be able to access it without having to set it in global mode/scope. I am working on a Lua file similar to this scheme: if verificacao then local…
-
4
votes1
answer118
viewsWhen a function is executed a new thread object is created?
According to the manual of version 5.3, a thread type value represents independent execution topics: The type thread represents Independent threads of Execution and it is used to implement…
-
4
votes3
answers151
viewsSeparate bytes that form an integer number?
Assuming I have this positive number: local uint = 2000; how can I get the bytes that compose it separately? For example: print(sepbytes(uint)); -- 7, 208 My attempt: local function sepbytes(cur)…
-
4
votes2
answers280
viewsWhat’s the difference between creating a string with quotes and square brackets?
I’ve always created the strings with the quotation marks, like this: local minhaString = "Eu sou uma string" I downloaded a source to give a study in the language and I came across the following way…
-
4
votes1
answer225
viewsStrength of typing in Lua language
Lua has dynamic typing, but after all, is it strongly typed or weakly typed? Every source I consult has a different information, which left me in doubt.