nice made ma dude!! I see you it's a love2d compiled to a web edition. i never got it to work converting any of my love2d project to web so far with https://github.com/Davidobot/love.js. do you have any tutorial or tricks or can share how you do it, would be much appreciated ma dude.
Hey! Cool to see another love2d user. If you have any specific questions, I’d be happy to try to answer. Outside of that, I can paste my web build script below and you can ask me questions on it if you like, I don’t have any specific tips though.
Here’s the script: let me know if it’s helpful or not. You can tweak it as you see fit, hopefully the comments help: (It’s not the full script, I had to remove some stuff that doesn’t make sense to share, like I copy a bunch of custom JavaScript files into the final directory for stuff I didn’t use this game, so I removed that from the script.
Rem this line makes it so each line of code doesn't echo into the command window
@echo off
Rem This is the folder that contains all different build versions
Rem The builds folder is defined as "Builds". If it doesn't exist, this will create it.
set buildFolder=Builds
Rem This is the actual folder that you'd zip and distribute
echo Enter the name of this build :
set /p buildName=
echo %buildFolder%
echo %buildName%
if not exist %buildFolder% (
echo adding build folder %buildFolder%
mkdir %buildFolder%
)
if exist %buildFolder%\%buildName% (
echo old build folder already exists
echo removing old folder
rmdir /s /q %buildFolder%\%buildName%
)
mkdir %buildFolder%\%buildName%
echo zipping up all files into %buildName%.zip
"C:\Program Files\7-Zip\7z.exe" a %buildFolder%/%buildName%/%buildName%.zip "Engine" "Fonts" "Music" "Sounds" "src" "Textures" "ThirdParty" "conf.lua" "main.lua"
echo renaming zip file to love file
rename %buildFolder%\%buildName%\%buildName%.zip %buildName%.love
@REM https://love2d.org/forums/viewtopic.php?f=12&t=81736&start=160
@REM Need to pick a much bigger size for the game than what is reported by the zip file size
@REM for example, if the file size was 55426989 bytes, you should pick something like 70000000
@REM Otherwise you get a cryptic 'out of bounds' console error in JS
Rem compute the file size first
for %%I in ("%buildFolder%/%buildName%/%buildName%.love") do set numBytes=%%~zI
echo zip file size is %numBytes%
echo Using a value of 70000000 (7 with 7 zeros) for the bytes required to preload game on the web.
echo If you get cryptic failures, try changing this value in webbuild.bat to be much higher than the zip file size.
@REM If you get cryptic errors and it gets stuck at 1/2 when loading the game, try picking a much bigger value.
set numBytes=70000000
echo building with love.js
call npx love.js.cmd -c -m %numBytes% %buildFolder%/%buildName%/%buildName%.love %buildFolder%/%buildName%/%buildName%
echo removing stale love file
del /q %buildFolder%\%buildName%\%buildName%.love
echo creating a zip file for itch.io right under the build folder
cd %buildFolder%
cd %buildName%
"C:\Program Files\7-Zip\7z.exe" a %buildName%.zip "%buildName%\*"
cd ..
cd ..
echo finished build
i just tried out the script, modified it to my project structure. boi oh boi this is what i needed. this is the first time succeeding having a web edition of any of my projects working. Don't know how to thank you, this is so freaking great :)
Now I just have some errors when compiling it to web compared to standalone i need to have fixed. Etc one of the things in with generating a random numbers the arguments are switched from the web, but works on standalone, but thats managable :). Do you sometime face that some of your code works when its standalone and then needs modification to work when compiled as web?
Just really happy to have this working finally, since i believe the size of games im making don't really make sense that you need to download to play.. Again thanks ma dude ! You should share your script on a open github repo. I belive many could benefit from this !
i added the script to my github repo as well https://github.com/LazerLars/doveBlaster4000_love2d/blob/main/love_web_build.bat , i credited you in the script hope this is ok buddy, else let me know? "
@REM all credits goes to abhimonk
@REM script provided by https://itch.io/profile/abhimonk via comment @ https://itch.io/post/10552214 itch page: https://abhimonk.itch.io/ x page: https://x.com/abhisundu"
Glad to hear it worked out!
As for standalone vs web code: The main change I make is all my audio is loaded in “static” mode (including music) for the web, whereas in the downloadable version, the music is loaded in “stream” mode. Outside of that, I don’t think I have many other web-only changes.
I’ll definitely try to post some of this stuff to github, that’s a good idea!