Anyone gonna help a newbie?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
LuaWeaver
Party member
Posts: 183
Joined: Wed Mar 02, 2011 11:15 pm
Location: Ohio, USA

Anyone gonna help a newbie?

Post 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, :3
"your actions cause me to infer your ego is the size of three houses" -finley
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: Anyone gonna help a newbie?

Post 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.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Anyone gonna help a newbie?

Post 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! :death:
Kurosuke needs beta testers
User avatar
sharpobject
Prole
Posts: 44
Joined: Fri Mar 18, 2011 2:32 pm
Location: California

Re: Anyone gonna help a newbie?

Post 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.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Anyone gonna help a newbie?

Post 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.
Help us help you: attach a .love.
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Anyone gonna help a newbie?

Post 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.
Kurosuke needs beta testers
User avatar
leiradel
Party member
Posts: 184
Joined: Thu Mar 11, 2010 3:40 am
Location: Lisbon, Portugal

Re: Anyone gonna help a newbie?

Post 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' )
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Anyone gonna help a newbie?

Post 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.
LuaWeaver
Party member
Posts: 183
Joined: Wed Mar 02, 2011 11:15 pm
Location: Ohio, USA

Re: Anyone gonna help a newbie?

Post by LuaWeaver »

Thanks guys! You were a big help! I think I'll try the connect-4 idea...
"your actions cause me to infer your ego is the size of three houses" -finley
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 1 guest