eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 18 Jun 2015 06:30 PM |
Wrappers are the joy of my life, and I think that the logic behind them is important because as they develop you will learn new things and begin to experiment with different architechtures.
I basically want everyone to write their own wrapper, and I will help people write wrappers and fix their wrappers. I want people to do it because I want to know that mine is the best. -I mean, I want to see how people make wrappers so I can be proud with everyone
When you make this wrapper it should be seamless and working that is the only important bit I figured that was important.
Enjoy, may the best wrapper eat all of the others ^^
|
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 18 Jun 2015 06:32 PM |
How many times have you said 'wrap' or 'wrapper' in the past 2 months? c: Anyway wrappers are a fun project so 10/10 |
|
|
| Report Abuse |
|
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 18 Jun 2015 06:34 PM |
local W = coroutine.wrap(function() print'Lul I made a wrappr :3' end) W() |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 18 Jun 2015 06:35 PM |
Basic rundown of wrapper behaviour for people who aren't sure:
When a value is wrapped, you have to store the real value somewhere so that you can unwrap your wrapper. This is important. The behaviour of the wrapped value depends on the datatype you are wrapping Functions wrap as a new function, which takes variable arguments and calls the original function wih unwrapped versions of the arguments, and wraps the returns. Tables wrap as new copies of the old table, with all the keys and values wrapped. It should proxy all of the metamethods appropriately. Userdata just has to proxy the metamethods so that's easy.
Unwrapping is simple, because it just involves grabbing that real value you stored earlier and returning that.
If you're not using wrap/unwrap and are using bidirectional conversion then good luck because I'm not explaining that. |
|
|
| Report Abuse |
|
|
radar001
|
  |
| Joined: 04 Sep 2011 |
| Total Posts: 718 |
|
|
| 18 Jun 2015 06:35 PM |
| But I'm to lazy to metatable my a** off.... |
|
|
| Report Abuse |
|
|
ash877
|
  |
| Joined: 18 Feb 2008 |
| Total Posts: 5142 |
|
|
| 18 Jun 2015 06:36 PM |
| may have seen dis in c++ tut c: maybe not. was watchin' a vid. |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 18 Jun 2015 06:41 PM |
You may have.
Please do write your wrappers and submit them all here so that other people can note what is wrong, get ideas for their own, and generally improve everything together. Alternatively, keep them to yourself but do say that you have written a wrapper and how well it is going so that I may be proud of you. |
|
|
| Report Abuse |
|
|
radar001
|
  |
| Joined: 04 Sep 2011 |
| Total Posts: 718 |
|
|
| 18 Jun 2015 06:43 PM |
| I'm still confused. Is a wrapper a metatable, a coroutine, a subroutine, or some combination of all three? |
|
|
| Report Abuse |
|
|
|
| 18 Jun 2015 06:44 PM |
all that did was confuse me
I found this code that I like but I don't know what useful stuff I could do with it function Wrap(object, tab, lock)
local new = setmetatable(tab, {__index = object})
local proxy = newproxy(true) local mt = getmetatable(proxy) mt.__index = new mt.__newindex = function(t,i,v) if new[i] then new[i] = v else error(v.." is not a valid member of "..i) end end if lock then mt.__metatable = "Locked, noobs" end
return proxy end |
|
|
| Report Abuse |
|
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 18 Jun 2015 06:45 PM |
Oh it is a metatable, no way in heck am I touching that bsns.
MetaTables are a cancer to lua
<3 |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 18 Jun 2015 06:49 PM |
It's not a metatable, don't be silly you banana monkey.
It's something that sits ontop of an object and emulates/proxies/integrates behaviour by redirecting and manipulating arguments and returns and invokations of behaviours. |
|
|
| Report Abuse |
|
|
radar001
|
  |
| Joined: 04 Sep 2011 |
| Total Posts: 718 |
|
| |
|
radar001
|
  |
| Joined: 04 Sep 2011 |
| Total Posts: 718 |
|
|
| 18 Jun 2015 06:50 PM |
| @eLun so its like a grouping of pointers? |
|
|
| Report Abuse |
|
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 18 Jun 2015 06:51 PM |
@eL, Even my dumbo grammar is comprehensible, right now you are going college graduate on me, please lower it to pre-school education.
lyk3 srsl'eh m8(), w0t maiks u fink u k4n b stup3d lyke dat? |
|
|
| Report Abuse |
|
|
| |
|
radar001
|
  |
| Joined: 04 Sep 2011 |
| Total Posts: 718 |
|
|
| 18 Jun 2015 06:55 PM |
| @mycheeze I would have to agree, my comprehension just flew out the window |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 18 Jun 2015 06:55 PM |
It's not a challenge, it's a project that I want everyone to take on for the greater good.
Basically, it lets you do stuff like
for _,Player in game.Players do Player:Kill() end
Which is very handy. It also let you do other stuff too, but that's when you get to the advanced uses and wrappers really start to shine. |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 18 Jun 2015 06:55 PM |
I legit have no idea how to make a wrapper, or really what it does / how I can use it.
Could you provide a basic example? |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 18 Jun 2015 06:57 PM |
| If you want a basic example I have a really basic buggy-as-ever wrapper in my models as Better Everything, or my old Valkyrie wrapper architecture on my c9 |
|
|
| Report Abuse |
|
|
|
| 18 Jun 2015 06:58 PM |
| So, I'd probably want to store the children within the actual table reference and the properties to be discovered through __index? |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 18 Jun 2015 07:00 PM |
| Up to you. If you compare Better Everything and the old Valkyrie wrapper, you'll realise that they had very different ways of handling it all. |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 18 Jun 2015 07:09 PM |
I think that once one of you has a basic wrapper going, other people will start to study it and chip in with new ideas, and I can help occasionally, and people can say problems and fix problems And then people will start extending it, so that it can have all kinds of sweet stuff to do with changing behaviour and people will start getting creative with what they can do and the behaviours they can make. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 18 Jun 2015 07:11 PM |
function wrap() print("i wrapped ur sister last night OOOOOOOO") end |
|
|
| Report Abuse |
|
|
|
| 18 Jun 2015 07:11 PM |
Eh. Here's a simple little thing I made for one of my GUIs.
http://pastebin.com/iN9NAK2N |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 18 Jun 2015 07:14 PM |
| That's more like just creating an Object really. It is wrapping, kind of, but not really what I'm getting at |
|
|
| Report Abuse |
|
|