Team Spartan Cookies & Milk Forums
getmetatable("Entity") and stragateUnstable - Printable Version

+- Team Spartan Cookies & Milk Forums (https://teamscm.co.uk)
+-- Forum: Garry's Mod (https://teamscm.co.uk/forum-4.html)
+--- Forum: Starfall (https://teamscm.co.uk/forum-7.html)
+--- Thread: getmetatable("Entity") and stragateUnstable (/thread-1439.html)



getmetatable("Entity") and stragateUnstable - Yuri6037 - 06-11-2015

Hey Person,

I have a few requests about Starfall. The first one would be about a function I found on the original stargate starfall lib on main CAP github : stargateUnstable. Is there any way you can add this function ? For example on my last screen I wanted to make the vortex gl.glCircle red instead of green when the vortex is unstable.

And for the second request well I'm not sure you can do that, what I'd like to have is a getmetatable("Entity"). So, you might ask me why ? And is it realy nessessary ?
Well to answer the first question, I plan on recreating the wire lib and interface because it's too complex to use. So I'd like to make a complete framework for Wiremod integration. However I plan on adding a new function to entities : GetWirelink(), the function is intended to return a special type of wirelink that will represent a framework's wirelink.

Also, it's not realy nessessary, but it would be cool look syntax... Yeah I know it's just to make more cool syntax.
This way I could make ent:GetWirelink():SetInt/SetBool/SetString/SetBin/SetNum/GetInt/GetBool/GetString/GetBin/GetNum
And I could also do ent:GetWirelink():SetOutputListener(OutputName, Callback).

All of that just because I begin to think the wire lib becomes a bit complicated.

Thanks by advance,
Yuri6037


RE: getmetatable("Entity") and stragateUnstable - Person8880 - 06-11-2015

(06-11-2015, 08:28 AM)Yuri6037 Wrote: Hey Person,

I have a few requests about Starfall. The first one would be about a function I found on the original stargate starfall lib on main CAP github : stargateUnstable. Is there any way you can add this function ? For example on my last screen I wanted to make the vortex gl.glCircle red instead of green when the vortex is unstable.
This has now been added as stargate.unstable( Gate ).

(06-11-2015, 08:28 AM)Yuri6037 Wrote: And for the second request well I'm not sure you can do that, what I'd like to have is a getmetatable("Entity"). So, you might ask me why ? And is it realy nessessary ?
Look up GetTypeDef.

(06-11-2015, 08:28 AM)Yuri6037 Wrote: Well to answer the first question, I plan on recreating the wire lib and interface because it's too complex to use.

...

This way I could make ent:GetWirelink():SetInt/SetBool/SetString/SetBin/SetNum/GetInt/GetBool/GetString/GetBin/GetNum
And I could also do ent:GetWirelink():SetOutputListener(OutputName, Callback).
How is the wire library complicated, and how is a dozen different methods for typed get/set better?

Compare what you want to this:
Wirelink.OutputName = OutputValue
local InputValue = Wirelink.Input
A user of the normal wirelinks has to remember only the input/output name, and how to read/write from a table.

Adding a dozen different typed set/get methods is wasteful and akin to this:
function AddStringToTable( Table, Key, String )
assert( type( String ) == "string" )
Table[ Key ] = String
end
function AddIntToTable( Table, Key, Int )
assert( type( Int ) == "number" )
Table[ Key ] = Int
end
-- and so on...
Do you see how silly that is?


RE: getmetatable("Entity") and stragateUnstable - Yuri6037 - 06-11-2015

(06-11-2015, 07:04 PM)Person8880 Wrote:
(06-11-2015, 08:28 AM)Yuri6037 Wrote: Hey Person,

I have a few requests about Starfall. The first one would be about a function I found on the original stargate starfall lib on main CAP github : stargateUnstable. Is there any way you can add this function ? For example on my last screen I wanted to make the vortex gl.glCircle red instead of green when the vortex is unstable.
This has now been added as stargate.unstable( Gate ).

(06-11-2015, 08:28 AM)Yuri6037 Wrote: And for the second request well I'm not sure you can do that, what I'd like to have is a getmetatable("Entity"). So, you might ask me why ? And is it realy nessessary ?
Look up GetTypeDef.

(06-11-2015, 08:28 AM)Yuri6037 Wrote: Well to answer the first question, I plan on recreating the wire lib and interface because it's too complex to use.

...

This way I could make ent:GetWirelink():SetInt/SetBool/SetString/SetBin/SetNum/GetInt/GetBool/GetString/GetBin/GetNum
And I could also do ent:GetWirelink():SetOutputListener(OutputName, Callback).
How is the wire library complicated, and how is a dozen different methods for typed get/set better?

Compare what you want to this:
Wirelink.OutputName = OutputValue
local InputValue = Wirelink.Input
A user of the normal wirelinks has to remember only the input/output name, and how to read/write from a table.

Adding a dozen different typed set/get methods is wasteful and akin to this:
function AddStringToTable( Table, Key, String )
assert( type( String ) == "string" )
Table[ Key ] = String
end
function AddIntToTable( Table, Key, Int )
assert( type( Int ) == "number" )
Table[ Key ] = Int
end
-- and so on...
Do you see how silly that is?

Well it's not as simple I tend on replacing many methods I'm using. All the wire stuff is hardcoded on lanai so I want to redirect to an external lib so things are more clear and more easy for me to understand if I need to read back my code.

The next big step is a large upgrade of how ScreenEngine works and I will surely add the gui support directly in the ScreenEngine. And I think I will add better windowing support to it using my recently upgraded gl lib now implementing a few new functions : glCircle(x, y, angle, radius, quality), glPushMatrix, glPopMatrix, glTranslate and finally glScale (which unfortunately works only on glVertex/glDraw functions)