1
LÖVE - 0.9.0 released!
Started by Kingdaro, Jul 02 2013 11:19 AM
56 replies to this topic
#41
Posted 15 December 2013 - 08:45 PM
I thought 'real' lua only had access to the current and subdirectories.
#42
Posted 15 December 2013 - 09:04 PM
"Real Lua" has access to everywhere and everything. Its io library is simply limited in that it can only directly read and write files and streams, and not do tasks like get directory lists, get the user directory and such. (You could probably accomplish these using hacky methods with io.popen, but still).
Edited by Kingdaro, 15 December 2013 - 09:05 PM.
#43
Posted 15 December 2013 - 09:21 PM
Just found out Love is programmed with .cpp files, what language is that?
Also, Engineer, if you have such a problem with it, change the source code and recompile
Also, Engineer, if you have such a problem with it, change the source code and recompile
#45
Posted 15 December 2013 - 09:27 PM
Find out where it changes the IO library, and find a way to take it out of the regular folder
#46
Posted 17 December 2013 - 01:38 AM
Death, on 15 December 2013 - 09:21 PM, said:
Just found out Love is programmed with .cpp files, what language is that?
Also, Engineer, if you have such a problem with it, change the source code and recompile />
Also, Engineer, if you have such a problem with it, change the source code and recompile />
#48
Posted 25 December 2013 - 11:01 PM
Or just get the .love, since .love files are literally renamed .zip files.
#49
Posted 08 January 2014 - 12:14 PM
Managed to persuade my head of computing to install Love on all the school computers.
#50
Posted 08 January 2014 - 12:54 PM
Now that this topic is bumped, a few questions about LÖVE:
1. Can you use local variables like this:
1. Can you use local variables like this:
local image local x local y function love.load() image = love.image.newImage("some-image.png") x = 10 y = 20 end function love. update(dt) x = x + 1--I realize that the dt isn't factored here. y = y + 1 end function love.draw() love.graphics.draw(image, x, y) endor do you have to do this:
function love.load() image = love.image.newImage("some-image.png") x = 10 y = 20 end function love. update(dt) x = x + 1--I realize that the dt isn't factored here. y = y + 1 end function love.draw() love.graphics.draw(image, x, y) end function love.quit() image = nil x = nil y = nil endAlso, is there anyway I can save outside of the boundaries of love.filesystem (I heard that the io library won't work like this.)? I have a level editor in my upcoming game and I'd like my users to easily be able to share levels, and submit them for inclusion into the official game.
Edited by awsmazinggenius, 08 January 2014 - 12:56 PM.
#51
Posted 09 January 2014 - 03:18 PM
LÖVE hasn't changed the way variables work with Lua. Local variables still are only accessable within the scope of a block, and globals anywhere. Both of those examples would work. With the second, setting them to nil is unnecessary because the variables are GC'd when the game closes. As for which is better, it's personal preference, as LuaJIT is fast enough for it to not really matter beyond that point.
In terms of interaction between scripts, other required scripts can only access global variables. Example:
LOVE's filesystem module can only save in a specific game directory, but the io library can indeed save outside of the filesystem directory; it can save anywhere you need. The only downside is that the io library can't list directories or a lot of operations something like LuaFileSystem could do. What you can do is use os.execute to open the game's map directory, so the user doesn't have to navigate to it manually. Of course, because the command differs from OS to OS, you'd need to check what the game is running on first using the system module:
In terms of interaction between scripts, other required scripts can only access global variables. Example:
--# test.lua foo = 5 local bar = 10 --# main.lua require "test" print(foo) --> 5 print(bar) --> nothing
awsmazinggenius, on 08 January 2014 - 12:54 PM, said:
Also, is there anyway I can save outside of the boundaries of love.filesystem (I heard that the io library won't work like this.)? I have a level editor in my upcoming game and I'd like my users to easily be able to share levels, and submit them for inclusion into the official game.
LOVE's filesystem module can only save in a specific game directory, but the io library can indeed save outside of the filesystem directory; it can save anywhere you need. The only downside is that the io library can't list directories or a lot of operations something like LuaFileSystem could do. What you can do is use os.execute to open the game's map directory, so the user doesn't have to navigate to it manually. Of course, because the command differs from OS to OS, you'd need to check what the game is running on first using the system module:
local mapdir = love.filesystem.getSaveDirectory() .. "/maps" if love.system.getOS() == "Windows" then os.execute('start "' .. mapdir .. '"') elseif love.system.getOS() == "Linux" then os.execute('xdg-open "' .. mapdir .. '"') elseif love.system.getOS() == "OS X" then --# etc end
Edited by Kingdaro, 09 January 2014 - 06:30 PM.
#52
Posted 09 January 2014 - 05:38 PM
I can see where you are going with that, bit one major problem: You overwrite the OS table with the love.system.getOS() then try to access it
#54
#55
#57
Posted 09 January 2014 - 06:58 PM
If the reason you put 'etc.' for the OS X terminal command is because you don't know what it is, it is just open <file/whatever else> with some optional flags about how to open the file. (eg must be opened in a certain application (for files), must be opened hidden, etc.)
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users