#Lovely - A runtime lua injector for LOVE2D

1 messages · Page 3 of 1

twin bluff
#

you can probably use the script as is but just replace the last line with your command to run it

wooden portal
#

wait wdym? those directories don’t exist

twin bluff
#

The first directory is the path to the game, and the last one is just pointing to the built in love binary the game has

solar pebble
#

or 🍎

wooden portal
#

apple

wooden portal
#

so what should the second one be? i dont believe i have a love binary

zealous void
#

right click the game icon in path to the game and select "show package content"

#

the .app extension usually don't appear

wooden portal
#

i'm running the game through the game engine

#

the game is a folder containing lua files

zealous void
#

change the last directory to the folder instead

#

normally it would be Balatro.love
extracting it gives the folder you're using

wooden portal
#

oh ok cool

#

so what should the first directory be?

zealous void
#

I don't think that's even needed

#

if you look at the last directory, you'll find that it simply prepends the first

wooden portal
#

oh wait true

#

so what directory should i add the mods to now?

#

idk whether or not it's working, but the game does run

zealous void
#

it's still ~/Library/Application Support/Balatro/Mods I believe
it doesn't matter how you run the game

wooden portal
#

i don't have a balatro folder, should i create one?

zealous void
#

yea

wooden portal
#

in application support

#

ok

#

what should i use to test it?

zealous void
#

steamodded itself, why not

wooden portal
#

sure

solar pebble
#

theres also a chance that the lovely binary won't work with the Love2d engine binary.

wooden portal
#

ok it doesn’t seem to be doing anything, but it could be because i installed steamodded wrong

wooden portal
#

ok i've tried for ages and this isn't working, so i'll put up a detailed outline of the problem i'm having:
i have the source code of balatro in a folder called 'balatro' as well as the love2d game engine. i normally run the game using the shell command love . from inside the 'balatro' folder. i've tries to instal love using the following shell script, also inside the 'balatro' folder:

export DYLD_INSERT_LIBRARIES=liblovely.dylib
/Applications/love.app/Contents/MacOS/love .```
the game runs successfully, and i get the following output in my terminal:
```INFO - [♥] Lovely 0.5.0-beta5
INFO - [♥] Game directory is at "/Applications/love.app/Contents/MacOS"
INFO - [♥] Writing logs to "/Users/myusername/Library/Application Support/love/Mods/lovely/log"
INFO - [♥] Using mod directory at "/Users/myusername/Library/Application Support/love/Mods"
INFO - [♥] Initialization complete in 3ms```
the directory `/Users/myusername/Library/Application Support/love/Mods` does not exist, and if i create it no logs appear. is it possible to get this to work, and if so what am i doing wrong?
#

(please reply ping me btw)

solar pebble
#

this is happening because we're deriving the name of the games app support dir from its executable. because you're launching the game via love, it uses that instead of balatro

queen spire
#

@solar pebble the regex bug is causing issues. could you release a new version of lovely?

solar pebble
#

absolutely

errant robin
#

🪲

fierce whale
#

🐛

wooden portal
wooden portal
#

@solar pebble ok, i looked into it a bit and, from my complete lack of knowledge of rust and dynamic libraries in general, i wonder if you could make a version of the dylib that directly reads all the necessary paths from environment variables rather than inferring them, so i could set the all up manually from the shell script

#

let me know if this is completely stupid since, again, i know practically nothing.

solar pebble
#

I also just remembered that you can set the mod directory via --mod-dir

queen spire
#

@solar pebble just saw this discussion. --mod-dir does not work with Steamodded on Mac

solar pebble
#

AH gotcha

#

yeah mb, a bit distracted atm

#

that should be integrated into the Mac version, will look at the code tomorrow.

#

that should fix your problem

solar pebble
queen spire
#

no, I think the problem was more complex than that- it was partly Steamodded's problem

#

uh, can't remember why it wasn't working. I'll get back to you on this

wooden portal
#

well we’ll get lovely working first, then move on to steamodded

solar pebble
#

yeah I'm a bit confused, I've been under the impression that it was working on Mac

wooden portal
#

it’s my weird environment i think

queen spire
#

ok, just found it. --mod-dir should work with just lovely; steamodded needs nativefs to honor --mod-dir

wooden portal
#

so what does that mean for me practically?

queen spire
#

@wooden portal if you're still around, I'm willing to help directly over DM

wooden portal
#

unfortunately i can’t rn, will you be available in 2-3 hours by any chance?

queen spire
#

just message me, I'll probably be around

errant robin
queen spire
#

@solar pebble --mod-dir is really inconvenient to use on Mac because the run_lovely.sh script itself changes directory

solar pebble
#

an env var would be nice to have. noted, will implement that maybe tonight and get a release out

wooden portal
gleaming elm
#

will lovely give any warning if two or even more mods are trying to modify the same line?

#

that could be horrible when you got many mods using lovely and find something is not working or even crashes the game

#

even worse, when mod A is modifying one line but mod B is modifying the whole code block that one line is in

proud arch
#

Help, I understand what it said but can't comprehend it

proud arch
twin bluff
gleaming elm
#

the fact that way too many modders are using ats everywhere in the toml and im not criticizing if bc in some case its the only solution to implement some features. imagine if a modpack got 50 mods, tho not possible for now, the possibility of the game being in this situation could drastically increase. modders can be haunted wasting time troubleshooting troubles and doing patches for other mods that are not even caused by my own problem.

#

so yea its more like a must for me, at least in the near future

twin bluff
#

I had a cursed idea

#

Lovely patcher

#

Patch the game using lovely stuff

#

Tbh it could be handy for platforms without natively lovely support

proud arch
#

Is that good idea

twin bluff
#

No

#

But it might be fun

errant robin
#

it's not too hard to do manually tbf

#

it might not be worth the av hassle

twin bluff
#

I mean simple stuff yes, but I'm curious about stuff like modules and how they would work

#

I should learn more about how the lua interpreter works

thick steppe
#

script files (e.g. lua modules) and functions (and loaded strings) are loaded/compiled to chunks which are lua bytecode and have debug info and upvalues (and environment pre lua 5.2), which decide the variables (globals and lexically scoped locals) that are available to that chunk, and truly global (chunk independent) storage is in the debug registry and the C API side

#

in LuaJIT that bytecode is further compiled to native code before it executes in the runtime

#

(no idea what the lua configuration is with love2D so just covering the bases)

#

when chunks are executed, they also are done so in a coroutine (usually the main thread), and there may be a debug hook set to interrupt this execution under certain conditions

#

AFAIK lovely is only capable of patching lua source files before they are loaded

solar pebble
#

well put and yes, that is correct

solar pebble
#

but like I said, time. I'm working on moving to a new place next couple weeks so don't expect anything substantial feature-wise

#

which reminds me that I need to get a release out

#

@queen spire sorry about that, like I said I've been a bit distracted

solar pebble
#

likely not going to happen for tonight as I want to redo how arg parsing is done

#

release is cooking, should be out in 10ish

gleaming elm
solar pebble
#

as you should. I believe in setting the expectation that the expectation will always be unrealistic

queen spire
#

@solar pebble obligatory poke, reminding you about the PR

solar pebble
#

I've allocated time to look at it tonight 👍

final void
#

Is there/will there be a way to see what patches don’t find anything
Might be very helpful for finding bugs

grizzled tinsel
#

I have ran into issues where sometimes it won’t show up.

#

Specifically when failing to make a pattern patch.

queen spire
solar pebble
#

PR is reviewed, I merge 2nite

solar pebble
#

mergied

queen spire
solar pebble
#

eating, been a busy day. allocated time for the release is in about an hour

#

and a general heads up that this is the last "beta" release. if the changes made here are validated to be good then expect a full release towards the latter end of this week.

final void
#

hype

grizzled tinsel
#

Had anyone else been getting this after lovely crashes from something else?

solar pebble
#

anything in the logs?

grizzled tinsel
#

Had a crash from a different lovely syntax error and clicking the ok box of that make this pop up

#

Recreating rn

#

Looks like any error has it pop up actually

#

Just caused a unknown variant and expected '.', '=' error and it showed up so this doesn't look isolated

solar pebble
#

my cursory guess is that we're panicking within the panic hook, interesting

#

@queen spire Issue #55 should be fixable by adding a flag to each patch which denotes whether or not that patch has been applied or not

#

however it's tricky though because we never know if we've actually patched every possible source file or not

queen spire
#

that seems reasonable. I do question the algorithm used purely on a code style basis, of course

solar pebble
#

that's always fair

#

this is an annoying problem because there's no "end"

#

at least nothing certain

#

eh, it's an edge case

#

I think it'll probably be fine if we iterated through the collection of patches at the end of the hook to ensure that everything has been applied

#

either solution is reasonable

queen spire
#

so could you give me a high-level overview of how lovely does patches?

#

(I am not asking just for myself, probably a lot of people have no idea...)

#

I'm curious as to why some people were having the problem of lua_reload.lua running during lovely patching. from my current understanding that would be impossible, but clearly I don't know what's going on

solar pebble
#

Prelude:

  • Lovely injects itself into the game process via DLL sideloading - the technics are irrelevant, what we care about is getting our bootstrap code running.
  • Lovely searches for patch files within the game directory, of which is either automatically determined from the executable name or provided as an argument.
  • Stuff happens to these patch files which turns them into a text file into something that we can use in code.
  • A function hook is installed into the Lua runtime function lual_loadbuffer. This means that every time the game calls that function it runs our code instead.

Runtime:

  • Every time the game calls lual_loadbuffer it provides a buffer of text code and the "name" of the module. Lovely uses the provided "name" to determine which patches are to be applied.
  • Each patch is applied by modifying the provided text buffer. Most common is the pattern patch, which searches through the code for a pattern match and then writes the payload to a position relative to the matched line.
  • Once complete Lovely converts the now patched text buffer back into something that the Lua runtime can understand.
  • And finally Lovely recalls the original lual_loadbuffer to load the patched code.
queen spire
#

ok, lual_loadbuffer is some C function. Can Lua code override lual_loadbuffer? If it's just an entry in some table somewhere it can be modified

#

or, is that thing fixed

solar pebble
#

It's complicated - yes and no

#

Lovely in theory installs the loadbuffer hook prior to LuaJIT, but during runtime when the game is actually calling loadbuffer we can assume that code is being executed.

#

lual_loadbuffer itself can't be overwritten but the LuaJIT function reference to it absolutely can

solar pebble
#

But what's hard is that any solution we go for needs to be fundamentally portable

solar pebble
queen spire
#

alright. clearly debugging this problem is quite difficult. Thanks for explaining everything

solar pebble
#

I can look into it, send me the details to repro.

#

It's just some reverse engineering

queen spire
#

you can't repro

solar pebble
#

fun

grizzled tinsel
#

Random question: does failed pattern patches show up as a failed query in the logs or is that specific to failed regex patches?

solar pebble
#

The implementation should be pretty easy all things considered, it'll likely just be another Lua runtime function hook

#

But finding out which is causing that problem specifically is tricky

#

build failed

#

damn it worked on my end lmao

#

ah I see why

#

one moment

queen spire
#

still confused about how this lua_reload bug can possibly happen. I can describe what lua_reload.lua might be doing- it overwrites the global require function, as well as a bunch of others. but all these functions are implemented in terms of lual_loadbuffer anyway?

solar pebble
#

no release tonight lads

queen spire
#

gah

solar pebble
queen spire
#

no, it's a file distributed by Steamodded

#

that module is loaded at the beginning of main.lua, and then somehow when game.lua is loaded it's through that file's function

#

ok, edited- that may be trouble

solar pebble
#

main.lua gets executed as per JIT, lua_reload does some funky shit, blam bam boom

queen spire
#

specifically, I thought that lua.reload was copied, but actually it's injected with a module patch

solar pebble
#

ah yeah that still incurs an execution

#

our solutions are to either hook the lua runtime C functions that lua_reload ends up calling, demand that lua_reload be rewritten with lovely in mind, or fundamentally change how we code injection

#

the former is the most plausible as of now

#

I can look into it tomorrow

#

more pressing is fixing the darwin build failure

grizzled tinsel
#

Text wall jumpscare

solar pebble
#

pattern patches dont, bad regex patterns will but that's purely on syntax

#

when the pattern can't be compiled

#

and it'll warn you when no matches have been found

#

I might be wrong though on pattern patches, I don't remember

#

ejwu didn't you add a warning when a pattern patch didn't find a match?

queen spire
#

yes, I did

#

oh, call me ejwu if using a username

grizzled tinsel
#

I ask because I don't remember seeing any indication of a fail and had to look at the lua dump directly to check.

#

Lemme try to force one

queen spire
#

yes, I added a check for that

#

it was not there before

grizzled tinsel
queen spire
#

yes, there is no check currently. I added one, but it'll only be there in next release

#

if you can build lovely yourself, you'll get the new tech

grizzled tinsel
#

Unfortunately I don't, but good thing that it's there.

solar pebble
#

so many patches

#

I feel bad for the game

grizzled tinsel
#

The prints can also go crazy

twin bluff
#

Btw has anyone did some digging on why lovely requires don't work when reloading the game using love's built in reload?

#

Also iirc it breaks the logs

#

Can be seen with steamodded and crashing and hitting r to reload

grizzled tinsel
#

There was discussion about lua_reload issues

twin bluff
#

Iirc Lua_reload is something different but maybe I'm wrong

#

Also I might have a use for getting my patches directory now

thick steppe
#

like modules rolling their own subdirectories via loadfile rather than require should be fine too (unsure if that's relevant, just an example of there being multiple ways to do similar things in lua)

#

(regardless of however they're handled in 'steammodded')

#

better to avoid 'surprise' when a dev wants to take general lua stuff and apply it (unless it's somehow in conflict with Love2D itself, can't really control that)

solar pebble
#

I've been investigating it, it's not that difficult, just annoying.

#

And a general heads up that I'll be on vacation until August, so I won't be responding very quickly.

reef locust
#

windows is for some reason always deleting version.dll from my balatro folder whenever i restart it

#

any solution to that?

#

i keep coping version.dll into the folder but it keeps deleting it each time

#

i guess its some windows defender issue

grizzled tinsel
#

It’s getting flagged as a virus

#

Which we can’t do very much about other than turning Windows Defender off when handling version.dll

reef locust
#

i mean it was working before

#

idk maybe there was an update

errant robin
#

windows defender has recently started flagging lovely for some reason

stiff raven
#

finding the 'threat removed' event in protection history in defender and restoring the file seems to whitelist it from defender

solar pebble
#

Gotcha gotcha, we can likely mitigate this by submitting a copy to Microsoft for review.

errant robin
#

I fear they won't approve if they're implementing strict policies like this

#

Given it's not fully wrong on the "potentially unwanted behavior" part - Bad actors could try to hide malware as a useful mod, and unsuspecting users may or may not run it without checking source, while defender would have a harder time catching on

pale gull
#

Error

Syntax error: game.lua:4: '=' expected near 'Game'

Traceback

[love "callbacks.lua"]:228: in function 'handler'
[C]: at 0x7fffd6a52fa0
[C]: in function 'require'
main.lua:16: in main chunk
[C]: in function 'require'
[C]: in function 'xpcall'
[C]: in function 'xpcall'

#

chat can someone explain this

#

ive tried everything but i cant use lovely

#

if i try without steam modded it just doesnt load mods btw

proud arch
#

That looks familiar

grizzled tinsel
#

Verify game integrity

#

This is from the old steamodded injector trying to inject and failing.

pale gull
#

ah sweet

gleaming elm
#

quick question what exactly is match_indent? is it to set whether the patch should match the whitespace at the beginning of the pattern?

twin bluff
#

got wondering what lovely can actually patch into, and it turns out, it can patch built in love2D files

#

but it fails to dump due to invalid file names

#
[[patches]]
[patches.pattern]
target = '=[love "Data.lua"]'
pattern = "end"
position = "at"
payload = 'end -- Hi mom'
match_indent = true
overwrite = true
#

althoguh it doesn't let me patch steamodded mods

final void
#

LMAO

twin bluff
#

wait I have a crazy idea

gleaming elm
#

replacing love2d with unreal 5

twin bluff
#

what if I added a copy of the balatro crash handler into the first file loaded so you get a fancy error handler for syntax errors caused by lovely

grizzled tinsel
#

That would be awesome.

twin bluff
#

doesn't look like every love file is hooked

#

not sure how it works

#

hmm a file named Data.lua is loaded a bunch of times but it looks like love doesn't have a file called that

#

wonder if its some kind of special wrapper

queen spire
#

discussing how lovely works? it might be helpful to know, lovely changes the lual_loadbuffer C function

#

in theory that's used by most methods of loading

twin bluff
#

I don't understand how lua works well enoguh to know how that effects it

queen spire
#

alright never mind, sorry

twin bluff
#

that's okay

#

The lovely crash handler is real

#

I guess I could add a patch to remove the game's built in crahs handler and then its the steamodded crash handler for not steamodded copies of the game

void juniper
#

Game is not launching with latest version

#

How to fix?

#

No errors, just not launching

twin bluff
#

Check your anti-virus

#

I've never seen it do this, but it might be interfering

errant robin
#

could also be steam not running if steamodded is not or improperly installed / outdated

void juniper
#

Ok, Windows Antivirus was a problem 🤦‍♂️

uneven warren
#

interestingley enough, beta-4 is allowed by microsoft

#

still, I'm hoping this issue gets solved

errant robin
#

@solar pebble I'm once again coming back for lua_reload has ultimately failed me. Is it possible for lovely to provide a way to soft-reload game files?

twin bluff
#

Maybe I should see if I could fix lovely on hard reloads

#

I think it should be as simple as just rerunning the init stuff (I hope)

errant robin
#

that would at least be better than literally running the game through steam again and killing the old instance

#

soft reloads would be nice but they might just be dead

twin bluff
#

Yeah

#

I also wonder if maybe lovely could provide a method to hard reload

#

Could maybe get some benefits, like if patch files haven't changed, don't have to repatch files (depending on if lovely caches that)

errant robin
twin bluff
#

Regarding the issue, hard reloads are something we can do without steam right now (the crash handler does it right now), but it breaks lovley in the process (only partially)

errant robin
#

I'm aware, just bringing it up as well because it's not workable currently

twin bluff
#

okay I just don't get rust

#

@solar pebble I'm trying to get lovely to work properly when reloaded using love's reload function. Basically, the main issue is that the lovely module get's de-registered, (theres also some other issues, like logs being lost). I belive that if I was able to re-run this block https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-core/src/lib.rs#L147-L154, it should fix these issues (although not do everything, like reloading patch files). However, I don't know how I would get this once to reload. I figured, maybe I could destruct and reconstruct a new lovely object, which should properly reload everything. However, i have no idea how to do this in rust. Seems like you need to make a drop method, which I don't know how I would do, or even what all would need to be done to drop the lovely class. Is there anything else you could think of to acheive this? Some feedback would be appreciated. Also I got to try to figure out how to detect when the runtime is being reset, but I do have the love2d code and can kinda understand it, so I should be able to figure smth out

twin bluff
#

yeah I was messing around and I can't reset the once, or reset the runtime cause I don't have a mutible copy of lovely, but i can't make a mutable copy of lovely cause its not thread safe

#

I also am not sure how to get it hooking int varibles, but it appears that love2d calls luaL_newstate everytime it starts the machine, so you should be able to init in that and get the restart stuff working (?)

thick steppe
#

on reload a signal should be passed to the reloaded file so it knows to only update code that contains idempotent side effects

#

such a signal can be modelled by the absence or presence of a variable in your chunk

#

such as whether your mod already exists

#

in the global container of mods

#

or something like that

#

it's easiest if all callbacks/listeners/hooks that a module subscribes to clears themselves by being notified when that module reloads

#

that way you don't need to defer the callbacks to definitions of functions

#

that get overridden by the reload, thus changing what the hook does without creating a new hook

#

you can't expect that reloading a mod (performing an action over the game state an additional time) wouldn't cause stacking side effects

#

moreover if there are effects that need to happen at certain points in the lifecycle of the game

#

then reloading will break the integrity of the game/mod if there's anything changed that relies on events that have already happened and can't be safely triggered again

errant robin
#

I have however been unsuccessful in finding a way that actually achieves this for modules that modify the global state

thick steppe
#

but maybe love2D has a special model

#

like most games that have a lua system are still mainly managed in native code

thick steppe
#

recursively

#

then merge the result with a policy

#

this would be really slow because the global state is gonna be super dense

#

but you can contagiously populate only what those base things touch each

#

other than that, lol no the code is just not designed that way

errant robin
#

I think getting love.event.quit('restart') to work again will be good enough tbh

thick steppe
#

¯_(ツ)_/¯

solar pebble
#

I'll catch up with everything when I've got internet and my PC setup in our new place. blueprint

twin bluff
#

Understandable. Hope your ready for the insane ramblings of a guy who doesn't know what's happening

final path
#

for some reason my computer is detecting a virus when i try to download the lastest version of this injector. what do i do. im on Windows 10 if that has anything to do with in

errant robin
final path
#

damn

errant robin
#

you'll have to whitelist it

final path
#

how?

errant robin
#

In Windows Security, go to Virus & Threat protection > Manage settings

#

Scroll down and click Add or remove exclusions

#

from there, add the folder of your Balatro installation as an exclusion: C:\Program Files (x86)\Steam\steamapps\common\Balatro

#

turning off real-time protection can be useful to stop it from preventing you from moving the file where it needs to go

clear oyster
#

Honestly, there seems to be enough confusion about pattern matches and whitespace, it might be worth introducing partial line patches

#

Regex patches matching over multiple code lines get reeeeeally messy

celest swallow
#

huh

#

if your partial line appears multiple times in code, it doesn't matter if regex used or not

#

It's going to be matched in all those places

#

I think multi line pattern patch is what would make regex not needed for the most cases

errant robin
#

it is also not well known that pattern patches support wildcards

celest swallow
#

if you don't know that patterns can match multiple different places in file then its more of a skill issue balatrojoker
best solution for it is to mention that in readme

errant robin
#

which doesn't work that well for replacement patches since you're still replacing the full line, but for before/after positions it's fine

clear oyster
#

I meant more in like text matches, but allowing for indentation in the source that's not present in the patch

celest swallow
#

hm

#

can you give an example

clear oyster
#

Patch pattern:

if x then
    y()
end

Source:

        if x then
            y()
        end
celest swallow
#

isn't that just multi line pattern? the thing that I suggested?

clear oyster
#

allowing for indentation in the source that's not present in the patch

celest swallow
#

ye but I'm pretty sure multi line patterns aren't supported?

#

I thought you can only regex those

errant robin
#
pattern = '''if x then
[\t ]*y\(\)
[\t ]*end'''
#

multiline patterns are regex only, yeah

celest swallow
#

then add [\t ]* in front of each line

#

quick and simple

clear oyster
#

The idea I'm suggesting is to add such a kind of multiline tab-insensitive pattern so we don't need huge regexes for them

celest swallow
#

ye that's fine by me

twin bluff
#

Maybe just even a multi-line option for pattern patches

errant robin
twin bluff
#

Someone should maybe rework the readme

#

The example is kinda a silly steamodded hybrid

#

But doesn't even work in steammodded yet

twin bluff
#

module patches use the file name of the before file for their crash file's

#

realisticsally, it should be the file name of the file I'm injecting, or some special chunk name liek love or Steamodded use

clear oyster
#

Are the regex patches supposed to be able to replace parts of lines? Or only whole lines?

celest swallow
#

regex can replace parts of lines

clear oyster
#

Is this intended functionality? The docs only mention replacing entire lines

errant robin
#

it says that for pattern patches

clear oyster
#

IMO it should not match and replace parts of lines by default, it's leading to some unintuitive behavior right now

errant robin
#

have fun making a custom regex implementation that does that

#

it's meant to be universal

#

also changing the default would break all existing patches, no thanks

clear oyster
#

I just implemented a change that does just that (in my own stuff), very little breakage

#

Internally it just puts line anchors on the ends of the pattern

errant robin
clear oyster
#

Though fair point, I think I have a more elegant solution that doesn't involve implicit anchoring

twin bluff
#

Just use ^ and $

#

If argue regex sould behave the exact same as if I ran the regex on the file manaully

twin bluff
#

What we should probably do is make pattern patches work better in more situations, so we aren't using regex when we dont need regex

clear oyster
#

Right

opal bolt
#

@solar pebble just in case you haven't seen this, my account (ejwu) has been hacked, ejwu and AlexIsGreat are compromised

solar pebble
#

how do I know that you're not an imposter 🤔

#

but heard, hope you can restore access to those accounts

opal bolt
#

actually Alex is someone else

#

I have restored access to ejwu, actually, Discord was really fast for once. thank you

opal bolt
solar pebble
#

likely tomorrow if you send me macos binaries

#

since the build pipeline is borked

twin bluff
#

I might be able to build macos binaries, if you need it

#

I recently revived an old mac

opal bolt
#

actually er, gotta build for x86 probably

solar pebble
#

I'm also happy to build them tomorrow on my Linux VM

#

... if zigbuild isn't totally broken lol

opal bolt
#

I've sent you a friend request, I can't dm you

clear oyster
#

I still haven't figured out how to make my cross-compiles to the windows-msvc target not blow up

#

They seem to work right up to a particular point and then come crashing right down

#

For some reason, I observe the same behavior: Lovely makes some decent progress on patching, but right at a particular point it gets hit with some kind of fault signal

twin bluff
#

What os are you compiling on?

#

On linux, to get it to compile, I had to remove the #[cfg(target_os = "windows")] in lovely-win/build.rs and also change the path to where I had my version.dll (in my case /home/shorty/projects/external/lovely-injector/version.dll)

#

copiled using cargo xwin build --package lovely-win --target x86_64-pc-windows-msvc --release

clear oyster
#

Okay, I'll try that

#

I wouldn't think to try doing that, that's not a typical step in a cross-compile workflow

#

I should probably neaten up my hodgepodge of edits to contribute back

clear oyster
#

Where'd you source your original version.dll?

twin bluff
#

uhh idk

clear oyster
#

ok thank you

civic raft
#

not balatro, but adding an extra empty line above some code causes the game to crash. any insight? other patches work fine for this game?

#

well, i found the problem? but i dont understand it. the output has cut off the last character of the file, which just so happens to cause it to fail entirely.

celest swallow
civic raft
#

i dont have acess to the files at the moment, but it seems that at some point during the patching process, the last character was being removed. the change from return st to return s caused it to crash. i was able to fix it by adding another patch, replacing return s with return st again. As far as i can tell it either only happens in this file, or other files have a newline at the end, nullifing the issue.

celest swallow
#

heh

#

did you add the other patch after your first one

civic raft
#

yup

celest swallow
#

because it basically nullifies the first one

#

so if first one caused syntax error, no wonder the other patch fixed it

civic raft
#

yeah, exactly

celest swallow
#

what is your point with ignoring last character tho

civic raft
#

the question is why the 't' got removed at all

#

i was patching an entirely different part of the file

celest swallow
#

well, I really find it hard to understand what exactly you're doing, so can't help you with that without the code snippet and toml file

#

just know that patches apply to entire file, so pattern needs to be unique

#

if you only want to replace smth once

#

use regex patch

#

and cover multiple lines

civic raft
#

i was taking one unique line, adding a print call before it, unrelated to the return at the end of the file

#

which by quantum entanglment??? i suppose, caused the character in an otherwise untouched part of the file, to dissapear.

solar pebble
#

I'd like to see the patch file as well, this could be a bug

civic raft
#

patch was essentially [[patches]] [patches.pattern] match_indent = false target = "states/SongSelect.lua" pattern = "elseif self.menuItems[self.selection].editor then" position = "before" payload = ''' elseif self.menuItems[self.selection].reload then self:getMenuItems() '''

#

targeting inbetween 339 and 340 here

#

return at the end with the removed t (not missing in this image)

celest swallow
#

if you go to %appdata%/gamename/Mods/lovely/dump

#

you can find dump for this file

#

and see how it looks like after applying patch

civic raft
#

the dump is exacly how i want it to be other than the missing t at the end. this is not caused by the patch, there is nothing affecting that area with a patch. ANY patch on the file causes the missing character.

celest swallow
#

must be lovely bug then

clear oyster
#

@solar pebble Is it intentional that regex patches can insert characters such that they concatenate to identifiers in the existing source? I'm currently wrestling with one such patch

#

And it's causing syntax errors in very confusing (and likely platform-dependent) ways

celest swallow
#

regex patches do not insert a new line

#

for before/after, unlike pattern patches

clear oyster
#

Right

celest swallow
#

because you can have regex that isn't a full line

#

and might want to insert something after like 1 word, within the same line

clear oyster
#

My problem is that the patch I have on hand is sticking chars immediately before its target, prepending characters to the beginning of a keyword and causing syntax errors

#

This is pulled right from the mod's source

errant robin
#

just insert a newline at the end?

celest swallow
#

or a space

clear oyster
#

The issue is this is someone else's patch causing this

#

Not mine

celest swallow
#

what mod?

clear oyster
#

Saturn

celest swallow
#

probably just a mod bug then 🤷‍♂️

clear oyster
#

Yeah but that this kind of bug is even possible seems like a flaw in lovely

celest swallow
#

do you have any other mods or steamodded?

#

because I know that saturn is incompatible with steamodded

clear oyster
#

Mhm

celest swallow
#

or, last I checked

#

maybe it's not anymore

#

I'd assume this behaviour might happen from some lovely patch failing because of steamodded/another mod

clear oyster
#

I've been hacking at Lovely at the source, and so far I've only been able to make the issue go away by making the injector automatically pad patches

#

And trying to be "intelligent" so as to not insert space where not needed to avoid this kind of issue is not really working out

clear oyster
#

Look, unless there's a good reason for it to be possible, I'm going to make it not possible (at least not without a more involved patch that explicitly matches against the identifier to modify)

twin bluff
#

I mean if you need to rename a variable

clear oyster
#

Again, capture it explicitly in the pattern

twin bluff
#

I'm not quite sure what your issue is?

clear oyster
#

I just described it above

twin bluff
#

I read that but I don't quite understand what you mean

clear oyster
#

This kind of thing should not be happening

#

This is the offending patch:

[[patches]]
[patches.regex]
target = "functions/UI_definitions.lua"
pattern = 'end\s*\n\s*end\s*\n\s*local\s+flip_col\s*=\s*G\.C\.WHITE'
position = 'before'
line_prepend = '$indent'
payload = 'view_deck.config.card_limit = card_count'
errant robin
#

I'll once again have to advocate for leaving regex patches unrestricted as a default

twin bluff
#

yeah me too

#

also I'm not even sure what lead to that

clear oyster
#

What's not wrong with card_countend being formed and causing a syntax error

twin bluff
#

oh wait

#

With the before tag

#

I mean this seems like an issue this the mod,

clear oyster
#

Don't think djynasty is much of a skill-issued person, this is either a subtle platform difference or a nasty interaction with another patch

twin bluff
#

well I assume it works like this, which is just a this patch is wrong

twin bluff
#

I took the raw source file and mapped it there

#

I'd argue we make it where pattern matches can properly match multi-line stuff so that less people need to use regex, rather than modify how the regex behavies, to maybe stop some accidental issues with patches

clear oyster
errant robin
#

I'm all for reducing the use of regex patches, pattern patches are a lot more efficient

twin bluff
#

hmm it doesn't error like that on my lovely?

#

are you running the latest lovely release?

#

I wonder if there was some change in behaviour somewhere

errant robin
#

are you running beta7?

clear oyster
#

I'm even further than that

#

I'm trying to develop lovely's code on my own system

twin bluff
#

can you verify you didn't break the patch with your changes?

clear oyster
twin bluff
#

hmm

#

the patch works on mine 5.0 beta 6

#

I gtg rn

#

I don't see how this patch would break, unless another patch is modifying something on top. There might be a lovely bug here

#

Do you have the other patxh that breaks this one?

clear oyster
#

Idk, I'll probably have to look for a patch that targets similar lines in the same file

zenith shuttle
#

anyone know why the version dll just vanished after a few days

#

I think my antivirus ate it when I turned it back on, is there a way to stop that from happening?

spice spoke
zenith shuttle
#

thanks

opal bolt
#

hey, discussing weird behavior with lovely? It's probably a bug, I already made an issue for it

#

there is something wrong with the logic for regex patches, but I wasn't able to figure it out

twin bluff
#

What's your patch?

clear oyster
solar pebble
#

god tier work, thanks

#

@opal bolt I'm going to add you to the review

#

well when I hop on my laptop later harold

thick steppe
#

I was about to informally review it but there's too many superficial changes

gleaming elm
#

hey how's the linux port going? (yes i know theres a pr but its just frozen up there)

true pagoda
#

what would running atively on linux matter when the game itself is proton?

gleaming elm
#

im not even running the game on steam deck or anything proton related

true pagoda
#

There is no native linux version of Balatro, at least not through conventional means

#

the version on Steam is the Windows version run through proton

#

Unless you don't mean Balatro. I know there are other Love2d games

gleaming elm
#

lovely's linux support got raised to high priority and theres literally a pull request implementing it so i am just asking the developers hows it going

true pagoda
#

fair

#

I can only guess it's for other Love2D games, unless Balatro is going native too

twin bluff
#

I mean it's fairly trivial to repack balatro into a Linux format, but yeah, if also helps with other native games

solar pebble
hollow birch
#
# After Draw Context
[[patches]]
[patches.regex]
target = "game.lua"
pattern = "first_hand_drawn = true}\)\n(.*)end\n(.*)end"
position = "after"
payload = '''
if not (G.GAME.current_round.hands_played == 0 and
    G.GAME.current_round.discards_used == 0) then
    for i = 1, #G.jokers.cards do
        G.jokers.cards[i]:calculate_joker({vic_hand_drawn = true, vic_facing_blind = G.GAME.facing_blind})
    end
end
'''
match_indent = true

Does anyone know why this patch fails? The error message mentions some issue escaping a character

hollow birch
#

@celest swallow helped me—I had to use single or triple-quotes instead of quotation marks

civic raft
#

is it expected that lovely does not work with love2d 12?

errant robin
#

seems reasonable given it was made with love 11.5 in mind

#

I'm not entirely sure what love 12 changes, but I don't think it should be that hard to adapt to it?

civic raft
#

but it is released

#

my assumption is that it uses something other than luaL_loadbuffer?

#

it actually still uses lua5.1 though

clear oyster
#

Think latest is still 11.5

#

That's what's on the front page

#

Also, Lovely on Linux? How?

errant robin
#

Proton

#

there's no native Linux build for balatro

#

but also there's a PR for native Linux support on lovely

clear oyster
#

How can I try this out for myself

civic raft
#

it seems like the LOVE2d files are working but the game files are loaded differently?

#

too wide

civic raft
#

i found the fix but i dont know how to implement it in a way that still works with balatro.

#

yikes

civic raft
#

Any rust heads know why this dosnt actually call the original and actually just calls the new detour, causeing a stack overflow every time the game is opened?
LuaLoadbufferx_Detour.call(a, b, c, d, e)

twin bluff
errant robin
#

ik

solar pebble
#

@civic raft great work on that PR, left some review comments for you to resolve.

#

Also @clear oyster , excellent job. Left some comments for you to look over when you get a chance.

clear oyster
#

Next thing I'm interested in doing is adding diagnostics for which file (and line, if feasible) a patch came from

#

Also, possibility of having Lovely making its functionality available to Lua code as a Lua module?

twin bluff
#

One thing that makes that difficult is that you need to basically load the Lua before the file your patching is loaded.

#

However, if lovely can get a seperate Lua instance, it could probably run a peice of lua code while a buffer is loading and givr it the buffer and take it'd return value

clear oyster
#

I mean, like, as in being able to require lovely, and then load up your own file and lovely-patching it (at a time after the original code is already loaded and patched up, we're not doing self-modifying code)

twin bluff
#

What's the point if lovley patching your own file?

clear oyster
#

Okay, weird hackery aside, you might have your own files in your own dir that you want to do stuff with

errant robin
clear oyster
#

Okay, maybe parts of the functionality, like much faster regexes or serialization/deserialization might be more compelling

twin bluff
#

TBH I think lovely should just have it where require works as intended for lovely modules

#

So they can require other parts of their code

errant robin
#

I don't think there's enough information for that if your code is actually part of main.lua

twin bluff
#

Not for injected code but there should be for modules

errant robin
#

yeah but wasn't there a thing where modules are also just in main.lua?

twin bluff
#

There filename matched whatever the beifre is (idk why) but they are still technically their own buffers

#

They keep their line length, etc

errant robin
#

meh that's still jank

twin bluff
#

I mean require working like intended wouldnt be jank

errant robin
#

yeah

clear oyster
#

I've been looking into the DebugPlus issue I've had, and my latest finding is... I'm somehow getting a string out of a require call?!

#

Printing the string, it seems to be an error string of some sort

#

... Hold on, lua_pcall's return value isn't being checked

#

Okay so it is an error message, for what is most likely an error in trying to evaluate the module's code

twin bluff
#

Can you print the error message?

solar pebble
#

a lua coruntime might work

#

but it's a cost/reward sorta deal

clear oyster
#

(Yes, that's literally the value of the string from printing it)

twin bluff
#

Which require are you printing?

clear oyster
#
GitHub

Better Debug Tools for Balatro. Contribute to WilsontheWolf/DebugPlus development by creating an account on GitHub.

GitHub

Better Debug Tools for Balatro. Contribute to WilsontheWolf/DebugPlus development by creating an account on GitHub.

#

I'm printing util

#

Hold on I reset to origin/dev and I'm not getting that anymore, I did a goof it seems

#

Well dangit all signs point back to me

twin bluff
#

Well glad you got it working

clear oyster
#

The ultimate culprit? A missing newline. (Specifically trailing at the end of util.lua)

twin bluff
#

That seems odd

clear oyster
#

That UX could use some improvement

#

Maybe check the return value of the pcall and respond accordingly?

twin bluff
#

Which pcall?

clear oyster
twin bluff
#

Oh lovlely's pcall

clear oyster
solar pebble
#

It was considered but I never went through with using it. The power and simplicity of calling the native API was preferred back then.

rugged abyss
#

iirc for windows reasons you can't really just extern lua symbols and you have to use libloading so that might also be an issue

#

huh, apparently it's only an issue for the detour target

clear oyster
#

Also just noticed that lua docs officially say package.preload is the official way of loading packages into lua from outside

clear oyster
#

Next thing I might try to do is inject things there instead of to package.loaded (and wrap the pcall a bit better)

errant robin
#

Wondering if there's a way to make lovely patches interact with loaded strings, either by making them use luaL_loadbuffer as well or hooking whatever they are using?

clear oyster
#

Any more hurdles before better patches is merged in?

gleaming elm
#

im sorry but the idleness of this project is lowkey driving me crazy

errant robin
#

yeah fr I should learn rust just so I can go contribute

deep raven
#

don't learn rust it is too good

errant robin
#

you're right I won't be able to go back

true pagoda
#

Steamodded's death came suddenly in early 2025 after a bold but misguided attemp to switch to a Rust api

solar pebble
solar pebble
#

@clear oyster merged your code, nice work

clear oyster
#

Alright up next, I'm making the lua module loading less janked

clear oyster
#

Is there a reason why the module chunk is evaluated immediately rather than being left as is (as a function)?

#

Or is this just a quirk of how the modules are being loaded?

twin bluff
#

I'm not too familiar with lia but I believe they are being added to its moduke cache as already loaded

#

Wait are they actually run as soon as they're injected?

#

Or just proxessrd

clear oyster
#

Seems like the files are being executed upon being loaded in

#

Then the results of evaluating those files are put into the cache

twin bluff
#

Oh intersting

#

I might be able to (ab)use that

true pagoda
twin bluff
#

Nah I could never dpell

errant robin
#

debugplus-ell balatrojoker

twin bluff
#

Proof i cojkdt spell in 2019

errant robin
#

that's not thta bad

twin bluff
#

Well I was just stating I couldn't spell

#

The spelling kistske was in code I wrote

errant robin
#

then it's just proof you claimed you couldn't spell in 2019

twin bluff
#

Well I'm not on desktop so I can't just go to the start of that channel and scroll down to the first spelling mistake

clear oyster
#

Idk if there are maybe mods out there that subtly rely on the eager-evaluation nature of steamodded module loading

twin bluff
#

I could make use of it but I don't right now

#

Actually though it might be nice to run my code before a file (like the one patch that just injectd my code) but not actually injecy my code into the file to make stack traces nicer

#

Speaking of stack traces does anyone know why modules have the same name as the file they are injecting before?

#

I looked at the code and it should be fine

#

But it just doesn't work

clear oyster
#

I'd rather not people abuse the eager nature of lovely module injection unless there's no other way

clear oyster
#

Also why is everyone vendoring their own copy of NFS under the same name without even bothering to namespace

twin bluff
#

Idk

#

I just use love.filesystem

clear oyster
#

Also a while ago you mentioned something that you said needs to be done for restarts to work better, can you link me back to it

twin bluff
#

Link to where I was discussing with meth and it links to what I mentioned here

solar pebble
#

I don't exactly remember what those components are specifically as it's been a minute

clear oyster
#

I'm suggesting using package.preload

solar pebble
#

But in general yes, eager execution isn't the best way to go about it, but it was convenient and enough for nfs at the time

#

ah yeah, that's what I was trying to remember

clear oyster
#

package.loaded is supposed to be the cache

solar pebble
#

I do remember having some weird behavior from mutating package.preload at runtime, but afaik it's likely a skill issue

#

The module system was sorta wholly meant for nfs lol, hence the fuglyness

clear oyster
#

Everyone's vendoring their own copy of nfs :p

#

I've actually went ahead and tried changing out things to use package.preload, seems to work fine

twin bluff
#

See if DebugPlus works fine with it

#

I use modules a bit

clear oyster
#

I'll look at that

fathom portal
#

someone help

#

main.lua is missing?

#

I'm trying to install steammodded 1.0.0

proud arch
#

did you verify game integrity?

fathom portal
#

no

#

how do i do that?

proud arch
fathom portal
#

so this part?

#

bet

#

okay it works

#

thank god

proud arch
#

good good

twin bluff
#

Oh also for some reason the file name for modules in the current version is the file they are injected before and not their name

#

I looked at that one and I don't see why that'd the case

celest swallow
clear oyster
#

I'm personally of the opinion that it might be better as an new patch variety

#

But honestly that's bikeshedding

#

Also I made progress with getting lua module support to be a bit less hacked together

celest swallow
twin bluff
#

I don't think it fits as a new patch type but it would be nice to have some kind of lovely config file that has things like this as well as some metadata like name author and version of the mod

celest swallow
#

yea I don't really feel like doing allat

#

just needed this to allow making steamodded more vanilla without splitting it up too much

twin bluff
#

Yeah that wouldn't be a simple PR but it would be nice

grizzled tinsel
#

How exactly does patches.copy work? I'm trying to get code to append main.lua after Steamodded adds it's code (easier to add modded compat for a mod meant to work with vanilla when it's being loaded on startup after SMODS global is created) but no matter the priority I set the .toml file it seems to always be copied and added before the rest of the mods.

#

This is assuming that adding priority to a .toml works (it should).

#

In fact messing with the priority of any of the mod files that are currently append files though patches.copy seems to do absolutely nothing, order of the code does not change.

#

That doesn't seem right

twin bluff
#

iirc priority isn;t implemented

grizzled tinsel
#

oh

twin bluff
#

oh its not in the readme

#

maybe it was

celest swallow
#

It's a comment in lovely source code iirc

#

either way, I just used prepend instead of priority to work around that

errant robin
#

that's dump_lua

celest swallow
#

yea I realised

clear oyster
clear oyster
solar pebble
#

heard, nice work

#

sorry for being quiet, I've been taking a break from personal projects due to medical reasons

solar pebble
#

however my opinion is very uneducated

grizzled tinsel
#

The times where you would want nested folders to still load lovely files is either 1: for multiple individual mods in one folder (e.x. Betmma Mods and Jen's Collection) and 2: to kinda get around incorrect downloads that result in the mod being nested.

#

The latter is never wanted and wouldn't be helped by file indication to check for if it's nested (because that file indicator would also be nested) and the former can just be done through expanding how deep lovely checks.

#

Definitely a good addition but requiring indication through .lovelynested file instead of just automatic is odd

solar pebble
solar pebble
storm zealot
#

Can lovely patch in dlls?

solar pebble
#

shouldn't be too hard

storm zealot
#

I’m trying to patch in a custom luasteam and steamapi.dll

twin bluff
#

i feel like you can probably just add a new module path to search for yours first

storm zealot
#

Haven’t been successful at that

celest swallow
celest swallow
#

¯_(ツ)_/¯

#

if you're wondering, .unique() to handle cases like

#

which seems to be working

clear oyster
#

The most recent merge to lovely injector kind of messes up some things

solar pebble
#

#70? It was working fine on my end

clear oyster
#

It uses libc to try to load in lua instead of libloading

#

And it disrupts the linux support PR that I was using (I was able to modify things to work around the changes)

clear oyster
#

As far as I can tell it behaves the same, just throws some wrenches into other changes

clear oyster
#

Just checking on this

sterile anvil
#

is there a way to patch localization without steamodded? targeting localization/[anything].lua does not seem to work

twin bluff
#

the way localization is laoded isn't caught by lovely

#

there was a pr recently that changed what it hooked, but I'm still not sure if that fixes it

#

you could probbaly patch whatever is loading the localizaion and load yours there

errant robin
#

same feature request as mine for being able to patch steamodded files (loc files are loaded w/ loadstring)

solar pebble
#

I've been smoke testing the latest commit and it seems to be performing 1:1. My big blocker rn is my SO's birthday and the Linux build pipeline.

#

Once those are done we can move forward with the release.

mystic oasis
#

link to current version?

clear oyster
#

Also, another prerelease version please?

solar pebble
#

mac is still borked, dang

clear oyster
#

😦

solar pebble
clear oyster
#

Did github change something in the mac machines at some point

solar pebble
#

the mac builds run on a linux container so likely nothing to do with that, but it could be some update on Github's end + odd interactions between the latest version of Rust and cargo-zigbuild

final void
#

wake up, new lovely version just dropped

#

i can finally see all the failed patches :D

solar pebble
#

alright, just ended up manually building the mac binaries. release is 100% live

#

a huge thanks goes to all of the huge brains that committed huge code to this release. ya'll are hugely great :-)

solar pebble
#

now lets see how broken everything is squirtle_evil

#

also dang, we've got 76k downloads on the repo right now. crazy stuff

solar pebble
#

oh my god

#

I forgot to bump cargo versions

grizzled tinsel
#

xdd

solar pebble
#

great time to remember too, I've got to head to bed. can everyone handle the binaries being the wrong version until tomorrow? pretty please?

#

nah nevermind

#

I need a Mac guineapig to test a build out rq

#

actually NO we're fine, the version on the release binaries SHOULD BE beta7

final void
#

I saw beta7 when I ran it

solar pebble
#

sweet. my past self has saved my current self

#

enjoy enjoy, let me know if anything is brokened

grizzled tinsel
#

Jist is the game loads but pressing play yeilds this.

twin bluff
#

oh also can confirm way more stuff is hookable

#

including the save files

#

(only if you know the entire contents of the file)

lusty arch
#

INFO - [G] 2024-09-16 22:17:35 :: ERROR :: StackTrace :: Oops! The game crashed
main.lua:39: attempt to concatenate field 'path' (a nil value)

After updating lovely injector to 0.50 beta 7, this error occurs.

twin bluff
#

send the full crash log

lusty arch
twin bluff
#

I belive this error is coming from cartomancer

lusty arch
celest swallow
#

seems to be because SMODS.MODS_DIR now returns full path even if it's default 😦 I guess I'm forced to use NFS now

twin bluff
#

if SMODS is there you can always assume NFS is theree

#

at least with 1.0

celest swallow
#

yes but any filesystem logic will quickly turn into spaghetti

#

if I do

if SMODS then
 //access file with NFS
else
 //access file with love filesystem
end```
#

everywhere

twin bluff
#

If you assume that lovely's mod path is always in the same spot, you could trim the /Mods from it and then use that to trim the beginning of real paths

#

actually just a sec

#

you can use love.filesystem.getRealDirectory("") to get the save path

#

oh wait theres a function for that

#

love.filesystem.getSaveDirectory()

celest swallow
#

I dont really understand why lovely isn't bundled with nfs tbh

#

even more so now that it always returns full path for mods folder

twin bluff
#

I thought it always returned the full path for mods folder

celest swallow
#

seems rather annoying to have same file in every mod

#

well, I tested with previous version, and SMODS.MODS_DIR is Mods

#

with beta7 it's full path

twin bluff
#

huh

#

I don't belive that lovely changed it's path at all

#

that might just be a SMODS change

celest swallow
#

man

#

I didn't change my steamodded version

twin bluff
#

huh

celest swallow
#

I have 2 version.dll in my folder

celest swallow
twin bluff
#

let me look at this

solar pebble
#

uhhh odd

twin bluff
#

I don't see a difference

#

actually thats odd

#

I'm looking at the code and it should trim it

#

I think

#

Think I found the issue

#

not sure what chnaged though

#

different types of slashes

#

so lovely is using backslash love is using forward slash

#

wait it's only using / for one path

#

oh wait smods patches the lovely one to use backslashes

#

not sure why the love one is not

#

no wait

#

@errant robin you wrote the function for handling paths originally, what is going on here?

#

why is is sometimes one way sometimes another?

celest swallow
#

ok I think I might see the issue

#

lemme double check tho

#

yeah SMODS.MODS_DIR apparently wasn't set in beta6

#

that's why it used Mods 😭

#

Idk wtf changed tho

#

oh is it because modules logic changed?

#

I remember something like modules are now loaded lazily

#

so my module was loaded before SMODS was ever initialized, that's why it never used mods_dir

errant robin
#

oh smh

solar pebble
#

can you advertise Lovely in your bio? thanks

#

I will not pay you anything to do so

twin bluff
#

I'm down

errant robin
#

I'm just asking for patches on loaded strings by chunk name in return

fierce whale
solar pebble
clear oyster
#

Every mod seems to be vendoring their own copy of NFS to load in

grizzled tinsel
#

It would be nice not having to do that.

twin bluff
#

tbh most mods don't need it for anything other than finding where there mod directory is and loading additional files

#

it would be nice if lovely at least told us where the patch(s) is located and also gave us the path for love.filesystem

#

although maybe lovely should just vendor some libs for common stuff

#

would also be nice for some stuff like https

#

maybe also some stuff that it already uses for itself like it's regex engine and toml parser

errant robin
#

also json maybe

#

seen it vendored by quite a few lovely mods

#
  • if we're gonna be moving to a json metadata file standard, I could see there being more use cases for wanting to read those
twin bluff
#

tbh even toml would probably be good enough for metadata files

#

oh btw @solar pebble do you have any idea why modules have their names as the file their targeting instead of the file that they are named after or their require name?

errant robin
twin bluff
#

toml is a standard for config files

errant robin
#

mod metadata isn't strictly a config file

twin bluff
#

technicall toml supports more types than json

errant robin
#

you're not wrong

#

I just think it should be reserved for patch files to reduce potential for confusion

twin bluff
#

nto sure how I missed that

mystic oasis
#

what them mean

twin bluff
#

it means that a lovely patch in JensAlmanaic is invalid

mystic oasis
#

ah

grave moss
mystic oasis
#

so no jensalmanac?

#

yall are too smart ;-;

grave moss
#

And he put 9,999,999,999

mystic oasis
#

why....

grave moss
#

I think that before that it doesn't affect

#

we will have to wait for him to fix it

mystic oasis
#

alright, have an amazing day both of yall

grave moss
#

You open the toml file, look for the priority number and change it to the one indicated by Jens and save

twin bluff
#

ok @solar pebble thoughts on thsi format for the source name of lovely modules =[lovely <require-name> "<filename>"]?

#

This is based off the Steamodded source =[SMODS <id> "<filename>"] which is in turn based off the love2d source =[love "<filename>"]

#

the = has special meaning as defined here

#

(like the @)

#

This makes it clear lovely added this in crashlogs (like so)

#

this is also easy for the crash handler to read the info from to display

solar pebble
#

Left a comment, otherwise looks good

twin bluff
#

ok fixed

solar pebble
#

merged, nice work

empty ore
#

"ERROR - [♥] lovely-injector has crashed:
panicked at crates\lovely-core\src\lib.rs:168:13:
The byte sequence at 0x2ce5dd28 is not a valid UTF-8 string: Utf8Error { valid_up_to: 49222, error_len: Some(1) }
ERROR - [♥] lovely-injector has crashed:
panicked at core\src\panicking.rs:221:5:
panic in a function that cannot unwind"
any advice on this?

solar pebble
#

what's your modlist?

solar pebble
grizzled tinsel
#

Yea

#

It seems to happen on a bunch of different button inputs

#

Someone else mentioned loading profiles

solar pebble
#

Should be as easy as making invalid UTF8 a non-fatal case. I'll poke around at it tomorrow.

mystic oasis
#

help pls

#

here is them lovely logs

#

i created a save without a problem, but when I press play it says that

#

@grave moss Amazing smart dude, do you have any idea of why this is happening?

#

sigmas? anybody have an idea of what is going on?

grave moss
mystic oasis
#

why u so smart ;-;

grave moss
#

its fixed?

mystic oasis
#

it be workign now

#

thanks so much my man

twin bluff
#

do we have a list of all the issues beta7 is causing somewhere?

twin bluff
#

I think thats it for new issues popping up with the new lovely build

#

other than the priority one

clear oyster
#

Hmm

twin bluff
#

idea print the lovely version in the console when started

#

or put it in the console title bar

#

oh wait it is printed out

#

I don't get the line printed to stdout though

#

but its in the logfile

twin bluff
#

Something odd is definitalty going on there

#

oh wait I had my diffs backwards

#

so it seems like we had some screwy indeting in the old version

#

this one seems odd

#

seems like its a bug in the steamodded version bundled with cryptid

#

in which case, it's probably not a concern

solar pebble
solar pebble
#

if anyone is getting the UTF-8 crash while using lovely beta7 PLEASE have them use this binary instead and screenshot the error message. #1225831216939536394 message

shell forge
#

has anyone gotten this to work on mac

solar pebble
#

Mac is a bit tricky but the instructions should still work fine

solar pebble
#

ptrace injection might work on andr**d when the game releases on the 26th

#

the current LD_PRELOAD technique won't work unless selinux disabled, which generally requires root.

#

are any of you guys experienced with android dev?

solar pebble
#

and then we can use setprop to set LD_PRELOAD

twin bluff
#

I also have familiarity with iOS twekas

left mulch
solar pebble
#

yep!

final void
#

nevertheless, if you're curious here is a mod folder of just the troubling steamodded version and lovely info

final void
#

@solar pebble finally got this error for myself!
it appears to be from loading a savefile with Ankh

This appears to be the UTF8 string in question : return {]"BLINK","LOVELY",[{"ID":"20","Time":"2019-04-28T23:25:17Z","Status","Open"

solar pebble
#

gotcha. it's weird because the text in bracker's screenshot is different: if not OmegaMeta then return {["GAME"]={["won"]=true,},} end ret

#

and that string is being passed as the chunk name, not as the chunk itself

#

there might be some weird memory corruption going on

final void
#

Ankh deals with decoding raw data when the crash happens, so it could be related to that

twin bluff
#

Side nkt it'd probably not useudk ever yo load unnamed chunks

#

Wonder if you could detect these and then just ignore then

final void
# solar pebble there might be some weird memory corruption going on

By the way I just released the version that had this issue so I can give you some steps to reproduce:

  1. Install Ankh v2.0.0-beta3 only.
  2. Start a new run and play it for a bit.
  3. Quit the game. When relaunching the game, press the play button.
  4. lovely-injector has crashed

idk if this will be consistent, it was for me across the first save I tested but maybe not for all

unique kraken
#

Do i need anything else? I don't see mods on the main screen

celest swallow
unique kraken
#

Than how do I know the mods are working?

celest swallow
#

by seeing functionality from the mods in game
lovely is just a tool that allows all mods to function

solar pebble
#

if I can repro. then I'll be able to walk back in a debugger and see where/how things are breaking

#

also we might be able to improve av detections by replacing the memory injector with a iat patcher

#

since there's no actual asm injection it may be less sus

#

I think my #1 focus right now is how/what mobile support is going to look like

clear oyster
#

IAT?

solar pebble
#

IAT = import address table. it's a lookup table in PE (win32 .exe) files that stores the addresses of functions in external modules

twin bluff
#

Idea make an empty file named smth like dont put mods in this folder for the lovely folder

solar pebble
#

good idea

#

I'm going to go ahead and replace the bad utf8 panic with a warn. patch targets should have valid chunk names so I feel like there's 0 use-case for implementing a proper fix

twin bluff
#

Yeah

#

Not only that but chances are it's just a raw buffer in that case and patching is pretty much useless cause we would need to know the entire buffer to patfh it at all

solar pebble
#

fix merged

#

ez pz

twin bluff
#

before making a release gimme a sec

#

print statements are printed in backwards order in lovely
print("1", "2") prints INFO - [G] 2[G] 1 and printing with a nil in it causes all to be nil print("1", nil) prints INFO - [G] nil[G] nil

solar pebble
#

gotcha, should be as simple as popping strings off the stack and printing them in reverse

#

or the other way around

twin bluff
#

yeah

#

not sure what is up with the nil though

cinder ruin
#

Hey all, I'm kinda new to this, but when I tried downloading Lovely, and ran the zip through virustotal, it showed like 30 things triggered, anyone know what I should do? (also popped up as malware on google)

twin bluff
#

it's a false positive

solar pebble
solar pebble
#

I'll check it out after work tomorrow

solar pebble
twin bluff
#

thoguh the [G] between items seems gone

proud arch
#

lol

solar pebble
#

and then some native function on lovely's end that returns a dict of name:path pairs

solar pebble
#

in the meantime I'll implement a template variable which inserts the path of the patch file

#

some {lovely:PATCH_PATH}

#

this is the most simple way to do things without getting into the "how do we determine what is a mod directory in a game-agnostic way" question

#

I do think that a proper implementation will require some sort of lovely manifest, maybe as a breaking change to lovely.toml files

#

the only real value imho is that it would make it easier to support non-balatro games.

deep raven
#

currently there's no need but in future if other games are added a general support server would be nice

twin bluff
#

Yeah I don't really see much need but if you do make one be sure to send me the invite

celest swallow
#

can there be an option to append raw text instead of a file with copy patch? or an alternative patch type that does it

twin bluff
#

actually was thinking of that

#

or even just a way for a pattern patch to match tbe beginning or end of the file

celest swallow
#

e.g. I want to have core functionality inside module, but then to call that module I have to create a one liner file just to require it

twin bluff
#

yeah me too

#

in my case I just match the first line of the file in question

twin bluff
solar pebble
#

got like 50% of the way there and then I got distracted

#

planning on having a PR up for it tonight

twin bluff
#

btw meth do you have thoguths on getting lovely to load patches from zip files?

#

idk how viable it is, but we can get smods to do it and it would help with managing mods

solar pebble
#

100% down

#

it's the more proper way to go about it

twin bluff
solar pebble
#

but I think we need to commit to an actual on-god for real package metadata format first

#

oh perfect'

#

I'll maintain support for both zips and dirs obviously

twin bluff
#

I wouldn't get rid of directory mods cause they are way easier to dev on but for users just dropping a zip would be so helpful

solar pebble
#

yeah, you can remove an install step ez pz

twin bluff
#

@errant robin since you are like the main smods dev figure you might want to follow this

solar pebble
#

but keep in mind that archives essentially make the mod immutable

twin bluff
#

yes

#

which aolso means we don't need to worry about config or other runtime created files when upgrading mods

#

which means its a simple as delete and replace

errant robin
#

mhm

#

well steamodded already moved config out of a mod's main dir

twin bluff
#

yeah

#

thoguh a few lovely mods still use it

errant robin
#

fair enough, though this would mostly break them

twin bluff
#

but we can't just leave old files around cause if somone for example moves from lovely.toml to a lovely dir and we leave the old lovely.toml then patchs break

#

yes but then we are breaking them in a obious way and not a oh your mod was updated so config is lost

#

lovely mods can still use the config folder even if smods doesn't exist

solar pebble
#

yeah, I'll even expose a directory as a static var for use

#

the big thing we need to figure out right now is metadata

twin bluff
#

using that api if the name is known, we can use love.filesystem to explore it

#

idk how exactly you will explore it from rust land

solar pebble
#

I can query the lua runtime for info if needed

twin bluff
solar pebble
#

agreed

errant robin
#

maybe that's inconsistent with having multiple patch files? idk

twin bluff
#

I think the lovely fodler doesn't have config

solar pebble
#

it's annoying because ideally we want lovely.toml to be purely package info

#

but I don't think it's insane to require a lovely.toml and make it possible to include patches

twin bluff
#

that makes sense

#

which metadata does lovely even need?

errant robin
#

i mean I'll make steamodded have some json file ideally with some fixed undecided name and surely it's best to have lovely metadata separate from that but it creates redundancy possibly

solar pebble
#

name, author, and version for now

#

the real big deal is that it would make extending that metadata way easier

solar pebble
#

but that's an edgecase now

twin bluff
#

oh meth I was thinking is there a possiblity for us to have a buffer loaded before a file is loaded mostly for side effects. Was thinking it wouid make the crash ahndler more reliable if it could be loaded seperatly than the main.lua for syntax errors

solar pebble
#

eg. the crash handler could get the patched buffer as text?