ethangreen-dev / lovely-injector

A runtime lua injector for games built with LÖVE
MIT License
78 stars 11 forks source link

feat: linux support #66

Open vgskye opened 4 months ago

vgskye commented 4 months ago

changes lovely-mac to lovely-unix and modifies it to use LUA_LIB instead of dlopen()ing a new one. this alongside a straightforward path addition for LUA_LIB is sufficient to get linux support.

vgskye commented 4 months ago

(is draft because readme and release workflows need adjustments for obvious reasons and I'd like advice on what the best course of action will be on that)

ChromaPIE commented 4 months ago

hey! not sure how's this been going but is there any build for now to test things out?

ethangreen-dev commented 3 months ago

I'll need to expand the release pipeline, but don't worry about that, I'll take care of it once this PR is merged.

antipatico commented 3 months ago

Hi! I recently tried this on NixOS and I was able to make it work using a custom flake. Thanks @vgskye for the port! The only slight issue I occur is that since I am running love to start Balatro, lovely detects the name as love (which would be true for all love games run on Linux).

Here is some system information:

[!NOTE]
I am removing /nix/store paths and replacing them with HFS ones to make the reading easier to everybody. I do not think this problem is HFS related.

$ rustc --version
rustc 1.82.0-nightly (8b3870784 2024-08-07)
$ love --version
LOVE 11.5 (Mysterious Mysteries)

Repository status when built:

$ git log -n 1
commit a5ce6c5188ae71b3908fa3188e3a1b29c565fb65 (HEAD -> linux-support, origin/linux-support)
Author: Skye <me@skye.vg>
Date:   Sat Jul 20 18:18:21 2024 +0900

    feat: linux support

When I start Balatro from a directory containing the extracted game files, lovely detects the process name as love:

$ LD_PRELOAD=./target/release/liblovely.so love /usr/local/share/Balatro
INFO - [♥] Lovely 0.5.0-beta7
INFO - [♥] /usr/local/share/Balatro
INFO - [♥] Game directory is at "/usr/bin"
INFO - [♥] Writing logs to "/home/user/.config/love/Mods/lovely/log"
INFO - [♥] Using mod directory at "/home/user/.config/love/Mods"
INFO - [♥] Cleaning up dumps directory at "/home/user/.config/love/Mods/lovely/dump"
INFO - [♥] Initialization complete in 1ms
INFO - [♥] Applied 1 patch to 'game.lua'
INFO - [G] Hello world!

The same behaviors is shown if love is launched against Balatro.exe:

$  LD_PRELOAD=./target/release/liblovely.so love ./depots/2379781/14235838/Balatro.exe
INFO - [♥] Lovely 0.5.0-beta7
INFO - [♥] ./depots/2379781/14235838/Balatro.exe
INFO - [♥] Game directory is at "/usr/bin"
INFO - [♥] Writing logs to "/home/user/.config/love/Mods/lovely/log"
INFO - [♥] Using mod directory at "/home/user/.config/love/Mods"
INFO - [♥] Cleaning up dumps directory at "/home/user/.config/love/Mods/lovely/dump"
INFO - [♥] Initialization complete in 0ms
INFO - [♥] Applied 1 patch to 'game.lua'
INFO - [G] Hello world!

[!NOTE]
As it is possible to see from the output, in both cases lovely seem to be working by loading a sample test mod that in turns prints 'Hello world!'. Unfortunately, lovely was not able to detect the game name since love was the one used in both cases.

Do you think there is an easy way around this? An option would be the ability to specify the game name via CLI, or an environment variable. In that way, it would be possible to specify the game name in the wrapper script and skip the game recognition via command line heuristics.

Update: unzipping the latest Steammodded alpha 1.0.0 on the ~/.config/love/Mods folder results in what looks like a working Steammoded installation:

image

whitelje commented 2 months ago

I will update this to be properly formatted when I get a chance later tonight, but I only have a minute and I want to make sure this doesn't fall out of my head.

The workaround here is to "build" an executable version of the Balatro app. Essentially inside the steam dir you: cat /usr/bin/love/ Balatro.exe > Balatro; chmod +x Balatro and then run ./Balatro directly. Mods go in ~/.config/Balatro/Mods You'll also need to move your old settings directory from ~/.local/share/love to ~/.local/share/Balatro. You should also put symlinks to both liblovely.so and the Balatro executable in ~/.local/share/Balatro

I think this might be an issue in love.

antipatico commented 2 months ago

EDIT: I have no problem with the symlinks so far. Your hack works. I do not like it a lot because I need to apply the following patch in Linux no matter what if the user wants mods installed or not:

--- result/share/balatro/globals.lua    1970-01-01 01:00:01.000000000 +0100
+++ result/share/balatro/globals.lua    1970-01-01 01:00:01.000000000 +0100
@@ -56,6 +56,14 @@
         self.F_CRASH_REPORTS = false
     end

+    if love.system.getOS() == 'Linux' then
+        self.F_SAVE_TIMER = 5
+        self.F_DISCORD = true
+        self.F_ENGLISH_ONLY = false
+        self.F_CRASH_REPORTS = false
+        self.F_NO_ACHIEVEMENTS = true
+    end
+
     if love.system.getOS() == 'Nintendo Switch' then
         self.F_HIDE_BETA_LANGS = true
         self.F_BASIC_CREDITS = true

So basically what I am doing right now is: unzip, patch, zip, concat with love, create script / desktop to run the game. Thanks for the help!

ethangreen-dev commented 2 months ago

Hi @vgskye, update this branch and I'll give it a review.