EGS v2 - Screenshots! Redesign! (Easy GUI System)

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Unnamed GUI library

Post by Robin »

Or just be careful about the double posting in the future.
Help us help you: attach a .love.
User avatar
GijsB
Party member
Posts: 380
Joined: Wed Jul 20, 2011 10:19 pm
Location: Netherlands

Re: Unnamed GUI library

Post by GijsB »

Robin, we both come from roblox were it doesnt really mater if you double post, so, yeah... ._.
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: Unnamed GUI library

Post by vrld »

GijsB, this isn't roblox where it doesn't t really mater if you double so, yeah... ._.
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
Trappingnoobs
Citizen
Posts: 95
Joined: Tue Oct 12, 2010 8:52 pm

Re: Unnamed GUI library

Post by Trappingnoobs »

Can somone look at my code though, please? I'm not sure whether you've missed the post because it's a page forward.

Second-last post (I think, or third-last or fourth-last) on page 2, I attached a .love (reluctantly :P)

If you fix it, I'd be REALY gratefull, because it's hindering me and I have no idea in the slightest what's going wrong.
User avatar
GijsB
Party member
Posts: 380
Joined: Wed Jul 20, 2011 10:19 pm
Location: Netherlands

Re: Unnamed GUI library

Post by GijsB »

vrld,

sorry, but were not used to it that you can edit posts, and we keep forgetting that, so, yeah... ._.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Unnamed GUI library

Post by Robin »

Trappingnoobs wrote:Can somone look at my code though, please?
Your Class.lua is a pile of WTFs. You might want to use an established class library, such as SECS, MiddleClass, HUMP.class, Slither.
Help us help you: attach a .love.
User avatar
Trappingnoobs
Citizen
Posts: 95
Joined: Tue Oct 12, 2010 8:52 pm

Re: Unnamed GUI library

Post by Trappingnoobs »

Robin wrote:
Trappingnoobs wrote:Can somone look at my code though, please?
Your Class.lua is a pile of WTFs. You might want to use an established class library, such as SECS, MiddleClass, HUMP.class, Slither.
I don't like them :-(

Mine is made just as I'd expect it to. The bit where it asks if the key is a number is basically checking whether it has a default value. Such as this:

{Test, ["Egg"] = 1}

Test wouldn't have a default value; but 'Egg' has a default value of one. - That's the only thing I can see that'd make people wonder what on earth I was doing
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Unnamed GUI library

Post by Robin »

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.
Help us help you: attach a .love.
User avatar
Trappingnoobs
Citizen
Posts: 95
Joined: Tue Oct 12, 2010 8:52 pm

Re: Unnamed GUI library

Post by Trappingnoobs »

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.
Yeah I'm not the best at explaining.

Say I was programming in C#, and I wanted to make a Dog class, and I was planning in the future to do other classes, I'd do this:

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;
}
So my idea was to make that system in lua as best I could- I think I did a decent job, but the problem is that it doesn't work in certain conditions. It seems to not work with tables inside the class (Under some conditions).

So when you set the key as a string, it assumes it has a default value. If you just put in a value without a key, lua automatically assigns it the next empty number- And it knows it has no default value, so it just sets it to an empty string.

I'm not sure if I explained it well that time, either, but hopefully I did.

The point of the class system is that you can inherit from as many classes as you want- All the other systems I've looked at, including middleclass, only allow you to inherit from one, and are not structured like real implementations of OOP.

Basically this means you could do this:

Code: Select all

Class "Checkbox" {Properties}
Class "TextLabel" {Properties}
Class "CheckboxWithText" ({Properties}, {Checkbox, TextLabel})
And CheckboxWithText would get the properties from both TextLabel and Checkbox.

For some reason, though, they work FINE, APART from tables inside tables.

My event system, as you've probably seen is structured:

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
}
So you can add as many functions as you'd like.

However when two classes have this, they seem to 'share' the table 'Event' between them, so when you do something like this:

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)
And then the event is ran in ONLY ONE button, this happens:

Code: Select all

Button2.Event:run()
>Hello from button1
>Hello from button2
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Unnamed GUI library

Post by T-Bone »

Pics or it didn't happen :neko:
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests