Can't we use multiple love.update() ?

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.
User avatar
semihmasat
Prole
Posts: 27
Joined: Sun Mar 04, 2012 2:38 am

Can't we use multiple love.update() ?

Post by semihmasat »

Hey,

I have couple files in my project.
In my movement.lua file I have 1 love.update funtion.

And I need one in main.lua file. but it does't work.
What should I do ?

Thanks :D
You must pay for your crimes against the earth.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Can't we use multiple love.update() ?

Post by Nixola »

You should keep the one in main.lua and rename the one in movement.lua (like movement.update(dt)) and call it during love.update
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
semihmasat
Prole
Posts: 27
Joined: Sun Mar 04, 2012 2:38 am

Re: Can't we use multiple love.update() ?

Post by semihmasat »

This is the code like in my main.lua

Code: Select all

function love.update()
	require 'movement' --Chracter Movement and Skinning Module
	if love.keyboard.isDown("x") then
		text = "Öp Örli Teknonoji Demosu"
	else
		text = "v.0000000.0.00.001.a"
	end
end
in my movement.lua file, there is not only love.update funtion.

I changed it like

Code: Select all

function love.update()

	love.graphics.setBackgroundColor(255,255,255)
	medium = love.graphics.newFont(20)
	x = 10;
	y = 10;
	katsayi = 0.5;
to

Code: Select all

function movement.update()

	love.graphics.setBackgroundColor(255,255,255)
	medium = love.graphics.newFont(20)
	x = 10;
	y = 10;
	katsayi = 0.5;
it is not working :D
You must pay for your crimes against the earth.
User avatar
molul
Party member
Posts: 264
Joined: Sun Feb 05, 2012 6:51 pm
Location: Valencia, Spain
Contact:

Re: Can't we use multiple love.update() ?

Post by molul »

semihmasat wrote:it is not working :D
Not trying to be sarcastic or rude, but, why do you think it's not working?

(Hint: Are you calling the function movement.update() somewhere?)
User avatar
semihmasat
Prole
Posts: 27
Joined: Sun Mar 04, 2012 2:38 am

Re: Can't we use multiple love.update() ?

Post by semihmasat »

I am getting this error.

and no, I am not using movement.update() elsewhere.
Attachments
dsa.PNG
dsa.PNG (9.89 KiB) Viewed 8606 times
You must pay for your crimes against the earth.
User avatar
semihmasat
Prole
Posts: 27
Joined: Sun Mar 04, 2012 2:38 am

Re: Can't we use multiple love.update() ?

Post by semihmasat »

When I change the movement.update(dt) to love.update(dt) , codes on movement.lua's love.update started to work.But now main.lua codes.

I just have to move codes then.
You must pay for your crimes against the earth.
User avatar
molul
Party member
Posts: 264
Joined: Sun Feb 05, 2012 6:51 pm
Location: Valencia, Spain
Contact:

Re: Can't we use multiple love.update() ?

Post by molul »

It would have worked the same if you just called movement.update() from love.update() (that's what I was trying you to realize).

No offense, but you clearly need to learn more about programming and about Lua before starting a complex project like a videogame. If you have this kind of problems now, I highly doubt you'll finish a game. Or if you do, most likely you won't understand what your code is about. Please don't get this as an insult.
User avatar
semihmasat
Prole
Posts: 27
Joined: Sun Mar 04, 2012 2:38 am

Re: Can't we use multiple love.update() ?

Post by semihmasat »

you are right.

actually I am learning on this time actually. this is my test and learning project.
You must pay for your crimes against the earth.
User avatar
semihmasat
Prole
Posts: 27
Joined: Sun Mar 04, 2012 2:38 am

Re: Can't we use multiple love.update() ?

Post by semihmasat »

oh god : movement = {}
You must pay for your crimes against the earth.
User avatar
molul
Party member
Posts: 264
Joined: Sun Feb 05, 2012 6:51 pm
Location: Valencia, Spain
Contact:

Re: Can't we use multiple love.update() ?

Post by molul »

semihmasat wrote:you are right.

actually I am learning on this time actually. this is my test and learning project.
I've been there, and I'd like to save you the time I didn't save. I was stubborn and continued trying to program a game, but I wasn't watching the big picture, the high amount of knowledge and work a videogame may need (unless you're thinking of a Pong and you use HardonCollider).

My suggestion is: be patient. Keep on learning programming (you know, defining and calling a function is very very very BASIC stuff). Study the available Löve examples and tutorials. Read a book about Lua. Program stuff with different languages (not because I don't think Lua is good enough, but just to learn programming without sticking to a single language).

Imagine Löve was an instrument. You wouldn't expect to write a great song or play a great solo when you're just starting with it, right? Then you shouldn't expect to program a videogame if you don't know the basics :)
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 9 guests