Page 2 of 9
Re: LÖVE 0.9.0 released
Posted: Sat Dec 14, 2013 2:34 am
by Clean3d
Thanks so much for this release! Can't wait to try it out. : D
If you won't tell anyone, Internet, I'll admit that I jumped up more than once while reading this summary and did a stupid little dance.
Re: LÖVE 0.9.0 released
Posted: Sat Dec 14, 2013 3:10 am
by Jasoco
Besides the Clipboard stuff, is there anything we can actually do with love.system? I mean, getting the OS could be useful, but what about the power supply or processor count ones? What can we do with this information?
Also, can we get some examples of some of the new stuff, like mesh's?
Re: LÖVE 0.9.0 released
Posted: Sat Dec 14, 2013 3:32 am
by slime
Jasoco wrote:what about the power supply or processor count ones? What can we do with this information?
Power supply info is mostly only useful for laptops right now, for example if you have a fullscreen game you might want to display a warning if the computer is on battery and about to run out of power.
The processor count function might be useful when using threads, to optimize the amount you have running in some situations.
Jasoco wrote:Also, can we get some examples of some of the new stuff, like mesh's?
Yeah, I'll make some examples sometime after I wake up tomorrow.
Re: LÖVE 0.9.0 released
Posted: Sat Dec 14, 2013 3:34 am
by Mermersk
Congratulations to everyone who has contributed! I'm very thankful for all the hard work that the Löve devs do to make Löve as awesome as it is. Can't wait to try out and learn some of the new features.
Re: LÖVE 0.9.0 released
Posted: Sat Dec 14, 2013 4:39 am
by conroy
Awesome news! I'm going to work on adding 0.9.0 support to StackMachine ASAP.
Re: LÖVE 0.9.0 released
Posted: Sat Dec 14, 2013 5:51 am
by Davidobot
Wow, I just casually missed this post...
Great job guys! Keep up the good work!
Re: LÖVE 0.9.0 released
Posted: Sat Dec 14, 2013 7:18 am
by Kyle
It's about time, slime!
Great work to everyone involved.
I'm glad I can finally stop getting made fun of for having outdated code!
Re: LÖVE 0.9.0 released
Posted: Sat Dec 14, 2013 7:30 am
by Karai17
URAH!
Congrats on the release! ~@u@~ <3
Re: LÖVE 0.9.0 released
Posted: Sat Dec 14, 2013 8:34 am
by Kasperelo
Finally!
Re: LÖVE 0.9.0 released
Posted: Sat Dec 14, 2013 8:39 am
by jack0088
Jasoco wrote:Besides the Clipboard stuff, is there anything we can actually do with love.system? I mean, getting the OS could be useful, but what about the power supply or processor count ones? What can we do with this information?
Also, can we get some examples of some of the new stuff, like mesh's?
You CAN get the OS filesystem. Here is one possible way of doing so:
(Only tested on OS X... but might run on Windows as well)
Code: Select all
-- Hack by jack0088
-- Get access to filesystem outside the love2d sandbox.
-- Known issues:
-- Not supported: Alias, dead Symlink
Filesystem = {}
function Filesystem.getDirectoryItems(dir, wanted_type, wanted_file, ram)
dir = tostring(dir) or os.getenv("HOME") --define entrypoint
dir = dir:gsub("\\?%s", "\\ "):gsub([[["']*]], "") --handle (already escaped) whitespaces!
if #dir > 1 and dir:sub(#dir) ~= "/" then dir = dir .. "/" end --end always with slash
local files = ram or {}
for file in io.popen("ls -F " .. dir):lines() do
if file ~= dir then
local file_indicator = file:sub(#file)
local file_type = Filesystem.type(file)
local file_name = file:sub(1, #file-1)
-- symlink
if file_indicator == "@" then
if (not wanted_file) or (wanted_file and wanted_file == file_name) then
for link in io.popen("readlink " .. dir .. file_name):lines() do
local link_parent_dir = link:match(".*/")
local pre = link_parent_dir:sub(1, 3)
if pre:find("%.%..") then
link_parent_dir = dir:sub(1, #dir-1):match(".*/") .. link_parent_dir:sub(4)
elseif not pre:find("/") then
link_parent_dir = dir .. link_parent_dir
end
Filesystem.getDirectoryItems(link_parent_dir, wanted_type, file_name, files)
end
end
else
if -- folder
((file_type == "folder") and (not wanted_type or wanted_type == "folder"))
or -- file
((file_type == "file") and (not wanted_type or wanted_type == "file"))
then
-- .exe and .app file
if (file_indicator == "*") or (file_type == "folder" and file:find(".app")) then file = file_name end
if not wanted_file or (wanted_file and file:find(wanted_file)) then
table.insert(files, dir .. file)
end
end
end
end
end
return files
end
function Filesystem.updated(sec)
if not Filesystem._tmr then
Filesystem._tmr = love.timer.getTime()
return true
end
local time = love.timer.getTime()
if time >= Filesystem._tmr + (sec or 1) then
Filesystem._tmr = nil
return true
end
return false
end
function Filesystem.type(file)
return file:sub(#file) == "/" and "folder" or "file"
end
Use:
Filesystem.getDirectoryItems(
[string dir, string type, string file])
(all parameters are optionally, therefor I wrote them inside [] )
Code: Select all
require "Filesystem"
function love.draw()
if Filesystem.updated(3) then --gets called every x seconds, in this case, each three sec.
files = Filesystem.getDirectoryItems("/", "folder") --lists (/update) all folders inside system's root
--do with files what ever you need... loop through them and display or whatever...
end
end
If you don't need to always have an updated filesystem you just can:
Code: Select all
function love.load()
files = Filesystem.getDirectoryItems() --lists all files of type "file" and "folder", inside the "/" root directory
end