777MrEpic
|
  |
| Joined: 17 Oct 2012 |
| Total Posts: 3998 |
|
|
| 25 Jun 2013 08:51 PM |
But how do you make where instead of print you can make it like txt("Hi") My attempt: ____________________________ local metatable = { __index = {txt = "print"} } local run = setmetatable({}, metatable) txt("Hi") ____________________________ before telling me to leave, note this is part "advanced"
|
|
|
| Report Abuse |
|
|
|
| 25 Jun 2013 08:52 PM |
{txt = print} Set it to a function, not a string. And yes, this should go in SH, regardless of if they can help or not. |
|
|
| Report Abuse |
|
|
|
| 25 Jun 2013 08:52 PM |
You don't want metatables for that.
txt = print
There. |
|
|
| Report Abuse |
|
|
777MrEpic
|
  |
| Joined: 17 Oct 2012 |
| Total Posts: 3998 |
|
|
| 25 Jun 2013 08:53 PM |
>Set it to function How do you do that, I am about 5 Hrs new to metatables. Also, I was told if it had anything advanced, it is allowd. |
|
|
| Report Abuse |
|
|
|
| 25 Jun 2013 08:53 PM |
Oh, and you're setting the metatable for the env completely wrong. Just set local txt = print |
|
|
| Report Abuse |
|
|
777MrEpic
|
  |
| Joined: 17 Oct 2012 |
| Total Posts: 3998 |
|
|
| 25 Jun 2013 08:53 PM |
| @Ar I want it to be effiecent as possible for once. |
|
|
| Report Abuse |
|
|
|
| 25 Jun 2013 08:55 PM |
| ...That is the most efficient. Occam's Razor and all that. |
|
|
| Report Abuse |
|
|
RoAnt
|
  |
| Joined: 14 Jul 2008 |
| Total Posts: 16794 |
|
|
| 25 Jun 2013 09:41 PM |
"Also, I was told if it had anything advanced, it is allowd."
Who told you that? |
|
|
| Report Abuse |
|
|
Parthax
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 6941 |
|
|
| 25 Jun 2013 09:42 PM |
setfenv(1, {txt=print,print=txt}) possible loop, but I don't care as I typed this on a phone. |
|
|
| Report Abuse |
|
|
dekkonot
|
  |
| Joined: 22 Dec 2010 |
| Total Posts: 6685 |
|
|
| 25 Jun 2013 09:43 PM |
That's redundant, Parthax.
~ Non simpliciter Latinam legere ~ |
|
|
| Report Abuse |
|
|
Usering
|
  |
| Joined: 18 Aug 2012 |
| Total Posts: 10281 |
|
|
| 25 Jun 2013 10:36 PM |
| Well, judging by how long you've been scripting (4 months or so) and these types of scripts (http://www.roblox.com/777MrEpic-39-s-CodeBook-item?id=107934700), I don't think you should be learning this right now. It looks like you still have a long way to go. I didn't learn Metatables until December last year and I started last year in April. |
|
|
| Report Abuse |
|
|
NVI
|
  |
| Joined: 11 Jan 2009 |
| Total Posts: 4744 |
|
|
| 25 Jun 2013 11:01 PM |
^^^
Metatables are a simple concept and if you can't figure them out, you shouldn't be scripting at all. There's no set time frame for you to learn anything in Lua.
Metatables simply redefine how tables act. It doesn't require magic. |
|
|
| Report Abuse |
|
|
777MrEpic
|
  |
| Joined: 17 Oct 2012 |
| Total Posts: 3998 |
|
| |
|