So I'm thinking about making a level editor for my current project.
The problem
I would preferably like to have it as a stand-alone application (it's own main-file basically) but still sharing the same code-base as the game itself.
I'm not sure how to approach this with Love2d so any advice/tips/tricks would be very much appreciated.
Suggestions
One way I was thinking of would perhaps be to have the main-file for the game and editor in their own sub-folders in the game-folder but as far as I've read it doesn't seem you can do "require" on paths that are higher up in the folder hierarchy.
Another way could be to have the editor in a completely separate folder and somehow load all the shared stuff from the games' directory.
Feel free to chime as well if you have similar concerns. Perhaps this thread could become a go-to-place for getting started with making editors in Love2d, particularly in regards of what's mentioned above.
Lugen wrote:So I'm thinking about making a level editor for my current project.
The problem
I would preferably like to have it as a stand-alone application (it's own main-file basically) but still sharing the same code-base as the game itself.
I'm not sure how to approach this with Love2d so any advice/tips/tricks would be very much appreciated.
Suggestions
One way I was thinking of would perhaps be to have the main-file for the game and editor in their own sub-folders in the game-folder but as far as I've read it doesn't seem you can do "require" on paths that are higher up in the folder hierarchy.
Another way could be to have the editor in a completely separate folder and somehow load all the shared stuff from the games' directory.
Feel free to chime as well if you have similar concerns. Perhaps this thread could become a go-to-place for getting started with making editors in Love2d, particularly in regards of what's mentioned above.
You can "share" files between directories hard- and symlinks: http://www.havetheknowhow.com/Creating- ... Links.html
whichever you can use depends on the hard-drive format and your OS, but generally both should work. A hardlink basically means that both names on the filesystem point to the same contents, a symlink is like a reference to another filename. Either should work fine with löve; just make sure that the original file is in the game's .love in case you use symlinks.
S0lll0s wrote:
You can "share" files between directories hard- and symlinks: http://www.havetheknowhow.com/Creating- ... Links.html
whichever you can use depends on the hard-drive format and your OS, but generally both should work. A hardlink basically means that both names on the filesystem point to the same contents, a symlink is like a reference to another filename. Either should work fine with löve; just make sure that the original file is in the game's .love in case you use symlinks.
Thanks for your reply. Interesting suggestion. Might be something I'll look into, particularly if one can hard-link entire folders.
How I did my level editor for my game was to have an object system which draws and handles all the buildings and objects in my maps that system is pretty much identical in my standalone map editor and my game. After I have created my maps in my map editor they get saved to a file with a table serializer and love.filesystem when I then load up my game it loads the map file.
jjmafiae wrote:How I did my level editor for my game was to have an object system which draws and handles all the buildings and objects in my maps that system is pretty much identical in my standalone map editor and my game. After I have created my maps in my map editor they get saved to a file with a table serializer and love.filesystem when I then load up my game it loads the map file.
Already got that covered. It's the file structure I'm mostly concerned about. So I assume you had your editor as its own project and simply duplicated whatever you needed from the game project folder?
Main file only chooses between running the game or the editor. You could even use a command-line switch for this (which would also work with .bat files, for example).
When, in the end, you want to distribute an .exe, you can simply change the main file to only load the game, then build your game.exe and then change it to only load the editor and build the editor.exe from it.
package.path = package.path .. ";../?.lua" -- add the parent directory to the list of include dirs
package.path = package.path .. ";../scripts/?.lua" -- add the scripts directory to the list of include dirs
require("common") -- this could be in the parent directory or the scripts directory.
jjmafiae wrote:How I did my level editor for my game was to have an object system which draws and handles all the buildings and objects in my maps that system is pretty much identical in my standalone map editor and my game. After I have created my maps in my map editor they get saved to a file with a table serializer and love.filesystem when I then load up my game it loads the map file.
Already got that covered. It's the file structure I'm mostly concerned about. So I assume you had your editor as its own project and simply duplicated whatever you needed from the game project folder?
Exactly, took some time. I spent around 6-10 hours total of development time on my map editor.
package.path = package.path .. ";../?.lua" -- add the parent directory to the list of include dirs
package.path = package.path .. ";../scripts/?.lua" -- add the scripts directory to the list of include dirs
require("common") -- this could be in the parent directory or the scripts directory.
Could you explain the syntax of the paths in your example. Does "?" mean that any file ending with ".lua" in that folder can be loaded?
Is the ";" an indicator to add to the package list rather than overwriting it?
Lugen wrote:
Could you explain the syntax of the paths in your example. Does "?" mean that any file ending with ".lua" in that folder can be loaded?
Is the ";" an indicator to add to the package list rather than overwriting it?
Thanks a bunch for your reply!
Yes and Yes, though I would never recommend this, since this only work with not packaged games.
Have you tried this solution:
Germanunkol wrote:Main file only chooses between running the game or the editor. You could even use a command-line switch for this (which would also work with .bat files, for example).
When, in the end, you want to distribute an .exe, you can simply change the main file to only load the game, then build your game.exe and then change it to only load the editor and build the editor.exe from it.
--This will be your main.lua file
local released = false --Set to true when you release your game
local editor = false --Set to true if you wanna force the editor mode
love.load = function (args)
for _, arg in ipairs(args) do
if arg == "-editor" and not released then
editor = true
end
end
if editor then
require "editor.lua" --Your editor "main.lua"
else
require "game.lua" --Your game "main.lua"
end
love.load(args)
end