IoIiderp
|
  |
| Joined: 05 Feb 2012 |
| Total Posts: 8613 |
|
|
| 24 Mar 2015 08:10 PM |
So for example if we make a function:
function printIns(ins) print(ins:GetFullName()) end
How can you make it you could do: game.Workspace.BasePlate:printIns() ? |
|
|
| Report Abuse |
|
|
CrowClaws
|
  |
| Joined: 04 Jul 2010 |
| Total Posts: 4466 |
|
| |
|
IoIiderp
|
  |
| Joined: 05 Feb 2012 |
| Total Posts: 8613 |
|
| |
|
|
| 24 Mar 2015 09:32 PM |
local function changenumber(num) return num+10 end
print(changenumber(5)) -- 15 |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2015 10:54 PM |
You would need to sandbox the actual code(a more complicated process i don't even fully understand), so you should just stick with
printIns(game.Workspace.BasePlate)
--Siggeh: "asd" - MakerModelLua |
|
|
| Report Abuse |
|
|
Tuneable
|
  |
| Joined: 16 Feb 2013 |
| Total Posts: 2932 |
|
|
| 24 Mar 2015 10:55 PM |
yeah you gotta do some nasty stuff to achieve that effect
since the whole game hierarchy is just a giant table I would try using metatables |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 24 Mar 2015 10:56 PM |
| Yeah creating a proxy for all instances just to add custom methods is inefficient and also longer than just doing what MML said |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 24 Mar 2015 11:42 PM |
function obj(o) return { printIns = function() print(o:GetFullName()) end } end
Usage; obj(workspace.BasePlate:printIns())
|
|
|
| Report Abuse |
|
|
LucasLua
|
  |
| Joined: 18 Jun 2008 |
| Total Posts: 7386 |
|
|
| 25 Mar 2015 12:34 AM |
@Goulstem
Usage:
obj(workspace.BasePlate):printIns();
fixed it ;3 |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
| |
|
IoIiderp
|
  |
| Joined: 05 Feb 2012 |
| Total Posts: 8613 |
|
|
| 25 Mar 2015 07:07 AM |
| So I gotta do the haxy stuff? Alright lets get into it :D |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 25 Mar 2015 09:57 AM |
here is something small but it works fine
local proxify = function(instance) local gf = newproxy(true); local jb = setmetatable({x=5, y=function(self)print(self.x, self.Name);end;}, {__index=instance}); getmetatable(gf).__index = jb; return gf; end;
local x = proxify(workspace.BasePlate); print(x.BrickColor); x:y(); |
|
|
| Report Abuse |
|
|
IoIiderp
|
  |
| Joined: 05 Feb 2012 |
| Total Posts: 8613 |
|
|
| 25 Mar 2015 09:59 AM |
| newproxy makes a virtual table that doesn't exist? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 25 Mar 2015 02:04 PM |
| No, its not a table but userdata and does exist. |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2015 02:06 PM |
| Frankly, I don't care how inefficient changing the environment is. It's fun and totally worth the 500 lines for a decent one. |
|
|
| Report Abuse |
|
|