PÄSSION: object-oriented LÖVE
Re: PÄSSION: object-oriented LÖVE
Passion is not gonna work with love 0.5.0?
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: PÄSSION: object-oriented LÖVE
Hi amshali,
I'm afraid that only 0.6 is supported.
I suppose you could try "transforming" the current example into 0.5 by doing the following:
In any case, you can use MiddleClass if you are just looking for object-orientation.
I'm afraid that only 0.6 is supported.
I suppose you could try "transforming" the current example into 0.5 by doing the following:
- Changing love.load, love.draw and love.update to just draw, load and update
- Changing "line" to love.draw_line
In any case, you can use MiddleClass if you are just looking for object-orientation.
When I write def I mean function.
Re: PÄSSION: object-oriented LÖVE
is the first example on http://love2d.org/wiki/index.php?title=MiddleClass broken? and can i just do require('passion/init.lua') instead of using just middle class to run it? im just trying to find an example that works so i can fiddle with it/learn it better thats all. (the avalanche one is a little bit too much to grasp at the moment - the text example on the page i linked to above seems easy enough to grasp. but i get errors when running it. - attenpt to index global 'B' (a nil value))
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: PÄSSION: object-oriented LÖVE
Try changing it to this: http://love2d.org/wiki/index.php?title= ... &oldid=939
Help us help you: attach a .love.
Re: PÄSSION: object-oriented LÖVE
still no good.there was another "B" left in there that i changed too, but it didn't help (i didn't change it on the wiki, as i didn't know if it was right or not). tried this in both 0.6.0 and 0.5.0
edit:
error is: attempt to index local 'self' (a nil value)
in function "speak"
edit:
error is: attempt to index local 'self' (a nil value)
in function "speak"
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: PÄSSION: object-oriented LÖVE
Oops.Pliskin09 wrote:still no good.there was another "B" left in there that i changed too,
http://love2d.org/wiki/index.php?title= ... &oldid=942Pliskin09 wrote:error is: attempt to index local 'self' (a nil value)
in function "speak"
Explanation: calling table1:func1() actually calls table1.func1(table1) (which was added to Lua specifically for OOP). That means, if you do p1.speak(), the argument self is nil, instead of p1.
Help us help you: attach a .love.
Re: PÄSSION: object-oriented LÖVE
got it working. except that the "constructor" for each "class" needs to be called "initialize", not "init". i've amended the wiki too.
http://love2d.org/wiki/index.php?title= ... &oldid=943
http://love2d.org/wiki/index.php?title= ... &oldid=943
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: PÄSSION: object-oriented LÖVE
Hi, sorry for not replaying - I've been out and without internet access.
My shame is only surpassed by my gratefulness. Thanks Robin & Pliskin09 for fixing my sample code - you guys are great.
My shame is only surpassed by my gratefulness. Thanks Robin & Pliskin09 for fixing my sample code - you guys are great.
When I write def I mean function.
Re: PÄSSION: object-oriented LÖVE
hey just another problem im having with the samples - see the mixins example? the hasWings module gives an error at '(' in function fly(). whats the correct way of doing this?
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: PÄSSION: object-oriented LÖVE
This is the problem:Pliskin09 wrote:hey just another problem im having with the samples - see the mixins example? the hasWings module gives an error at '(' in function fly(). whats the correct way of doing this?
Code: Select all
HasWings = { -- HasWings is a module, not a class. It can be "included" into classes
function fly()
print('flap flap flap I am a ' .. self.class.name)
end
}
Code: Select all
HasWings = { -- HasWings is a module, not a class. It can be "included" into classes
fly = function ()
print('flap flap flap I am a ' .. self.class.name)
end
}
Code: Select all
HasWings = {} -- HasWings is a module, not a class. It can be "included" into classes
function HasWings.fly()
print('flap flap flap I am a ' .. self.class.name)
end
I fixed it on the wiki as well.
EDIT: Word of advice: putting up examples on the wiki is good, but run them to check for mistakes first. An example that's wrong is worse than no example at all.
Help us help you: attach a .love.
Who is online
Users browsing this forum: Semrush [Bot] and 63 guests