Page 8 of 9
Re: ËNVY (LÖVE Framework)
Posted: Wed Feb 11, 2009 11:25 pm
by Merkoth
+1 to the ass part.
I'm currently writing a little game and decided to give ENVY a try, everything cool so far. The only thing I'd suggest is to also add a "blank" game to the distribution.
Re: ËNVY (LÖVE Framework)
Posted: Thu Feb 12, 2009 3:02 am
by mike
Merkoth wrote:The only thing I'd suggest is to also add a "blank" game to the distribution.
Good idea. Perhaps for the beginner looking into coding with Lua/LÖVE, ËNVY would be a great place to start if you added a barebones game that showed a few coding conventions and good ideas.
Re: ËNVY (LÖVE Framework)
Posted: Sun Feb 15, 2009 8:26 am
by Tad2020
Is it just me or is LÖVE not calling the metamethod __type? I'm having problems with ËNVY's vector class causing C STACK OVERFLOWS, I traced it down to the type calls returning "table" instead of "vector". I figured something might be wrong with my OOP module (using own, not ËNVY's), but tostring is fine and __type works when called directly.
Re: ËNVY (LÖVE Framework)
Posted: Sun Feb 15, 2009 12:26 pm
by Kaze
Tad2020 wrote:Is it just me or is LÖVE not calling the metamethod __type? I'm having problems with ËNVY's vector class causing C STACK OVERFLOWS, I traced it down to the type calls returning "table" instead of "vector". I figured something might be wrong with my OOP module (using own, not ËNVY's), but tostring is fine and __type works when called directly.
__type isn't part of standard Lua.
Re: ËNVY (LÖVE Framework)
Posted: Sun Feb 15, 2009 4:57 pm
by Tad2020
Kaze wrote:__type isn't part of standard Lua.
That's strange, I sworn that I've used it with the standalone Lua bin before, I guess my memory is mistaken. Time to override type() then
Re: ËNVY (LÖVE Framework)
Posted: Sun Feb 15, 2009 5:51 pm
by osuf oboys
I believe it would be better if you used a custom function for this. Some libraries for optimizations, serialization, copying, and the like may need to know whether your data is stored as a table or not.
Re: ËNVY (LÖVE Framework)
Posted: Mon Feb 16, 2009 3:49 am
by Tad2020
osuf oboys wrote:I believe it would be better if you used a custom function for this. Some libraries for optimizations, serialization, copying, and the like may need to know whether your data is stored as a table or not.
Yeah.... I think I put back a isinstanceof() function to my object system instead (or just check for x & y). That was a crazy idea, I stopped overriding things in Lua years ago.
Re: ËNVY (LÖVE Framework)
Posted: Thu Feb 19, 2009 1:25 pm
by Kuromeku
In ENVY's main.lua exists this:
Code: Select all
-- This is the worst thing since Garry Glitter.
local rawtype = type;
-- This is the worst thing since Garry Glitter.
type = function(variable)
local metatable = getmetatable(variable);
-- Check if the type is valid.
if (metatable and metatable.__type) then
return metatable.__type(variable);
else
return rawtype(variable);
end;
end;
Re: ËNVY (LÖVE Framework)
Posted: Thu Feb 19, 2009 11:32 pm
by Tad2020
Kudomiku wrote:Code: Select all
-- This is the worst thing since Garry Glitter.
I think his name is with one "r", Gary Glitter.
I just did metaclass.__vector = true since all I needed to know is if it is, or derived from, a vector. I had to rewrite most of that class anyway, I was getting "C Stack Overflow"s every time I used any of the metamethods.
Code: Select all
-- Called when a vector is added with another variable.
function vector:__add(a)
if type(a) == "number" then
return vector(self.x + a, self.y + a)
elseif a.__vector then
return vector(self.x + a.x, self.y + a.y)
end
end
I also added __le and __lt, it was missing those and they're very useful for checking in a point is in a quad.
Re: ËNVY (LÖVE Framework)
Posted: Fri Feb 20, 2009 10:48 pm
by Kuromeku
This is now licenced under LPCL.