|
| 16 Aug 2012 08:39 PM |
setmetatable({}, {__call = function(...) table.foreach({...}, function(_, var) assert(loadstring(string.dump(var))()); end); end;})(function() print("Fix me D:") end, function() print("Oh noes") end, (function() return (getfenv(0)['script'] ~= script); end)());
kk thanx |
|
|
| Report Abuse |
|
|
|
| 16 Aug 2012 08:42 PM |
setmetatable({}, {__call = function(...) table.foreach({...}, function(_, var) assert(loadstring(string.dump(var))()); end); end;}) (function() print("Fix me D:") end, function() print("Oh noes") end, (function() return (getfenv(0)['script'] ~= script); end)());
-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]- |
|
|
| Report Abuse |
|
|
|
| 16 Aug 2012 08:42 PM |
Derp, I hit the Post button instead of the Back button. Anyway, there's no point to it, you're setting the __call metamethod to a table without a name.
-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]- |
|
|
| Report Abuse |
|
|
|
| 16 Aug 2012 08:44 PM |
setmetatable returns the table it's being set to.
local myTable = setmetatable({}, {}); -- returns the first table given |
|
|
| Report Abuse |
|
|
|
| 16 Aug 2012 08:46 PM |
I know, but you never assigned any variables.
-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]- |
|
|
| Report Abuse |
|
|
|
| 16 Aug 2012 08:48 PM |
| Why would I need to in this case? It's not setmetatable that's wrong, it's how I'm using __call. |
|
|
| Report Abuse |
|
|
|
| 16 Aug 2012 08:52 PM |
| There's nothing wrong with the syntax by the way. |
|
|
| Report Abuse |
|
|
| |
|
mamaguy
|
  |
| Joined: 07 Oct 2010 |
| Total Posts: 7073 |
|
|
| 16 Aug 2012 08:58 PM |
| table.foreach is deprecated. |
|
|
| Report Abuse |
|
|
|
| 16 Aug 2012 08:58 PM |
Ohhhh, I see what you mean.... Still don't know what's wrong, but I get what you said before :D
-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]- |
|
|
| Report Abuse |
|
|
|
| 16 Aug 2012 08:59 PM |
Was foreach removed from Lua 5.2?
-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]- |
|
|
| Report Abuse |
|
|
mamaguy
|
  |
| Joined: 07 Oct 2010 |
| Total Posts: 7073 |
|
|
| 16 Aug 2012 09:00 PM |
Not sure, I'd heard of it before now, but never really understood it, so I went to the wiki and it says: "This item is deprecated; use the pairs() function instead!" Might not be removed from Lua 5.2 but it is from RBX.Lua :/ |
|
|
| Report Abuse |
|
|
|
| 16 Aug 2012 09:01 PM |
@mama No, deprecated means it's still usable, but there are better options. You can still use it in Roblox, but I don't think you can in Lua 5.2
-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]- |
|
|
| Report Abuse |
|
|
mamaguy
|
  |
| Joined: 07 Oct 2010 |
| Total Posts: 7073 |
|
|
| 16 Aug 2012 09:02 PM |
| Oh, I thought deprecated meant that they took it out o.O.. |
|
|
| Report Abuse |
|
|
|
| 16 Aug 2012 09:03 PM |
| It's usable in RBX.Lua (right now). I guess nobody knows how to fix it lol. |
|
|
| Report Abuse |
|
|
|
| 16 Aug 2012 09:06 PM |
Why do you have () after your last end?
-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]- |
|
|
| Report Abuse |
|
|
|
| 16 Aug 2012 09:16 PM |
It executes the function q.q
(function() print("Hi") end)()
would work the same as
function hi() print("Hi") end hi() |
|
|
| Report Abuse |
|
|
|
| 16 Aug 2012 09:22 PM |
Did not know that...
-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]- |
|
|
| Report Abuse |
|
|
|
| 16 Aug 2012 09:22 PM |
| You should learn Lua, I heard a game called ROBLOX uses it. |
|
|
| Report Abuse |
|
|
|
| 16 Aug 2012 09:26 PM |
Wow, I was about to thank you for teaching me these things, but then you go and make fun of me for not already knowing them.
-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]- |
|
|
| Report Abuse |
|
|
|
| 16 Aug 2012 09:44 PM |
> "Make fun of"
What's fun about this? |
|
|
| Report Abuse |
|
|
mew903
|
  |
| Joined: 03 Aug 2008 |
| Total Posts: 22071 |
|
| |
|
| |
|
| |
|