inapt
|
  |
| Joined: 04 Oct 2008 |
| Total Posts: 11666 |
|
|
| 09 Nov 2014 11:17 PM |
screwing around with metatables
local meta = {__call = function() end} local lua = {storage = {}}
meta.__lt = function(self, set) if self ~= lua then local data = lua.storage[self] --get the data print(data) --> PRINTS 10 return data --> RETURNS TRUE???? end for i = 1, #set, 2 do lua.storage[set[i]] = set[i + 1] end return setmetatable(self, meta) end
setmetatable(lua, meta)
lua{ lua < {"x", 10} --set x to 10 }
local y = lua > "x" --get x print(y) --> PRINTS 'true' BUT x IS 10???
using < sets a value, using > gets a value......
in my __lt function where i get the data, i print it and then return it....
it prints 10, but returns true, wtf im tired and done >.>
what am i doing wrong
sorry if i explained this terribly im tired
-ForeverDev |
|
|
| Report Abuse |
|
|
inapt
|
  |
| Joined: 04 Oct 2008 |
| Total Posts: 11666 |
|
|
| 09 Nov 2014 11:18 PM |
can the __lt only return a boolean??????
-ForeverDev |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
inapt
|
  |
| Joined: 04 Oct 2008 |
| Total Posts: 11666 |
|
| |
|
|
| 10 Nov 2014 10:51 AM |
why not remove the __'s?
You can simply replace them with another variable, and that will make it less confusing.
Also any outputs? |
|
|
| Report Abuse |
|
|
inapt
|
  |
| Joined: 04 Oct 2008 |
| Total Posts: 11666 |
|
|
| 10 Nov 2014 02:52 PM |
its a metatable u froob
-ForeverDev |
|
|
| Report Abuse |
|
|
| |
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 10 Nov 2014 04:09 PM |
Says him, you froob. Hehe
I'm actually a yoghurt pot today |
|
|
| Report Abuse |
|
|
| |
|
| |
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
| |
|
|
| 10 Nov 2014 04:45 PM |
| I ain't everyone who says that is it himself :3 |
|
|
| Report Abuse |
|
|