Search found 7 matches

by LastNameGames
Wed Mar 18, 2015 1:46 am
Forum: Support and Development
Topic: separating files causes unexpected nil values
Replies: 2
Views: 1710

Re: separating files causes unexpected nil values

Wow. I'm a little bit embarrassed that I missed that. Thanks very much for clearing up the confusion. It actually makes perfect sense, now.
by LastNameGames
Wed Mar 18, 2015 1:20 am
Forum: Support and Development
Topic: separating files causes unexpected nil values
Replies: 2
Views: 1710

separating files causes unexpected nil values

In an effort to clean up some of the code I've been writing recently in Löve, I separated my game into a couple of files. Unfortunately, I'm finding that my enemies now have their sprite_index field come up as nil, even though they're being very explicitly set. My code looks like this: Main.lua: req...
by LastNameGames
Wed Mar 18, 2015 1:11 am
Forum: Support and Development
Topic: using inheritance to compare (__lt) two different types
Replies: 7
Views: 3538

Re: using inheritance to compare (__lt) two different types

I'm not 100% sure I follow what you're saying. Are you suggesting that it would be easiest to just have a create_enemy() function that returns a table containing the fields and functions that an enemy has, instead of having a prototype table that enemies set their metatable to? If so, then when (if ...
by LastNameGames
Tue Mar 17, 2015 7:07 pm
Forum: Support and Development
Topic: using inheritance to compare (__lt) two different types
Replies: 7
Views: 3538

Re: using inheritance to compare (__lt) two different types

aaaaah, okay. I think I understand it, now. I kind of thought that a table's __index metamethod defaulted to itself, so I felt it was unnecessary to set. I probably could have just changed the skip list code like you said, but I hadn't read through it fully, and I also felt it would be worthwhile to...
by LastNameGames
Tue Mar 17, 2015 5:56 pm
Forum: Support and Development
Topic: using inheritance to compare (__lt) two different types
Replies: 7
Views: 3538

Re: using inheritance to compare (__lt) two different types

ah, okay. That worked, but now depth isn't being set by default. I have to set the depth values for both objects manually before I can call the function.

Shouldn't calling setmetatable(o,depth) set it so that an object of type o will look for undefined values in depth?
by LastNameGames
Tue Mar 17, 2015 4:09 pm
Forum: Support and Development
Topic: using inheritance to compare (__lt) two different types
Replies: 7
Views: 3538

using inheritance to compare (__lt) two different types

I've been exploring the skip list data structure to aid me in setting up a drawing order for objects, but I've realized that it may be difficult if I want to make a skip list containing multiple types of objects (like a player type and an enemy type), because Lua can't use relational operators on ob...
by LastNameGames
Tue Mar 10, 2015 8:10 pm
Forum: Support and Development
Topic: using minor logic in love.draw
Replies: 2
Views: 1222

using minor logic in love.draw

I know that it's frowned upon to do any math/logic in the love.draw loop, but I was wondering how far that convention goes. For example, I have the following code in my draw loop: if player.slice_anim > 0 then love.graphics.draw(spr_slice,player.slice_x,player.slice_y,player.slice_direction, 6-(play...