Complete noob, help please?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
PloXyZeRO
Prole
Posts: 8
Joined: Thu Apr 05, 2012 2:47 am

Complete noob, help please?

Post by PloXyZeRO »

Hi! So I just got started with love. I'm sure I could find some of my answers if I searched enough, but I figured it would be easier to ask all of my questions in a thread.

1) Is there a console or output or anything? For example, if all I had was print("Hello world!"), where would it show up? Or do I always have to draw it to the screen to see the output? If you always have to draw it, could you somehow run two windows for love in one program, and basically use the secondary one for information that you print out?

2) How do I find out which button on a gamepad I'm pressing in love? Same with analog sticks and triggers? I tried to find which analog sticks were mapped to each number in love.joystick.getAxis I think (can't quite remember, sorry!), and manually went through all the numbers to figure out which number was assigned to what. I'm sure there's a better more efficient way to do that, I just don't know :P

3) Is there a wait/pause/sleep function? Pretty self explanatory, I just don't know if there is. For example, wait(15) or sleep(15) would pause for 15 seconds, then go to the next line of code. msleep(1000) would wait a thousand milliseconds, then go to the next line of code.

4) Any links to tutorials to get me started? I've tried looking at the wiki, but I'm a bit confused. Any help appreciated!

Thanks!

EDIT:
5) Also, could someone explain the whole "OBEY" thing in everyone's avatars? It seems to be a trend :P

DOUBLE EDIT:

6) Is it possible to find the length of pixels a sting of text is? That would be very helpful for centering text on the screen!
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: Complete noob, help please?

Post by Davidobot »

PloXyZeRO wrote:Hi! So I just got started with love. I'm sure I could find some of my answers if I searched enough, but I figured it would be easier to ask all of my questions in a thread.

1) Is there a console or output or anything? For example, if all I had was print("Hello world!"), where would it show up? Or do I always have to draw it to the screen to see the output? If you always have to draw it, could you somehow run two windows for love in one program, and basically use the secondary one for information that you print out?

2) How do I find out which button on a gamepad I'm pressing in love? Same with analog sticks and triggers? I tried to find which analog sticks were mapped to each number in love.joystick.getAxis I think (can't quite remember, sorry!), and manually went through all the numbers to figure out which number was assigned to what. I'm sure there's a better more efficient way to do that, I just don't know :P

3) Is there a wait/pause/sleep function? Pretty self explanatory, I just don't know if there is. For example, wait(15) or sleep(15) would pause for 15 seconds, then go to the next line of code. msleep(1000) would wait a thousand milliseconds, then go to the next line of code.

4) Any links to tutorials to get me started? I've tried looking at the wiki, but I'm a bit confused. Any help appreciated!

Thanks!

EDIT:
5) Also, could someone explain the whole "OBEY" thing in everyone's avatars? It seems to be a trend :P

DOUBLE EDIT:

6) Is it possible to find the length of pixels a sting of text is? That would be very helpful for centering text on the screen!
1)You can print stuff on the screen, but using that command it will print it out on the console prompt. Which can be enabled in conf.lua
4)http://www.youtube.com/watch?v=6ZBAxKoJ ... aGHWims%3D
5) There is nothing to get, just OBEY
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
PloXyZeRO
Prole
Posts: 8
Joined: Thu Apr 05, 2012 2:47 am

Re: Complete noob, help please?

Post by PloXyZeRO »

Thanks, I've tried printing stuff to the console before but it didn't work. I just tried in a love.draw() function though and it worked. It's something that I'll have to get used to haha

Also thanks for the tutorial!
Averice
Prole
Posts: 25
Joined: Thu Apr 05, 2012 5:20 pm

Re: Complete noob, help please?

Post by Averice »

The closest thing I've done with pixels of text ( It's not 100% ) is to string.len(myText)*fontSize
User avatar
Jasoco
Inner party member
Posts: 3728
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Complete noob, help please?

Post by Jasoco »

string.len is depreciated. Use # instead.

i.e. where before you used string.len(myvar) you now use #myvar. Simpler to remember. Simpler to type. The # operator also tells you how many rows are in a table too. It's versatile. mytable = { "Text", "Something", "More" } shows you #mytable => 3.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Complete noob, help please?

Post by bartbes »

PloXyZeRO wrote: 1) Is there a console or output or anything? For example, if all I had was print("Hello world!"), where would it show up? Or do I always have to draw it to the screen to see the output? If you always have to draw it, could you somehow run two windows for love in one program, and basically use the secondary one for information that you print out?
As mentioned before there's a console switch in boot.lua, or the --console argument to love.exe if you're on windows. If not, running it from the terminal will just work.
PloXyZeRO wrote: 2) How do I find out which button on a gamepad I'm pressing in love? Same with analog sticks and triggers? I tried to find which analog sticks were mapped to each number in love.joystick.getAxis I think (can't quite remember, sorry!), and manually went through all the numbers to figure out which number was assigned to what. I'm sure there's a better more efficient way to do that, I just don't know :P
Sadly, that's kind of hard, in windows the control panel can tell you, though. I did run into the same problem myself, recently, so I wrote this small (0.8.0) .love:
joy.love
0.8.0
(584 Bytes) Downloaded 142 times
PloXyZeRO wrote: 3) Is there a wait/pause/sleep function? Pretty self explanatory, I just don't know if there is. For example, wait(15) or sleep(15) would pause for 15 seconds, then go to the next line of code. msleep(1000) would wait a thousand milliseconds, then go to the next line of code.
Yes, love.timer.sleep, but it's not what you want to do, because it stops everything, nothing else will happen during that time, and your game will appear to hang. What you do want to do is count (or calculate) time passed since t0 (where t0 is the start of your timing), and when you're 15 seconds past t0, you can act.
PloXyZeRO wrote: 6) Is it possible to find the length of pixels a sting of text is? That would be very helpful for centering text on the screen!
Font:getWidth
However, you most likely want to center text, or similar, try love.graphics.printf instead.
PloXyZeRO
Prole
Posts: 8
Joined: Thu Apr 05, 2012 2:47 am

Re: Complete noob, help please?

Post by PloXyZeRO »

Very useful information! Now it'll be easier for me to get started, and I can probably figure more things out for myself now. Thank you, guys!
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 8 guests