Lua - Reddit – Telegram
Lua - Reddit
30 subscribers
281 photos
31 videos
4.28K links
News and discussion for the Lua programming language.

Subreddit: https://www.reddit.com/r/lua

Powered by : @r_channels & @reddit2telegram
Download Telegram
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
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
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 input
captureservice with the mocked API
input
captureservice = inputcaptureservicemodule.inputcaptureservice(api)
end)

describe("getdigits", function()
it("should call api:executeString with the correct command", function()
-- Arrange
local sound
file = "test.wav"
local maxdigits = 5
local terminator = '#'
local expected
command = "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.called
with(expectedcommand)
end)
end)

Test results:

Input Capture Service get
digits 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
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
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
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
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
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
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
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
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
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