Page 1 of 1
Anyone gonna help a newbie?
Posted: Wed Mar 23, 2011 12:45 am
by LuaWeaver
I have been in Lua for a while, but the love modules are still kinda making me scratch my head, but they are easy to learn. What's troubling me is 2 things: I've been observing other game's code to see how complex these games really are, and I noticed there are .lua extensions with code OUTSIDE main.lua. This is really confusing me. How do you use these? Are they subscripts that can be used as basically an organizer? Like to separate different bits so you can edit it more easily? How do you call on them from main.lua? And the other thing is, does anyone have any ideas? If you are the best scripter in the world but have no ideas, then you don't do anything. What's the point in that? I want an idea that wouldn't be too hard to tackle, or too easy. If you need an idea of what I'm capable of,I can do pretty good with syntax, can easily debug issues, but don't know much about love modules, but can check the wiki, but don't want to spend twice as much time on the wiki as on the project. Thanks in advance,
Re: Anyone gonna help a newbie?
Posted: Wed Mar 23, 2011 1:07 am
by Taehl
You don't have to use any files other than main.lua if you don't want to, but it can help keep things organized. I, personally, don't like my scripts getting much longer than two hundred lines - at that point, I group related things together and split it into two files. Additionally, if my game has distinct levels, I tend to put each level's data in its own file. Lastly, many of my projects have a file called helper.lua, which contains extra math functions and other little generic things.
Loading another script can be done in two main ways: Classic Lua style, using a line like require("script"); or with
love.filesystem.load. That makes the script execute, which usually creates functions and/or data which can be used by main.lua or yet another script.
As for ideas, it's widely maintained that Love needs a good platformer. Feel free to take on that challenge.
Re: Anyone gonna help a newbie?
Posted: Wed Mar 23, 2011 2:24 am
by tentus
Taehl wrote:
As for ideas, it's widely maintained that Love needs a good platformer. Feel free to take on that challenge.
I promise I'll get back to work eventually!
Re: Anyone gonna help a newbie?
Posted: Wed Mar 23, 2011 2:46 am
by sharpobject
As Taehl said, you can include external files like this
Code: Select all
-- in main.lua outside of any function
require("class")
require("queue")
require("globals")
or like this
Code: Select all
-- in main.lua
function love.load()
-- love.filesystem.load() returns a function that does the stuff in the file.
-- the "()" at the end of each of these lines is to call that function.
love.filesystem.load("class.lua")()
love.filesystem.load("queue.lua")()
love.filesystem.load("globals.lua")()
-- do other stuff to prepare your game.
end
I would love to see a good bullet hell game in Love.
Re: Anyone gonna help a newbie?
Posted: Wed Mar 23, 2011 7:11 am
by Robin
Note that you probably should use require(). (Less typing for one thing.
)
As for what you could do, why don't you try to implement, say, connect-4? It is not a huge project, but you will need to use a large part of the LÖVE API for it.
Re: Anyone gonna help a newbie?
Posted: Wed Mar 23, 2011 7:43 pm
by tentus
You could try to recreate Pentago, a fun little abstract strategy game. It'd get you nice and deep into game development concepts without forcing you to also to a bunch of graphic design.
Re: Anyone gonna help a newbie?
Posted: Wed Mar 23, 2011 8:06 pm
by leiradel
Robin wrote:Note that you probably should use require(). (Less typing for one thing.
)
Even less if you omit the parenthesis:
Code: Select all
require 'class' -- equals require( 'class' )
Re: Anyone gonna help a newbie?
Posted: Wed Mar 23, 2011 8:14 pm
by BlackBulletIV
leiradel wrote:Robin wrote:Note that you probably should use require(). (Less typing for one thing.
)
Even less if you omit the parenthesis:
Code: Select all
require 'class' -- equals require( 'class' )
Be careful with that, you can't do anything like this if you omit them:
Code: Select all
require 'something' .. somethingElse
That'll try to require 'something' and then try to concatenate what it returns with whatever's in somethingElse.
Re: Anyone gonna help a newbie?
Posted: Wed Mar 23, 2011 8:20 pm
by LuaWeaver
Thanks guys! You were a big help! I think I'll try the connect-4 idea...