Questions tagged as 'lua'

1
answer

Save table value

I'd like to save the value assigned to a table in real time, I'll explain. I have 2 files: Main.lua dofile("tester.lua") io.write("blabla") table.insert(oi, io.read()) print(oi[1]) io.read() tester.lua oi = {} If I exe...
asked by 17.08.2014 / 22:51
1
answer

What is the error in the while loop? moon language

What is the error in the loop? I wrote this code to print the sum of the first 10 prime numbers, I already checked the loops but could not find the error. It was to print the sum of the cousins until 29 but only printed 2. Vlwzao o / n=2 cont=...
asked by 29.11.2016 / 01:41
1
answer

Two 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 this: http = require "socket.http" function downloadFile(url) download = http.request(url) return downloa...
asked by 24.11.2014 / 09:32
2
answers

POO Tables on Moon!

I would like to know why you are 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 function TP:setNewPos(po...
asked by 30.05.2015 / 18:51
2
answers

Read only the last characters of a LUA string

I have a string, I just want to read the last characters after the last ";". Example: "12/5/2015; 00: 00: 05; 90" -> Read only the "90"     
asked by 12.05.2015 / 16:41
1
answer

Access local variable outside of 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'm working on a Lua file similar to this schema: if verificacao then local variavelDoArquivo = 123...
asked by 16.11.2016 / 07:44
1
answer

When a function is executed a new thread object is created?

According to the manual of version 5.3, a value of type thread represents independent threads of execution:    The type thread represents independent threads of execution and it is used to implement coroutines (see §2.6). Moon threads are n...
asked by 07.01.2017 / 14:41
1
answer

How to know the last weekend of a month in LUA

How to get the last weekend of March to change your time for daylight saving time. Code to identify whether it is the month of March and whether it is a Sunday. month_now=os.date("%m") week_day=os.date("%w") if week_day=="7" then print("d...
asked by 17.01.2015 / 12:52
1
answer

How to detect the mouse, in Lua?

I recently solved a problem related to the control of screen coordinates in a terminal (thanks to the response found here in SOpt). Now I need to detect the movements and clicks of a pointing device (mouse). Is it time to think and a graphical...
asked by 19.07.2014 / 04:51
1
answer

Moon 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 it shows this: table: 0035AE18 My code: Conta = {balance = 0} Contas = {} Senhas = {} Ini...
asked by 26.01.2015 / 22:13