Re: Unnamed GUI library
Posted: Fri Jul 22, 2011 10:00 pm
Or just be careful about the double posting in the future.
Your Class.lua is a pile of WTFs. You might want to use an established class library, such as SECS, MiddleClass, HUMP.class, Slither.Trappingnoobs wrote:Can somone look at my code though, please?
I don't like them :-(Robin wrote:Your Class.lua is a pile of WTFs. You might want to use an established class library, such as SECS, MiddleClass, HUMP.class, Slither.Trappingnoobs wrote:Can somone look at my code though, please?
Yeah I'm not the best at explaining.Robin wrote:But that doesn't work at all. Only Test has a number as a key (I can't tell what type the value is, because it is a variable). The other one has 1 as value and "Egg" as key.
Also, that thing with string.dump and loadstring --- you shouldn't need that.
And you should use metatables. That's the only* way you can properly do object orientation in Lua.
* Not really the only way, but close enough.
Code: Select all
class LifeForm{
dead = false; --Default value of dead is false
name; --We don't set a default value
}
class Animal : LifeForm{
intelligent = false; --Animals aren't ''intelligent'' as such in general, so we default as false
}
class Dog : Animal{
someProperty;
}
Code: Select all
Class "Checkbox" {Properties}
Class "TextLabel" {Properties}
Class "CheckboxWithText" ({Properties}, {Checkbox, TextLabel})
Code: Select all
Event = {
connect = function(s,c)
table.insert(s.functions,c)
end
functions = {}
run = function(s)
for _,v in pairs(s.functions) do
v()
end
end
}
Code: Select all
Button:new("Button1")
Button:new("Button2")
Button1.Event:connect(function()
print("Hello from button1")
end)
Button2.Event:connect(function()
print("Hello from button2")
end)
Code: Select all
Button2.Event:run()
>Hello from button1
>Hello from button2