First mini program in Lua
I don't know if I should be posting this on here, but I followed a tutorial to make a basic calculator program using Lua. It's really basic, but my end goal is to make a basic game in Lua using Love2D, and I just wanted to start with something basic. The code is here:
https://redd.it/1mkdpvy
@r_lua
I don't know if I should be posting this on here, but I followed a tutorial to make a basic calculator program using Lua. It's really basic, but my end goal is to make a basic game in Lua using Love2D, and I just wanted to start with something basic. The code is here:
function adding(x, y) return x + y end function subtraction(x, y) return x - y end function calculate(x, y, f) return f(x, y) end print("enter a number") local x = io.read("*n" , "*l") print("enter another number") local y = io.read("*n", "*l") print("Do you need to add or subtract? (Type + or -) ") local op = io.read(1, "*l") if op == "-" then operation = subtraction else operation = adding end print(calculate(x, y, operation))https://redd.it/1mkdpvy
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Help with uniforms
So I am making a war game and I need help with uniforms. One is model and another is folder. Photo is in the link.
https://preview.redd.it/sjsf5dyb9rhf1.png?width=1920&format=png&auto=webp&s=45876bdec80e5c7b5dbf4f669a851fca5316cbb6
https://redd.it/1mkplpg
@r_lua
So I am making a war game and I need help with uniforms. One is model and another is folder. Photo is in the link.
https://preview.redd.it/sjsf5dyb9rhf1.png?width=1920&format=png&auto=webp&s=45876bdec80e5c7b5dbf4f669a851fca5316cbb6
https://redd.it/1mkplpg
@r_lua
Math question
How do you feel about this way of solving 2 variabled math equations?
local num1 = 4
local num2 = 3
local sub = "+"
local function mul(a, b, op)
return loadstring("return " .. a .. op .. b)()
end
local success, result = pcall(mul, num1, num2, sub)
if success then
print(result)
else
warn("error")
end
https://redd.it/1mkqc7j
@r_lua
How do you feel about this way of solving 2 variabled math equations?
local num1 = 4
local num2 = 3
local sub = "+"
local function mul(a, b, op)
return loadstring("return " .. a .. op .. b)()
end
local success, result = pcall(mul, num1, num2, sub)
if success then
print(result)
else
warn("error")
end
https://redd.it/1mkqc7j
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Are there any free luraph obfuscators out there? The site I was using patched free luraph obfuscation smh
It was panda development
https://redd.it/1mkz2w6
@r_lua
It was panda development
https://redd.it/1mkz2w6
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Should PascalCase be used in the name of a "class" in a preloaded module
So I want to embed lua in my program. I saw it's common to use a preloaded module for all the functionality provided(for example neovim). if I have a class per LuaRocks guidelines(because these were only ones that I could find), a table that does OOP stuff should have it's name in PascalCase. Then calling the constructor of a class in this namespace would look like this:
local bar = foo.Bar.new()
I haven't really used lua all that often so I can't really tell. But is this casing considered idiomatic? Doesn't it look kind of weird/out of place? I haven't been able to find an example of this. The other option would be to have a table that contains the constructor and it's name would be snake_case due to not being a "class". Which would result in:
local bar = foo.bar.new()
Where the
My apologies if I used the term "class" incorrectly I'm not haven't done much in lua, so this is my way of calling the table that emulates a class.
Am I obsessing over the casing of one letter? Yes. But an answer would be greatly appreciated.
https://redd.it/1ml726d
@r_lua
So I want to embed lua in my program. I saw it's common to use a preloaded module for all the functionality provided(for example neovim). if I have a class per LuaRocks guidelines(because these were only ones that I could find), a table that does OOP stuff should have it's name in PascalCase. Then calling the constructor of a class in this namespace would look like this:
local bar = foo.Bar.new()
I haven't really used lua all that often so I can't really tell. But is this casing considered idiomatic? Doesn't it look kind of weird/out of place? I haven't been able to find an example of this. The other option would be to have a table that contains the constructor and it's name would be snake_case due to not being a "class". Which would result in:
local bar = foo.bar.new()
Where the
bar is a table not a class.My apologies if I used the term "class" incorrectly I'm not haven't done much in lua, so this is my way of calling the table that emulates a class.
Am I obsessing over the casing of one letter? Yes. But an answer would be greatly appreciated.
https://redd.it/1ml726d
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
a bit of a math problem (iam kinda new to lua)
My code makes a large table with many different numbers and i want my code to take the numbers from that table (i know how tables work) and find the closest number in the table to a preset number.
For context i have made a few programs already, but none of them needed this.
https://redd.it/1mluuvs
@r_lua
My code makes a large table with many different numbers and i want my code to take the numbers from that table (i know how tables work) and find the closest number in the table to a preset number.
For context i have made a few programs already, but none of them needed this.
https://redd.it/1mluuvs
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Lua Fake Vector - preprocessor that duplicates expressions to do vector math without garbage
https://github.com/mceicys/lua-fake-vector
https://redd.it/1mlutlv
@r_lua
https://github.com/mceicys/lua-fake-vector
https://redd.it/1mlutlv
@r_lua
GitHub
GitHub - mceicys/lua-fake-vector
Contribute to mceicys/lua-fake-vector development by creating an account on GitHub.