rename file or open a file as the wrong type

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
TheLegoSensei
Prole
Posts: 8
Joined: Tue Feb 18, 2020 8:06 am

rename file or open a file as the wrong type

Post by TheLegoSensei »

So i'm making a little... something? where I can drop in song files meant for Clone Hero and Beat Saber, and it shows a list of the songs and I can play them like an MP3 player, gonna see if I can't do something with the note files and such. but I've got a small hiccup, in that Beat Saber's audio files are ".OGG" renamed into ".EGG". I can of course manually rename the files, but I plan to drop a whole bunch into here, and that would become tedious really fast. is there a command or set of commands that would allow me to rename the file, or open it as an .OGG, ignoring the given file extension? thanks! :awesome:
TheLegoSensei
Prole
Posts: 8
Joined: Tue Feb 18, 2020 8:06 am

Re: rename file or open a file as the wrong type

Post by TheLegoSensei »

here's how far I've gotten so far:

Code: Select all

renameFile = love.filesystem.read("Songs/" .. SongsDir[menuSelection] .. "/song.egg")
love.filesystem.write(menuSelection .. ".ogg", renameFile)
music = love.audio.newSource(love.filesystem.getSaveDirectory() .. "/" .. menuSelection .. ".ogg", "stream")
but it's not opening the file from the appdata folder. I even had it write the file directory to a .txt, and copied and pasted it into Chrome and it opened the file just fine, so I know for certain the directory is correct, plus the resulting file isn't corrupted in any way. why won't it open?
User avatar
zorg
Party member
Posts: 3468
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: rename file or open a file as the wrong type

Post by zorg »

Hi and welcome to the forums.

First it'd be nice to know what menuSelection and SongsDir[menuSelection] is, because you might be missing the SongsDir[ .. ] part from within newSource's parameter on the third line above.

That said, i think i remember that the current löve version actually tries to see if it can open a file with any decoder it can, so it shouldn't matter if the file extension is egg instead of ogg.

Finally, you don't pass absolute directories to any löve function, they only take the relative paths given by the internal virtual file system, so you'd do one of the following:

Code: Select all

music = love.audio.newSource(menuSelection .. ".egg", "stream")
-- or
music = love.audio.newSource(SongsDir[menuSelection] .. ".egg", "stream")
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
TheLegoSensei
Prole
Posts: 8
Joined: Tue Feb 18, 2020 8:06 am

Re: rename file or open a file as the wrong type

Post by TheLegoSensei »

right now when I tell it to play .egg it sounds like lasers
the lasers are really cool, but I don't think it was doing that before...
Last edited by TheLegoSensei on Sat Feb 22, 2020 6:48 am, edited 2 times in total.
TheLegoSensei
Prole
Posts: 8
Joined: Tue Feb 18, 2020 8:06 am

Re: rename file or open a file as the wrong type

Post by TheLegoSensei »

ah, now both .egg play, and sound like lasers (forgot to put math.floor() in several places)
TheLegoSensei
Prole
Posts: 8
Joined: Tue Feb 18, 2020 8:06 am

Re: rename file or open a file as the wrong type

Post by TheLegoSensei »

OH, I didn't understand what you were telling me, but now I get it

running "love.audio.newSource("song.ogg")" will search both the original zip folder directories as well as the appdata folder directories for the file in question, so I don't need to specify the appdata folder.

that took me a while :oops: thanks for your help!
Smit1h
Prole
Posts: 2
Joined: Tue Mar 03, 2020 10:07 am

Re: rename file or open a file as the wrong type

Post by Smit1h »

If you need to change the extension as well, select the entire file name and change it.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest