help with a continuous script

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
hellfiresage
Prole
Posts: 49
Joined: Tue Feb 10, 2009 6:07 pm

help with a continuous script

Post by hellfiresage »

can you help with a piece of code please. its at http://pastebin.com/fff8b105 . 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,
hellfiresage
also i will attach the game too. so you will see what i'm talking about i already have the back button drawn.
Attachments
elfwarsv0.1.0.zip
robin this one...
(297.83 KiB) Downloaded 174 times
2game.zip
thelinx download this one
(214.07 KiB) Downloaded 160 times
game.love
(192.02 KiB) Downloaded 177 times
Last edited by hellfiresage on Wed Mar 04, 2009 9:57 pm, edited 2 times in total.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: help with a continuous script

Post 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.
hellfiresage
Prole
Posts: 49
Joined: Tue Feb 10, 2009 6:07 pm

Re: help with a continuous script

Post by hellfiresage »

well is there a tutorial for this?
User avatar
Neptar
Prole
Posts: 20
Joined: Mon Feb 16, 2009 3:24 am
Location: England

Re: help with a continuous script

Post 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.
User avatar
osgeld
Party member
Posts: 303
Joined: Sun Nov 23, 2008 10:13 pm

Re: help with a continuous script

Post 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 = love.graphics.newFont(love.default_font, 18)
	love.graphics.setFont(font) 
	state = "menu" -- our magic light switch
end

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

function draw()
	if state == "menu" then
		love.graphics.draw("welcome to the menu", 10, 100)
	elseif state == "game" then
		love.graphics.draw("welcome to the game", 10, 100)
	else
		love.graphics.draw("thanks for playing the game", 10, 100)
	end
end
User avatar
Skofo
Party member
Posts: 146
Joined: Mon Dec 22, 2008 10:55 pm

Re: help with a continuous script

Post 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!
Working on: Viator
Need a 64-bit Debian package for LÖVE? Here it is!
Post Reply

Who is online

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