LPM - A package manager and standalone executable compiler for Lua, in Lua
As the name suggests, `lpm` is a package manager for lua. It is written entirely in LuaJIT. It is heavily inspired by package managers like `npm`, `bun` and `uv`.
It is currently in an alpha state, but I think it's become quite usable and is integral to my main project ([Arisu](https://github.com/codebycruz/arisu), if you're curious). Expect certain things to be in flux and stupid things to be broken as the project gets more stable and gets a proper test harness.
# Features
* Git dependencies, supporting subdirectories+monorepos
* Local relative path dependencies (good for monorepos)
* Compile your project to a single executable with `lpm compile`
* Run a suite of tests with `lpm test`
* Self upgrade to the latest version with `lpm upgrade`
* Supports Windows and Linux (x86/ARM, Musl/Glibc).
* Build noscripts
* Can do things like preprocess files. Perfect for languages like teal
* This is also how C dependencies are built generically instead of making some arbitrary schema as luarocks did.
* Simple JSON configuration (`lpm.json`, ala `package.json`)
* Not vibecoded :)
# How do I use it?
Create a project with `lpm init`, and run it with `lpm run`. It sets up lua's path and cpath to resolve your dependencies which are stored in `lpm_modules`.
# Who is this for?
If you want a package manager that resembles a modern experience, and primarily make your own projects, or are willing to briefly port a LuaRocks project to LPM (It's not very difficult), give it a try.
As a proof of concept, I ported over [busted](https://github.com/lunarmodules/busted) to lpm [here](https://github.com/codebycruz/busted). You can manually invoke the test runner and use busted that way, but in the future, the lpm test runner will have its own testing library built-in, ala bun's built-in test runner.
Porting over busted took a lot of forking but was mostly just creating the `lpm.json` configuration file, and a simple build noscript to call `make` for C dependencies.
# How does this compare with luarocks or lux?
At the moment I have no intention of supporting previous LuaRocks packages, as lpm makes strives for simplicity. But a separate registry will come in the future.
`lpm` is written in Lua(JIT)
`luarocks` is written in Teal
`lux` is written in Rust
# Download
Repo: [https://github.com/codebycruz/lpm](https://github.com/codebycruz/lpm)
The `lpm` binary is built from running `lpm compile` on itself, you can download it below, no need to have lua or luajit installed on your system :)
Linux: `curl -fsSL` [`https://raw.githubusercontent.com/codebycruz/lpm/master/install.sh`](https://raw.githubusercontent.com/codebycruz/lpm/master/install.sh) `| sh`
Windows: `irm https://raw.githubusercontent.com/codebycruz/lpm/master/install.ps1 | iex`
Or get it as an artifact from the [latest nightly build](https://github.com/codebycruz/lpm/actions/workflows/build.yml)
https://redd.it/1qqsf8d
@r_lua
As the name suggests, `lpm` is a package manager for lua. It is written entirely in LuaJIT. It is heavily inspired by package managers like `npm`, `bun` and `uv`.
It is currently in an alpha state, but I think it's become quite usable and is integral to my main project ([Arisu](https://github.com/codebycruz/arisu), if you're curious). Expect certain things to be in flux and stupid things to be broken as the project gets more stable and gets a proper test harness.
# Features
* Git dependencies, supporting subdirectories+monorepos
* Local relative path dependencies (good for monorepos)
* Compile your project to a single executable with `lpm compile`
* Run a suite of tests with `lpm test`
* Self upgrade to the latest version with `lpm upgrade`
* Supports Windows and Linux (x86/ARM, Musl/Glibc).
* Build noscripts
* Can do things like preprocess files. Perfect for languages like teal
* This is also how C dependencies are built generically instead of making some arbitrary schema as luarocks did.
* Simple JSON configuration (`lpm.json`, ala `package.json`)
* Not vibecoded :)
# How do I use it?
Create a project with `lpm init`, and run it with `lpm run`. It sets up lua's path and cpath to resolve your dependencies which are stored in `lpm_modules`.
# Who is this for?
If you want a package manager that resembles a modern experience, and primarily make your own projects, or are willing to briefly port a LuaRocks project to LPM (It's not very difficult), give it a try.
As a proof of concept, I ported over [busted](https://github.com/lunarmodules/busted) to lpm [here](https://github.com/codebycruz/busted). You can manually invoke the test runner and use busted that way, but in the future, the lpm test runner will have its own testing library built-in, ala bun's built-in test runner.
Porting over busted took a lot of forking but was mostly just creating the `lpm.json` configuration file, and a simple build noscript to call `make` for C dependencies.
# How does this compare with luarocks or lux?
At the moment I have no intention of supporting previous LuaRocks packages, as lpm makes strives for simplicity. But a separate registry will come in the future.
`lpm` is written in Lua(JIT)
`luarocks` is written in Teal
`lux` is written in Rust
# Download
Repo: [https://github.com/codebycruz/lpm](https://github.com/codebycruz/lpm)
The `lpm` binary is built from running `lpm compile` on itself, you can download it below, no need to have lua or luajit installed on your system :)
Linux: `curl -fsSL` [`https://raw.githubusercontent.com/codebycruz/lpm/master/install.sh`](https://raw.githubusercontent.com/codebycruz/lpm/master/install.sh) `| sh`
Windows: `irm https://raw.githubusercontent.com/codebycruz/lpm/master/install.ps1 | iex`
Or get it as an artifact from the [latest nightly build](https://github.com/codebycruz/lpm/actions/workflows/build.yml)
https://redd.it/1qqsf8d
@r_lua
GitHub
GitHub - codebycruz/arisu: A painting program with absolutely zero dependencies.
A painting program with absolutely zero dependencies. - codebycruz/arisu
Lua coders and roblox studio devs for hire (free, passion project, outcome memories)
https://www.reddit.com/gallery/1qqki2z
https://redd.it/1qqkih4
@r_lua
https://www.reddit.com/gallery/1qqki2z
https://redd.it/1qqkih4
@r_lua
Reddit
Lua coders and roblox studio devs for hire (free, passion project, outcome memories) : r/OutcomeMemories
51 votes, 61 comments. 18K subscribers in the OutcomeMemories community. The UNOFFICIAL subreddit for the Roblox Game: Sonic.EXE Outcome Memories…
Any Luau Learning/Practice Websites?? (roblox)
I'm trying to learn how to code in roblox (coding language is luau) and I've been searching for a while on stuff to help me improve, yet I cant find any. Please recommend me some websites, such as this one, https://luau-academy-d1bc1004.base44.app/?is\_new\_user=true, but more advanced since the one I listed is kinda broken...
Don't recommend me:
\- Roblox Youtube tutorials ( i know some are good but I've tried it before and they don't help me as much as I would like them to)
\- Roblox documentation ( its hard for me to stare at a screen and read while not boring my mind out )
\- Roblox dev forums ( they are helpful, but again, I don't want to stare at screen and read for a long amount of time + doing an activity would help me remember it more)
\-ANY online classes where I have to interact with teachers, "sign up with a guardian", and stuff like that (I want it to be like the website I listed)
\- don't tell me to just use the website I listed please!!
Please recommend me:
\- any websites that are interactive
|__(possibly let you write notes along the way)
\- ones that I can write code in it and it gets reviewed
\- ones that have activities as in quizzes and stuff like that (or even daily challenges)
btw everything that I asked to be recommended doesn't NEED to be on the website, its just a few things that I thought would be nice to be included to be recommended, thanks!!
https://redd.it/1qpnebk
@r_lua
I'm trying to learn how to code in roblox (coding language is luau) and I've been searching for a while on stuff to help me improve, yet I cant find any. Please recommend me some websites, such as this one, https://luau-academy-d1bc1004.base44.app/?is\_new\_user=true, but more advanced since the one I listed is kinda broken...
Don't recommend me:
\- Roblox Youtube tutorials ( i know some are good but I've tried it before and they don't help me as much as I would like them to)
\- Roblox documentation ( its hard for me to stare at a screen and read while not boring my mind out )
\- Roblox dev forums ( they are helpful, but again, I don't want to stare at screen and read for a long amount of time + doing an activity would help me remember it more)
\-ANY online classes where I have to interact with teachers, "sign up with a guardian", and stuff like that (I want it to be like the website I listed)
\- don't tell me to just use the website I listed please!!
Please recommend me:
\- any websites that are interactive
|__(possibly let you write notes along the way)
\- ones that I can write code in it and it gets reviewed
\- ones that have activities as in quizzes and stuff like that (or even daily challenges)
btw everything that I asked to be recommended doesn't NEED to be on the website, its just a few things that I thought would be nice to be included to be recommended, thanks!!
https://redd.it/1qpnebk
@r_lua
Luau Academy
Your all-in-one platform to master Luau noscripting for Roblox. From beginner basics to advanced techniques, learn interactively with code examples and track your progress.
Help with replacing specific term in string
I'm modifying a World of Warcraft addon, and I have player-defined strings in the form of WoW macro conditionals, which generally take the form
When the conditions change the action, the game calls an onstate method and passes me a string of the active action. The actions I am expecting are:
"hide": hides the object
"shownumber": shows the object with an alpha of number percent
"showhigh", "showmed", and "showlow": show the object with an alpha based on config settings
"show": shows the object based on its player-assigned default alpha.
The issue is, due to anti-botting measures, I cannot call global variables in the onstate method. In order to reference the config, I take the conditional string and use string.gsub to replace "showhigh", "showmed", and "showlow" with "shownumber". So for example, by default "showhigh" becomes "show75" and is handled by the same code as "shownumber".
Similarly, I would like to replace "show" with "shownumber", where number is the default alpha. But I don't know how to do that with string.gsub because it would also replace "show" in most of the other actions.
My question is, how can I replace the term "show" in a string, but only if it is not followed by numbers? (It is possible that "show" will appear at the very end of the string.)
https://redd.it/1qp3p5c
@r_lua
I'm modifying a World of Warcraft addon, and I have player-defined strings in the form of WoW macro conditionals, which generally take the form
[conditionA,conditionB][conditionC]action;[conditionD]action; actionWhen the conditions change the action, the game calls an onstate method and passes me a string of the active action. The actions I am expecting are:
"hide": hides the object
"shownumber": shows the object with an alpha of number percent
"showhigh", "showmed", and "showlow": show the object with an alpha based on config settings
"show": shows the object based on its player-assigned default alpha.
The issue is, due to anti-botting measures, I cannot call global variables in the onstate method. In order to reference the config, I take the conditional string and use string.gsub to replace "showhigh", "showmed", and "showlow" with "shownumber". So for example, by default "showhigh" becomes "show75" and is handled by the same code as "shownumber".
Similarly, I would like to replace "show" with "shownumber", where number is the default alpha. But I don't know how to do that with string.gsub because it would also replace "show" in most of the other actions.
My question is, how can I replace the term "show" in a string, but only if it is not followed by numbers? (It is possible that "show" will appear at the very end of the string.)
https://redd.it/1qp3p5c
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
mote - Lightweight HTTP server for Lua
I've been working on a standalone HTTP server for Lua/LuaJIT. It started as the core of a Backend as a service (BaaS) project I was building and I decided to extract it into a standalone library. It has Koa-style routing with URL params, onion middleware, and built-in support for CORS, JWT, rate limiting, and Server-Sent Events with pub/sub. Runs on Linux, macOS, and Windows. No nginx or openresty needed, though a reverse proxy is still recommended for TLS in production.
Example:
local mote = require("mote")
mote.get("/users/:id", function(ctx)
ctx.response.body = { id = ctx.params.id }
end)
mote.create({ port = 8080 }):run()
https://github.com/luanvil/mote
I'd love to hear what you think.
https://redd.it/1qnp6g9
@r_lua
I've been working on a standalone HTTP server for Lua/LuaJIT. It started as the core of a Backend as a service (BaaS) project I was building and I decided to extract it into a standalone library. It has Koa-style routing with URL params, onion middleware, and built-in support for CORS, JWT, rate limiting, and Server-Sent Events with pub/sub. Runs on Linux, macOS, and Windows. No nginx or openresty needed, though a reverse proxy is still recommended for TLS in production.
Example:
local mote = require("mote")
mote.get("/users/:id", function(ctx)
ctx.response.body = { id = ctx.params.id }
end)
mote.create({ port = 8080 }):run()
luarocks install motehttps://github.com/luanvil/mote
I'd love to hear what you think.
https://redd.it/1qnp6g9
@r_lua
GitHub
GitHub - luanvil/mote: Lua HTTP server with routing and middleware
Lua HTTP server with routing and middleware. Contribute to luanvil/mote development by creating an account on GitHub.
metaty.freeze: immutable types
https://civboot.github.io/lua/metaty.html#metaty.freeze
https://redd.it/1qn5yr7
@r_lua
https://civboot.github.io/lua/metaty.html#metaty.freeze
https://redd.it/1qn5yr7
@r_lua
LUA dynamic concatenation
Hello guys. I need to build a message in LUA that has fixed value of 240 characters. This message is composed by a variable lenght message that I have allready processed, but the rest has to be filled with the * character. So for example if my initial message is 100 characters, I need to fill the rest until 240 with the * character. If my message will be 200 characters, I need to fill 40 * until reaching 240.
How can this be achieved?
Thanks
https://redd.it/1qr2vgk
@r_lua
Hello guys. I need to build a message in LUA that has fixed value of 240 characters. This message is composed by a variable lenght message that I have allready processed, but the rest has to be filled with the * character. So for example if my initial message is 100 characters, I need to fill the rest until 240 with the * character. If my message will be 200 characters, I need to fill 40 * until reaching 240.
How can this be achieved?
Thanks
https://redd.it/1qr2vgk
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
can anybody help me fix this piece of code
this code is suppose to look if the new ore thats currently generating and any existing ore are overlaping .but when i run it some times idoesnt work i need help
ores = {x = {}, y = {},durability = {} ,rotation = {},alive = {} , image = love.graphics.newImage("rock.png"),image2 = love.graphics.newImage("tree.png") ,class = {}}
local pos = {x = 0 , y = 0, blocked = false}
function ores:generate(repeats,mapsizex,mapsizey,mapX,mapY,class) --tree height is 32 and rock height is 16
for i = 1 , repeats do
pos.blocked = false
pos.x = mapX + love.math.random(0,40) 30
pos.y = mapY + love.math.random(0,20) 30
for k = 1, #ores.x do
if ores.rotationi ~= nil and ores.xk == pos.x and ores.yk == pos.y or ores.rotationi ~= nil and pos.y + 30 == ores.yk and ores.xk == pos.x then
pos.blocked = true
break
end
end
if not pos.blocked and mapX + mapsizex > pos.x and mapY + mapsizey > pos.y then
table.insert(ores.x, pos.x)
table.insert(ores.y, pos.y)
table.insert(ores.durability, 10)
table.insert(ores.rotation, 0)
table.insert(ores.alive, true)
table.insert(ores.class, class)
end
end
end
https://redd.it/1qnfggo
@r_lua
this code is suppose to look if the new ore thats currently generating and any existing ore are overlaping .but when i run it some times idoesnt work i need help
ores = {x = {}, y = {},durability = {} ,rotation = {},alive = {} , image = love.graphics.newImage("rock.png"),image2 = love.graphics.newImage("tree.png") ,class = {}}
local pos = {x = 0 , y = 0, blocked = false}
function ores:generate(repeats,mapsizex,mapsizey,mapX,mapY,class) --tree height is 32 and rock height is 16
for i = 1 , repeats do
pos.blocked = false
pos.x = mapX + love.math.random(0,40) 30
pos.y = mapY + love.math.random(0,20) 30
for k = 1, #ores.x do
if ores.rotationi ~= nil and ores.xk == pos.x and ores.yk == pos.y or ores.rotationi ~= nil and pos.y + 30 == ores.yk and ores.xk == pos.x then
pos.blocked = true
break
end
end
if not pos.blocked and mapX + mapsizex > pos.x and mapY + mapsizey > pos.y then
table.insert(ores.x, pos.x)
table.insert(ores.y, pos.y)
table.insert(ores.durability, 10)
table.insert(ores.rotation, 0)
table.insert(ores.alive, true)
table.insert(ores.class, class)
end
end
end
https://redd.it/1qnfggo
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Sharing my TIC80 lua language server stubs
https://codeberg.org/firns/tic80-lua-language-server-stubs
Hi, I made some LLS stubs for TIC80 because I use an external editor that isn't VS Code. For anyone else interested, my repo will explain how to use them, its super simple if your ide has language server functionality.
Hope this helps a few people!
https://redd.it/1qrf66x
@r_lua
https://codeberg.org/firns/tic80-lua-language-server-stubs
Hi, I made some LLS stubs for TIC80 because I use an external editor that isn't VS Code. For anyone else interested, my repo will explain how to use them, its super simple if your ide has language server functionality.
Hope this helps a few people!
https://redd.it/1qrf66x
@r_lua
Codeberg.org
tic80-lua-language-server-stubs
A folder to be added to the Lua-Language-Server to provide code completion, parameter hints, etc.
morolua, a small, engine-agnostic Lua utility library to avoid rewriting common helpers every project. I’d appreciate feedback on the API design and scope.
https://github.com/moro989/morolua
https://redd.it/1qsxbm3
@r_lua
https://github.com/moro989/morolua
https://redd.it/1qsxbm3
@r_lua
GitHub
GitHub - moro989/morolua: morolua is a pure Lua utility library with no dependencies. Its goal is to eliminate the need to rewrite…
morolua is a pure Lua utility library with no dependencies. Its goal is to eliminate the need to rewrite common functionality in every project. While designed with game-style environments in mind, ...
Grid Fusion: little puzzle like triple town
hello just a little game in love2d
i want to recreate some kind of triple town game
it s simpliest than triple town
give me your opinion / advices about it
thanks
https://pouranat.itch.io/grid-fusion
https://redd.it/1qt49cu
@r_lua
hello just a little game in love2d
i want to recreate some kind of triple town game
it s simpliest than triple town
give me your opinion / advices about it
thanks
https://pouranat.itch.io/grid-fusion
https://redd.it/1qt49cu
@r_lua
itch.io
Grid Fusion by pouranat
a puzzle game (fusion from 2048 and Triple Town). Play in your browser
removing specific iteration of one variable from table
so what i am doing is in the beginning of the program there's a variable "monsters", which is where a created instance of a "monster" variable is created. what i want is how to figure out how to remove the specific instance of a monster from an if then statement(during a collision). this is the code:
im sorry if this is a redundant question, also im using love2d but thats kinda irrelevant
thank you.
edit: i figured it out
https://redd.it/1qw0umi
@r_lua
so what i am doing is in the beginning of the program there's a variable "monsters", which is where a created instance of a "monster" variable is created. what i want is how to figure out how to remove the specific instance of a monster from an if then statement(during a collision). this is the code:
for i, bullet in ipairs(bullets) doif bullet.x + 10 > monster.x and bullet.x - 10 < monster.x + 80 thenif bullet.y - 10 > monster.y and bullet.y + 10 < monster.y + 80 then--what do i dotable.remove(monsters, i)endendendendim sorry if this is a redundant question, also im using love2d but thats kinda irrelevant
thank you.
edit: i figured it out
https://redd.it/1qw0umi
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
I am making a new package manager for lua called LuaMoon
Hi everyone!
I’m working on LuaMoon, a lightweight Lua package manager that aims to improve on existing tools like LuaRocks. LuaMoon is designed to be compatible with Love2D, LuaJIT, and Lua, making it easier to manage libraries across different Lua environments using virtual environments.
It’s still in the early stages of development, so it’s experimental — it might be buggy or insecure, and things are changing rapidly. My goal is to make LuaMoon simpler, faster, and more user-friendly than what’s currently available.
I’d love to get feedback from the community! Any advice, suggestions, or ideas for features would be hugely appreciated. If you’ve been frustrated by LuaRocks or other Lua package managers, LuaMoon is meant to address some of those pain points.
Check it out here: https://github.com/MXD-K1/LuaMoon
Thanks for looking, and I’m excited to hear your thoughts!
https://redd.it/1qw1vbb
@r_lua
Hi everyone!
I’m working on LuaMoon, a lightweight Lua package manager that aims to improve on existing tools like LuaRocks. LuaMoon is designed to be compatible with Love2D, LuaJIT, and Lua, making it easier to manage libraries across different Lua environments using virtual environments.
It’s still in the early stages of development, so it’s experimental — it might be buggy or insecure, and things are changing rapidly. My goal is to make LuaMoon simpler, faster, and more user-friendly than what’s currently available.
I’d love to get feedback from the community! Any advice, suggestions, or ideas for features would be hugely appreciated. If you’ve been frustrated by LuaRocks or other Lua package managers, LuaMoon is meant to address some of those pain points.
Check it out here: https://github.com/MXD-K1/LuaMoon
Thanks for looking, and I’m excited to hear your thoughts!
https://redd.it/1qw1vbb
@r_lua
GitHub
GitHub - MXD-K1/LuaMoon: LuaMoon is a modern, lightweight package manager for Lua, designed to make dependency management simple…
LuaMoon is a modern, lightweight package manager for Lua, designed to make dependency management simple, fast, and predictable. - MXD-K1/LuaMoon
Free lua obfuscator
An actually solid lua obfuscator i developed, it works for normal lua, and for hvh, i will probably try to update for roblox aswell
discord: https://discord.gg/vdBnvXBaJ4
https://redd.it/1qwgrww
@r_lua
An actually solid lua obfuscator i developed, it works for normal lua, and for hvh, i will probably try to update for roblox aswell
discord: https://discord.gg/vdBnvXBaJ4
https://redd.it/1qwgrww
@r_lua
Discord
Join the Proteus Discord Server!
Best Javanoscript Obfuscator | 25 members
Where to learn Lua
# Where to able learn Lua coding and its free which not going waste my time. I would like to try create game.
https://redd.it/1qvqlwj
@r_lua
# Where to able learn Lua coding and its free which not going waste my time. I would like to try create game.
https://redd.it/1qvqlwj
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
This media is not supported in your browser
VIEW IN TELEGRAM
I built interactive visualizations to understand Rate Limiting algorithms, implementation using lua, node.js and redis
https://redd.it/1qupxmk
@r_lua
https://redd.it/1qupxmk
@r_lua
ds.time: time objects in pure-lua including DateTime from epoch
https://civboot.github.io/lua/ds.html#ds.time
https://redd.it/1quf6mc
@r_lua
https://civboot.github.io/lua/ds.html#ds.time
https://redd.it/1quf6mc
@r_lua
My favorite part about coding in Lua..
..is having to write a custom function to print tables so I can actually debug.
I especially love watching that function get more complex than the project I'm trying to debug with it cause I want to use nested tables.
https://redd.it/1qtk4od
@r_lua
..is having to write a custom function to print tables so I can actually debug.
I especially love watching that function get more complex than the project I'm trying to debug with it cause I want to use nested tables.
https://redd.it/1qtk4od
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
I made a lua-based build system to help learn lua better. I've gained a good appreciation for Lua (Kindler Build System)
https://setsunasoftware.com/kindler/
https://redd.it/1qt7ki8
@r_lua
https://setsunasoftware.com/kindler/
https://redd.it/1qt7ki8
@r_lua
Need help finding out what's what
So I wish to modify a game to change the sound of the tinnitus ringing from flashbangs and explosions (Don't worry rule 8 enforcers, my file makes them louder and have a much more irritating tone.). I got the lua from a repository of the game files on GitHub. I have next to no experience with lua code, and I want to know what points to what or what does what, just so I know where everything points to to play the sounds and what I'd have to change (like the sound file format - currently it's .ogg, any errors in the code, or any files I'd have to create /rename to get it to work). Any help is appreciated! Game is Payday 2 by the way, in case that helps. Here's the code I copied:
function PlayerDamage:on_concussion(mul)
if self._downed_timer then
return
end
self:_start_concussion(mul)
end
function PlayerDamage:_start_concussion(mul)
if self._concussion_data then
self._concussion_data.intensity = mul
local duration_tweak = tweak_data.projectiles.concussion.duration
self._concussion_data.duration = duration_tweak.min + mul * math.lerp(duration_tweak.additional - 2, duration_tweak.additional + 2, math.random())
self._concussion_data.end_t = managers.player:player_timer():time() + self._concussion_data.duration
SoundDevice:set_rtpc("concussion_effect", self._concussion_data.intensity * 100)
else
local duration = 4 + mul * math.lerp(8, 12, math.random())
self._concussion_data = {
intensity = mul,
duration = duration,
end_t = managers.player:player_timer():time() + duration
}
end
self._unit:sound():play("concussion_player_disoriented_sfx")
self._unit:sound():play("concussion_effect_on")
end
function PlayerDamage:_stop_concussion()
if not self._concussion_data then
return
end
self._unit:sound():play("concussion_effect_off")
self._concussion_data = nil
end
function PlayerDamage:on_flashbanged(sound_eff_mul)
if self._downed_timer then
return
end
self:_start_tinnitus(sound_eff_mul)
end
function PlayerDamage:_start_tinnitus(sound_eff_mul, skip_explosion_sfx)
if self._tinnitus_data then
if sound_eff_mul < self._tinnitus_data.intensity then
return
end
self._tinnitus_data.intensity = sound_eff_mul
self._tinnitus_data.duration = 4 + sound_eff_mul * math.lerp(8, 12, math.random())
self._tinnitus_data.end_t = managers.player:player_timer():time() + self._tinnitus_data.duration
if self._tinnitus_data.snd_event then
self._tinnitus_data.snd_event:stop()
end
SoundDevice:set_rtpc("downed_state_progression", math.max(self._downed_progression or 0, self._tinnitus_data.intensity * 100))
self._tinnitus_data.snd_event = self._unit:sound():play("tinnitus_beep")
else
local duration = 4 + sound_eff_mul * math.lerp(8, 12, math.random())
SoundDevice:set_rtpc("downed_state_progression", math.max(self._downed_progression or 0, sound_eff_mul * 100))
self._tinnitus_data = {
intensity = sound_eff_mul,
duration = duration,
end_t = managers.player:player_timer():time() + duration,
snd_event = self._unit:sound():play("tinnitus_beep")
}
end
if not skip_explosion_sfx then
self._unit:sound():play("flashbang_explode_sfx_player")
end
end
function PlayerDamage:_stop_tinnitus()
if not self._tinnitus_data then
return
end
self._unit:sound():play("tinnitus_beep_stop")
self._tinnitus_data =
So I wish to modify a game to change the sound of the tinnitus ringing from flashbangs and explosions (Don't worry rule 8 enforcers, my file makes them louder and have a much more irritating tone.). I got the lua from a repository of the game files on GitHub. I have next to no experience with lua code, and I want to know what points to what or what does what, just so I know where everything points to to play the sounds and what I'd have to change (like the sound file format - currently it's .ogg, any errors in the code, or any files I'd have to create /rename to get it to work). Any help is appreciated! Game is Payday 2 by the way, in case that helps. Here's the code I copied:
function PlayerDamage:on_concussion(mul)
if self._downed_timer then
return
end
self:_start_concussion(mul)
end
function PlayerDamage:_start_concussion(mul)
if self._concussion_data then
self._concussion_data.intensity = mul
local duration_tweak = tweak_data.projectiles.concussion.duration
self._concussion_data.duration = duration_tweak.min + mul * math.lerp(duration_tweak.additional - 2, duration_tweak.additional + 2, math.random())
self._concussion_data.end_t = managers.player:player_timer():time() + self._concussion_data.duration
SoundDevice:set_rtpc("concussion_effect", self._concussion_data.intensity * 100)
else
local duration = 4 + mul * math.lerp(8, 12, math.random())
self._concussion_data = {
intensity = mul,
duration = duration,
end_t = managers.player:player_timer():time() + duration
}
end
self._unit:sound():play("concussion_player_disoriented_sfx")
self._unit:sound():play("concussion_effect_on")
end
function PlayerDamage:_stop_concussion()
if not self._concussion_data then
return
end
self._unit:sound():play("concussion_effect_off")
self._concussion_data = nil
end
function PlayerDamage:on_flashbanged(sound_eff_mul)
if self._downed_timer then
return
end
self:_start_tinnitus(sound_eff_mul)
end
function PlayerDamage:_start_tinnitus(sound_eff_mul, skip_explosion_sfx)
if self._tinnitus_data then
if sound_eff_mul < self._tinnitus_data.intensity then
return
end
self._tinnitus_data.intensity = sound_eff_mul
self._tinnitus_data.duration = 4 + sound_eff_mul * math.lerp(8, 12, math.random())
self._tinnitus_data.end_t = managers.player:player_timer():time() + self._tinnitus_data.duration
if self._tinnitus_data.snd_event then
self._tinnitus_data.snd_event:stop()
end
SoundDevice:set_rtpc("downed_state_progression", math.max(self._downed_progression or 0, self._tinnitus_data.intensity * 100))
self._tinnitus_data.snd_event = self._unit:sound():play("tinnitus_beep")
else
local duration = 4 + sound_eff_mul * math.lerp(8, 12, math.random())
SoundDevice:set_rtpc("downed_state_progression", math.max(self._downed_progression or 0, sound_eff_mul * 100))
self._tinnitus_data = {
intensity = sound_eff_mul,
duration = duration,
end_t = managers.player:player_timer():time() + duration,
snd_event = self._unit:sound():play("tinnitus_beep")
}
end
if not skip_explosion_sfx then
self._unit:sound():play("flashbang_explode_sfx_player")
end
end
function PlayerDamage:_stop_tinnitus()
if not self._tinnitus_data then
return
end
self._unit:sound():play("tinnitus_beep_stop")
self._tinnitus_data =