C++ style oop
Hello,
I made this:
Test = function(isBase, id)
---@private
local o = {
id = id or 5,
base = isBase or true,
}
o.index = o
o.getId = function(self)
return self.id
end
o.isBase = function(self)
return self.base
end
return o
end
Test2 = function(isBase, id, name)
local o = {
name = name,
}
setmetatable(o, Test(isBase, id))
return o
end
local test = Test2(true, "test")
local test1 = { Test2(false, 15, "lol"), Test2(false, 35, "lol") }
for , v in ipairs(test1) do
print(v:getId())
end
to somewhat mimic cpp style constructor at least.
So here is my question, is it correct path or it would result with unwanted behaviour?
https://redd.it/1d2z2m6
@r_lua
Hello,
I made this:
Test = function(isBase, id)
---@private
local o = {
id = id or 5,
base = isBase or true,
}
o.index = o
o.getId = function(self)
return self.id
end
o.isBase = function(self)
return self.base
end
return o
end
Test2 = function(isBase, id, name)
local o = {
name = name,
}
setmetatable(o, Test(isBase, id))
return o
end
local test = Test2(true, "test")
local test1 = { Test2(false, 15, "lol"), Test2(false, 35, "lol") }
for , v in ipairs(test1) do
print(v:getId())
end
to somewhat mimic cpp style constructor at least.
So here is my question, is it correct path or it would result with unwanted behaviour?
https://redd.it/1d2z2m6
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
A template for hybrid development between C and Lua
Symbiotic-Lua is a template for hybrid development between C and Lua, being very useful for hybrid teams, or to facilitate the creation of programs. It generates a native Windows/Linux binary, without the need to install Lua, so it can be used to build desktop apps, or run in environments that cannot install Lua.
https://github.com/OUIsolutions/Symbiotic-Lua
https://redd.it/1d3aao5
@r_lua
Symbiotic-Lua is a template for hybrid development between C and Lua, being very useful for hybrid teams, or to facilitate the creation of programs. It generates a native Windows/Linux binary, without the need to install Lua, so it can be used to build desktop apps, or run in environments that cannot install Lua.
https://github.com/OUIsolutions/Symbiotic-Lua
https://redd.it/1d3aao5
@r_lua
GitHub
GitHub - OUIsolutions/Symbiotic-Lua: a template for hybrid programming between lua and C
a template for hybrid programming between lua and C - OUIsolutions/Symbiotic-Lua
Newbie Needs Unit Test Help
I have this simple test spec:
describe("Input Capture Service", function()
local api
local inputcaptureservice
beforeeach(function()
-- Mock the API object
api = mock({
executeString = function() end
}, true)
-- Create an instance of the inputcaptureservice with the mocked API
inputcaptureservice = inputcaptureservicemodule.inputcaptureservice(api)
end)
describe("getdigits", function()
it("should call api:executeString with the correct command", function()
-- Arrange
local soundfile = "test.wav"
local maxdigits = 5
local terminator = '#'
local expectedcommand = "playandgetdigits 1 5 1 5000 # test.wav silencestream://500"
-- Act
inputcaptureservice.getdigits(soundfile, maxdigits, terminator)
-- Assert
local stub = require("luassert.stub")
assert.stub(api.executeString).was.calledwith(expectedcommand)
end)
end)
Test results:
Input Capture Service getdigits should call api:executeString with the correct command spec/inputcapturespec.lua:32: Function was never called with matching arguments.
Called with (last call if any): (values list) ((table: 0x13ff416e0)
{ executeString = { by_default = { invokes = function: 0x13ff3e530 returns = function: 0x13ff3e4c0 } callback = function: 0x13ff3f650 called = function: 0x13ffca310 called_with = function: 0x13ff3e360 calls = { 1 = { ... more } } clear = function: 0x13ffca130 invokes = function: 0x13ff3e530 on_call_with = function: 0x13ff3e5d0 returned_with = function: 0x13ff3e390 returns = function: 0x13ff3e4c0 returnvals = { 1 = { ... more } } revert = function: 0x13ff3e3c0 target_key = 'executeString' target_table = { executeString = { ... more } } } }, (string) 'playandgetdigits 1 5 1 5000 # test.wav silencestream://500') Expected: (values list) ((string) 'playandgetdigits 1 5 1 5000 # test.wav silencestream://500')
I can't sort out what I'm doing wrong with the stub here.
I've verified that the expected string is indeed being passed down the line correctly.
It's my first four days with Lua, pls halp, lol
https://redd.it/1d3lotl
@r_lua
I have this simple test spec:
describe("Input Capture Service", function()
local api
local inputcaptureservice
beforeeach(function()
-- Mock the API object
api = mock({
executeString = function() end
}, true)
-- Create an instance of the inputcaptureservice with the mocked API
inputcaptureservice = inputcaptureservicemodule.inputcaptureservice(api)
end)
describe("getdigits", function()
it("should call api:executeString with the correct command", function()
-- Arrange
local soundfile = "test.wav"
local maxdigits = 5
local terminator = '#'
local expectedcommand = "playandgetdigits 1 5 1 5000 # test.wav silencestream://500"
-- Act
inputcaptureservice.getdigits(soundfile, maxdigits, terminator)
-- Assert
local stub = require("luassert.stub")
assert.stub(api.executeString).was.calledwith(expectedcommand)
end)
end)
Test results:
Input Capture Service getdigits should call api:executeString with the correct command spec/inputcapturespec.lua:32: Function was never called with matching arguments.
Called with (last call if any): (values list) ((table: 0x13ff416e0)
{ executeString = { by_default = { invokes = function: 0x13ff3e530 returns = function: 0x13ff3e4c0 } callback = function: 0x13ff3f650 called = function: 0x13ffca310 called_with = function: 0x13ff3e360 calls = { 1 = { ... more } } clear = function: 0x13ffca130 invokes = function: 0x13ff3e530 on_call_with = function: 0x13ff3e5d0 returned_with = function: 0x13ff3e390 returns = function: 0x13ff3e4c0 returnvals = { 1 = { ... more } } revert = function: 0x13ff3e3c0 target_key = 'executeString' target_table = { executeString = { ... more } } } }, (string) 'playandgetdigits 1 5 1 5000 # test.wav silencestream://500') Expected: (values list) ((string) 'playandgetdigits 1 5 1 5000 # test.wav silencestream://500')
I can't sort out what I'm doing wrong with the stub here.
I've verified that the expected string is indeed being passed down the line correctly.
It's my first four days with Lua, pls halp, lol
https://redd.it/1d3lotl
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Is there an up-to date alternative to fengari?
Considering fengari-webs latest commit is 3 years ago, I would consider it more than just stale. Is there any alternatives to run Lua in a html document thats more up to date than fengari?
https://redd.it/1d3zgec
@r_lua
Considering fengari-webs latest commit is 3 years ago, I would consider it more than just stale. Is there any alternatives to run Lua in a html document thats more up to date than fengari?
https://redd.it/1d3zgec
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
LUA Executor?
Before anyone calls me a noscript kiddie, NO, I am not looking for a way to cheat in FiveM or Roblox. I am looking for a simple lua executor or a way to create one (I unfortunately don't know cpp to make injectors on my own).
Why? I am currently having fun decompiling Farming Simulator 2011 and fiddling around with it's source code and I was wondering if I can change game's boolean values or execute functions while the game is running since it was written in lua. Apologies if my post violates the rules. I am just a bored developer. Cheers :)
https://redd.it/1d4cxgu
@r_lua
Before anyone calls me a noscript kiddie, NO, I am not looking for a way to cheat in FiveM or Roblox. I am looking for a simple lua executor or a way to create one (I unfortunately don't know cpp to make injectors on my own).
Why? I am currently having fun decompiling Farming Simulator 2011 and fiddling around with it's source code and I was wondering if I can change game's boolean values or execute functions while the game is running since it was written in lua. Apologies if my post violates the rules. I am just a bored developer. Cheers :)
https://redd.it/1d4cxgu
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
I need help to make this work
Good day, I'm trying to make a Cheat Table work for a game (Persona Q), and I keep getting this error:
Error:[string "---------------------------..."\]:369: attempt to index a nil value (local 'f')
366 --- returns the contents of a file in a given path
367 function readAll(file)
368 local f = io.open(file, "rb")
369 local content = f:read("*all"); f:close()
370 return content
371 end
The section of the code in question... (I know nothing about code, so apologies if it's something obvious)
https://github.com/zarroboogs/pq-ct/blob/master/citra-pq.CT
And this here is the github page
https://redd.it/1d4dxl1
@r_lua
Good day, I'm trying to make a Cheat Table work for a game (Persona Q), and I keep getting this error:
Error:[string "---------------------------..."\]:369: attempt to index a nil value (local 'f')
366 --- returns the contents of a file in a given path
367 function readAll(file)
368 local f = io.open(file, "rb")
369 local content = f:read("*all"); f:close()
370 return content
371 end
The section of the code in question... (I know nothing about code, so apologies if it's something obvious)
https://github.com/zarroboogs/pq-ct/blob/master/citra-pq.CT
And this here is the github page
https://redd.it/1d4dxl1
@r_lua
GitHub
pq-ct/citra-pq.CT at master · zarroboogs/pq-ct
A cheat table for Persona Q @ Citra. Contribute to zarroboogs/pq-ct development by creating an account on GitHub.
What do I think about Lua after shipping a project with 60,000 lines of Lua code?
https://blog.luden.io/what-do-i-think-about-lua-after-shipping-a-project-with-60-000-lines-of-code-bf72a1328733
https://redd.it/1d53qff
@r_lua
https://blog.luden.io/what-do-i-think-about-lua-after-shipping-a-project-with-60-000-lines-of-code-bf72a1328733
https://redd.it/1d53qff
@r_lua
Medium
What do I think about Lua after shipping a project with 60,000 lines of code?
Lead programmer talks Lua’s flexibility, challenges, and integration with Defold game engine after 60k lines of code in Craftomation 101.
Luaforwindows Luarocks error
C:\\Users\\####>luarocks install protobuf
Installing http://luarocks.org/repositories/rocks/protobuf-1.1.2-0.rockspec...
Cloning into 'protobuf-lua'...
fatal: unable to connect to github.com:
github.com[0: 140.82.121.3\]: errno=Unknown error
Error: Failed fetching files from GIT while cloning
https://redd.it/1d55brt
@r_lua
C:\\Users\\####>luarocks install protobuf
Installing http://luarocks.org/repositories/rocks/protobuf-1.1.2-0.rockspec...
Cloning into 'protobuf-lua'...
fatal: unable to connect to github.com:
github.com[0: 140.82.121.3\]: errno=Unknown error
Error: Failed fetching files from GIT while cloning
https://redd.it/1d55brt
@r_lua
LUA Table ripple load
I need to create a LUA table (20 elements) and always write new values to newTable[20\]=newValue. On the next iteration of the write to index 20 the value at newTable[20\] needs to go to newTable[19\], and repeat until the original value falls off the top. I don't know what this is called, and suspect it's been done before. Is there a LUA library function that does this kind of thing? Thanks.
https://redd.it/1d5oyiz
@r_lua
I need to create a LUA table (20 elements) and always write new values to newTable[20\]=newValue. On the next iteration of the write to index 20 the value at newTable[20\] needs to go to newTable[19\], and repeat until the original value falls off the top. I don't know what this is called, and suspect it's been done before. Is there a LUA library function that does this kind of thing? Thanks.
https://redd.it/1d5oyiz
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Lua for reaper reanoscript
Anyone here learn to code specifically for that scenario? How long did it take to learn? I’m not sure if it’s worth it just for that.
https://redd.it/1d6puwx
@r_lua
Anyone here learn to code specifically for that scenario? How long did it take to learn? I’m not sure if it’s worth it just for that.
https://redd.it/1d6puwx
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Online Lua course recommendations
Hi all, Has anybody done any online courses to learn Lua? If so any tips in terms of good ones to look at and ones to avoid?
https://redd.it/1d7h220
@r_lua
Hi all, Has anybody done any online courses to learn Lua? If so any tips in terms of good ones to look at and ones to avoid?
https://redd.it/1d7h220
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Not understanding why my noscript isnt working | Ghub API
I'm trying to make a macro play when 2 keys have been pressed (xButton1 & G1)
My noscript always fails to work unless I remove one of the keys as a requirement to fire the macro. What am I doing wrong?
if event =="MOUSE_BUTTON_PRESSED"
and arg == 5 then
if event =="G_PRESSED"
and arg == 1 then
PlayMacro()
https://redd.it/1d84ap1
@r_lua
I'm trying to make a macro play when 2 keys have been pressed (xButton1 & G1)
My noscript always fails to work unless I remove one of the keys as a requirement to fire the macro. What am I doing wrong?
if event =="MOUSE_BUTTON_PRESSED"
and arg == 5 then
if event =="G_PRESSED"
and arg == 1 then
PlayMacro()
https://redd.it/1d84ap1
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
For beginners: 3 Fun Facts about the Lua Programming Language
https://youtube.com/shorts/iIRquYIstss
https://redd.it/1d8m3tj
@r_lua
https://youtube.com/shorts/iIRquYIstss
https://redd.it/1d8m3tj
@r_lua
YouTube
3 Fun Facts about the Lua Programming Language #shorts #short #lua #programming #funfacts #coding ng
How to learn Lua
I know the basics of Lua but don't know how to proceed. Any tips?
https://redd.it/1d9u0l1
@r_lua
I know the basics of Lua but don't know how to proceed. Any tips?
https://redd.it/1d9u0l1
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Wanted to share my Lua game engine with VS Code breakpoint debugging (Made in C++)
The Editor
The engine could be used as learning material for the beginners on this forum. If you're doing a C++/OpenGL/Lua engine, feel free to have a look. It should be fairly straight-forward to compile and run a template project.
Feature Set, TL;DR
Editor with all kinds of tools.
Works on all desktop platforms (Win, Linux, Mac) and browsers (WebGL 2 / WebAssembly).
PBR Renderer (OpenGL ES 3.0), point lights, sun light, skybox, MSAA, material editor...
Lua Scripting for systems or components, with breakpoint debugging in VS Code.
Object/Component System (like Unity), support C++ components or Lua components.
Serialization (save/load) of all the things (scene, materials, prefabs...)
In-Game User Interface
Multi-threaded animation system, root motion, etc
Audio
Multi-threaded job system
3D physics (bullet3): rigidbodies, raycasts, etc
Networking: scene sync, events, client/server architecture, multiplayer debug tools, UDP, etc
If anyone has questions, please reach out :D
GitHub link: https://github.com/mormert/jle
YouTube demo video: https://youtu.be/2GiqLXTfKg4/
https://redd.it/1da7151
@r_lua
The Editor
The engine could be used as learning material for the beginners on this forum. If you're doing a C++/OpenGL/Lua engine, feel free to have a look. It should be fairly straight-forward to compile and run a template project.
Feature Set, TL;DR
Editor with all kinds of tools.
Works on all desktop platforms (Win, Linux, Mac) and browsers (WebGL 2 / WebAssembly).
PBR Renderer (OpenGL ES 3.0), point lights, sun light, skybox, MSAA, material editor...
Lua Scripting for systems or components, with breakpoint debugging in VS Code.
Object/Component System (like Unity), support C++ components or Lua components.
Serialization (save/load) of all the things (scene, materials, prefabs...)
In-Game User Interface
Multi-threaded animation system, root motion, etc
Audio
Multi-threaded job system
3D physics (bullet3): rigidbodies, raycasts, etc
Networking: scene sync, events, client/server architecture, multiplayer debug tools, UDP, etc
If anyone has questions, please reach out :D
GitHub link: https://github.com/mormert/jle
YouTube demo video: https://youtu.be/2GiqLXTfKg4/
https://redd.it/1da7151
@r_lua
good lua ide
I am needing a lua ide for making apps but from what I am looking for I need the noscript bar to be gone in some of my apps as I need to make a more custom one I would use C# and windows forms but its not as suggested for what I am doing if there is an ide anyone knows of please let me know
https://redd.it/1daj5vb
@r_lua
I am needing a lua ide for making apps but from what I am looking for I need the noscript bar to be gone in some of my apps as I need to make a more custom one I would use C# and windows forms but its not as suggested for what I am doing if there is an ide anyone knows of please let me know
https://redd.it/1daj5vb
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community