Re: [WIP]BeatFever Mania ~ osu! Engine reimplementation
Posted: Thu Mar 31, 2016 7:32 pm
Some guy on IRC wrote:don't give me credit
Some guy on IRC wrote:don't give me credit
Sulunia wrote:Does love even have a IRC? Where?
https://love2d.org/ wrote:Community: (...) There is also an IRC channel: #love@irc.oftc.net.
Code: Select all
local ffi = require('ffi')
ffi.cdef('int PHYSFS_mount(const char *newDir, const char *mountPoint, int appendToPath);')
local liblove = ffi.os == 'Windows' and ffi.load('love') or ffi.C
function love.filedropped(file)
local path = file:getFilename()
extractZip(true, path)
end
local lfs = love.filesystem
local function enu(folder, saveDir)
local filesTable = lfs.getDirectoryItems(folder)
if saveDir ~= "" and not lfs.isDirectory(saveDir) then lfs.createDirectory(saveDir) end
for i,v in ipairs(filesTable) do
local file = folder.."/"..v
local saveFile = saveDir.."/"..v
if saveDir == "" then saveFile = v end
if lfs.isDirectory(file) then
lfs.createDirectory(saveFile)
enu(file, saveFile)
else
lfs.write(saveFile, tostring(lfs.read(file)))
end
end
end
function extractZIP(tech, file, dir, delete)
local dir = dir or ""
local temp = tostring(love.math.random(1000, 2000))
if tech then
success = liblove.PHYSFS_mount(path, temp, false)
else
success = lfs.mount(file, temp)
end
if success then enu(temp, dir) end
lfs.unmount(file)
if delete then lfs.remove(file) end
end
Now that's handy. Allright, the next "release" here will have drag and drop to install and a revamped selection screen UI.Davidobot wrote:I'm not going to let down:The tech variable checks if the complex lovelib call is needed or not, it is meant to be true only if the file is to be extracted from drop.Code: Select all
local ffi = require('ffi') ffi.cdef('int PHYSFS_mount(const char *newDir, const char *mountPoint, int appendToPath);') local liblove = ffi.os == 'Windows' and ffi.load('love') or ffi.C function love.filedropped(file) local path = file:getFilename() extractZip(true, path) end local lfs = love.filesystem local function enu(folder, saveDir) local filesTable = lfs.getDirectoryItems(folder) if saveDir ~= "" and not lfs.isDirectory(saveDir) then lfs.createDirectory(saveDir) end for i,v in ipairs(filesTable) do local file = folder.."/"..v local saveFile = saveDir.."/"..v if saveDir == "" then saveFile = v end if lfs.isDirectory(file) then lfs.createDirectory(saveFile) enu(file, saveFile) else lfs.write(saveFile, tostring(lfs.read(file))) end end end function extractZIP(tech, file, dir, delete) local dir = dir or "" local temp = tostring(math.random(1000, 2000)) if tech then success = liblove.PHYSFS_mount(path, temp, false) else success = lfs.mount(file, temp) end if success then enu(temp, dir) end lfs.unmount(file) if delete then lfs.remove(file) end end
Not gonna run around, and will just say, use love.math.random instead, for various reasons, including the here important fact that it's actually seeded in love.run, unlike lua's math.random.Davidobot wrote:I'm not going to let down:Code: Select all
local temp = tostring(math.random(1000, 2000))
To be fair, that's just a stupid way to ensure that there are no folder overlaps? If that makes sense. Anyways, I switched it out. This code was written before love.math.random was introduced, so it was justifiable.zorg wrote:Not gonna run around, and will just say, use love.math.random instead, for various reasons, including the here important fact that it's actually seeded in love.run, unlike lua's math.random.Davidobot wrote:I'm not going to let down:Code: Select all
local temp = tostring(math.random(1000, 2000))
Oops.Davidobot wrote:Just want to let you know that https://github.com/danielpontello/beatfever is no longer a thing..