Page 1 of 1
Complete noob, help please?
Posted: Fri Apr 06, 2012 6:09 am
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
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
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!
Re: Complete noob, help please?
Posted: Fri Apr 06, 2012 6:49 am
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
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
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
Re: Complete noob, help please?
Posted: Fri Apr 06, 2012 7:35 am
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!
Re: Complete noob, help please?
Posted: Fri Apr 06, 2012 8:13 am
by Averice
The closest thing I've done with pixels of text ( It's not 100% ) is to string.len(myText)*fontSize
Re: Complete noob, help please?
Posted: Fri Apr 06, 2012 8:46 am
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.
Re: Complete noob, help please?
Posted: Fri Apr 06, 2012 1:12 pm
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
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.
Re: Complete noob, help please?
Posted: Fri Apr 06, 2012 8:20 pm
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!