Page 1 of 1

help with a continuous script

Posted: Mon Mar 02, 2009 6:14 pm
by hellfiresage
can you help with a piece of code please. its at . I want it so that the main menu will appear then you can click story and it will take you to the story menu. at the story menu i want to add a back button (which i have in the script) and when you hit it the program will take you back to the main menu. my problem is i don't know how to make the script be continuous. i was wondering if you could help me. i'm new at programming and was wondering if you could put in notes to explain what you are doing.
thank you,
also i will attach the game too. so you will see what i'm talking about i already have the back button drawn.

Re: help with a continuous script

Posted: Mon Mar 02, 2009 7:06 pm
by bartbes
I don't want to sound like some angry man, it's just that I've seen you ask for support everywhere, and in (almost) all cases someone else has to write the code for you. I'd suggest trying some tutorials first.

Re: help with a continuous script

Posted: Mon Mar 02, 2009 7:16 pm
by hellfiresage
well is there a tutorial for this?

Re: help with a continuous script

Posted: Tue Mar 03, 2009 12:37 am
by Neptar
You won't find a tutorial for everything. As every game is different. You need to patient, and learn about Lua and love. The only way you are going to do this is by going through ALL the tutorials one by one, only moving onto the next one when you understand what everything in the code does. That should help you greatly. Also it may help to come up with small ideas using some of the things you have learnt. Create something small, and just build on it adding things here and there. It may not be a great game, but it will be a great learning process, as you will actually be putting what you have learnt into practice.

People will give you help, but they won't write everything for you. I know you've had a go at doing the menu as you posted another thread on the same thing. Take some time out on the current game and work on developing your knowledge first.

Re: help with a continuous script

Posted: Tue Mar 03, 2009 1:51 am
by osgeld
Ok ill play liberal hippy douche, and spread some love (and maybe hug a bleeding tree, i said MAYBE!)

now im not really disagreeing with the others, but i also see that you are struggling, which is not good, not for you cause your going to get frustrated, and not for us because for all we know your going to change the entire universe with your awesome app (*citation needed)

there is a time in most scripters lives where they really really really want to do something with this interest but are totally lost and confused with whats going on, and until they grasp it, life will be hard (and their code useless)

but one day, it will snap into place and hit you like a ton of bricks, and from that point onward your not going to have much, if any trouble learning anything you want in any language (except maybe asm or brainfuck)... till then just keep at it and it will fall into place

ok so here is a basic script that should give you the idea of how to control love, in part to act like different scripts working together (such as a menu script or a game script)

Code: Select all

function load()	
	font =, 18) 
	state = "menu" -- our magic light switch

function keypressed(key)
	if key == love.key_space then
		if state == "menu" then
			state = "game"
		elseif state == "game" then
			state = "ending"
			state = "menu"

function draw()
	if state == "menu" then"welcome to the menu", 10, 100)
	elseif state == "game" then"welcome to the game", 10, 100)
	else"thanks for playing the game", 10, 100)

Re: help with a continuous script

Posted: Tue Mar 03, 2009 3:19 am
by Skofo
This is pretty much like your loading screen, minus the loading, plus buttons. You can check if your mouse is between the top left and bottom right coordinates of any buttons you have when you click, and if they are, go to the next screen.

EDIT: Also, tutorials are better to be learned from, not copied and pasted. If you actually type code out and try to understand why things work how they do, you'll be able to think critically about code and use combinations of the things you've learned from tutorials to create your own stuff from scratch. For example, if you looked at the code you used to go from the loading screen to the title screen, you could do something similar to go between the title screen and story menu. If you really don't know how you would go about making buttons, you should look at the source code of the GUI libraries out there or games which use buttons. Pretty much every LOVE game released right now is open source, and the beauty of open source is that you can rip into the code and learn from it. ^^

Good luck and have fun!