Yet another LoveJS Player

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
alexjgriffith
Prole
Posts: 31
Joined: Wed Jan 20, 2021 9:50 pm

Yet another LoveJS Player

Post by alexjgriffith »

I've been working on tools for interactive development in lovejs. Took a small detour this week to put together a little lovejs-player, with some of the extensions my development tools rely on (websockets, and interop with JS).

https://alexjgriffith.itch.io/lovejs-player

Like all other Emscripten ports of Love2D, this version relies on Lua5.1, rather than luajit. The core virtual machine used by luajit is written in assembly, meaning it can't be compiled to wasm to run in the web.

Feedback on the tool and extensions would be appreciated. Note that the API for the websockets and js library may change. Right now it's tied directly into love2ds event system, however rewriting them to be polled will make it easier to update LoveJS in the future.

Image
User avatar
dusoft
Party member
Posts: 765
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: Yet another LoveJS Player

Post by dusoft »

Nice and well documented!
SamR71
Prole
Posts: 3
Joined: Thu Mar 09, 2023 10:30 am

Re: Yet another LoveJS Player

Post by SamR71 »

Having trouble getting my .love working with the tool hosted on lovejs-player

Error:
Reading Uploaded .love file
index.html:325 File main.lua does not exist on disk.
index.html:325 Error: [love "boot.lua"]:330: Cannot load game at path '/home/web_user/love/game.love'.
index.html:325 Make sure a folder exists at the specified path.
index.html:325 stack traceback:
index.html:325 [love "boot.lua"]:352: in function <[love "boot.lua"]:348>
index.html:325 [C]: in function 'error'
index.html:325 [love "boot.lua"]:330: in function <[love "boot.lua"]:126>
index.html:325 [C]: ?
index.html:325 [love "boot.lua"]:1340074251: in function <[love "boot.lua"]:42>
index.html:325 [C]: in function 'xpcall'
index.html:325 [love "boot.lua"]:357: in function <[love "boot.lua"]:355>
index.html:325 [C]: in function 'xpcall'
User avatar
alexjgriffith
Prole
Posts: 31
Joined: Wed Jan 20, 2021 9:50 pm

Re: Yet another LoveJS Player

Post by alexjgriffith »

I've seen this error before with .love files that didn't have a main.lua in the top level. It could also happen if something in the .love file botched the b64 encoding.

Do you have a copy of the .love file you can share?
gianmichele
Citizen
Posts: 69
Joined: Tue Jan 14, 2014 11:03 pm

Re: Yet another LoveJS Player

Post by gianmichele »

I had the same issue. main.lua is definitely in the top level.
I'm using a mac with osx and I know it does like to hide some crappy stuff in the zip. Maybe that?
User avatar
alexjgriffith
Prole
Posts: 31
Joined: Wed Jan 20, 2021 9:50 pm

Re: Yet another LoveJS Player

Post by alexjgriffith »

Maybe? I tested it again on several games on linux and windows and I am not getting the main.lua is missing error.

If someone is running macos could they test using the following zip command to build their project and see if it still errors out?

The script just changes to whatever game-directory your project is in, finds all files, sorts them and zips them without any extra metadata. It saves the .love file one directory up to prevent you from accidentally recursively including it in your zip file.

Code: Select all

cd game-directory && find -type f | LC_ALL=C sort | env TZ=UTC zip -r -q -9 -X ../game.love -@
Alternatively, if any of your projects are available on a git host I can test the program with them.
User avatar
gingerbeardman
Prole
Posts: 19
Joined: Mon Sep 14, 2015 7:22 am
Location: United Kingdom
Contact:

Re: Yet another LoveJS Player

Post by gingerbeardman »

I'm also getting this error. I upload a game.love (zip with one main.lua file)

Your command needed some changes to work on macOS:

Code: Select all

cd project && find . -type f | LC_ALL=C sort | env TZ=UTC zip -r -q -9 -X ../game.love -@ ; cd ..
But even so, yeah, still the error.

I've had a similar error before, with 2dengine/love.js and it was to do with the mime types on my server. I never fully resolved it.

If you could provide a test file that works, I will package it up and confirm that I can get it to work, then we can drill in further to see if there's something about my specific main.lua file that is problematic?

even this fails for me

Code: Select all

function love.draw()
  love.graphics.print("Hello World!", 400, 300)
end
gianmichele
Citizen
Posts: 69
Joined: Tue Jan 14, 2014 11:03 pm

Re: Yet another LoveJS Player

Post by gianmichele »

If you want to have a look at the attached file, I'm having the same error.
It's generated on osx.
game.love
(8.47 KiB) Downloaded 48 times
User avatar
alexjgriffith
Prole
Posts: 31
Joined: Wed Jan 20, 2021 9:50 pm

Re: Yet another LoveJS Player

Post by alexjgriffith »

Just playing around with Macos now. It looks like all browsers have a unique issue loading .love files. an issue that is not present on windows or linux. It appears to be an underlying emscripten issue. I will look into a work around.
Dasryel
Prole
Posts: 1
Joined: Sat Mar 22, 2025 10:58 am

Re: Yet another LoveJS Player

Post by Dasryel »

This was by far the easiest and most efficient way to convert a LÖVE2D game to HTML. The documentation was clear, and the process was incredibly smooth. The tool is well-designed and deserves more recognition from the community and official support. Fantastic work, buddy!
Post Reply

Who is online

Users browsing this forum: Amazon [Bot] and 4 guests