|
| 20 Oct 2012 04:13 PM |
How could I override the print function with _G so that anywhere I use the print function it does what I code it to do?
To add on to this question, so I do not have to make another thread, can global variables be accessed by LocalScripts? |
|
|
| Report Abuse |
|
|
|
| 20 Oct 2012 04:14 PM |
You have to explicitly call your function with the _G prefix now.
_G.print(stuff)
LocalScripts have their own _G table and scripts have their own _G table. |
|
|
| Report Abuse |
|
|
|
| 20 Oct 2012 04:19 PM |
So, if I wanted the global print function to kill a player when I call it, I could use this code to define it:
_G.print(game.Workspace.Player.Head:remove())
And this code to use it:
_G.print()
? |
|
|
| Report Abuse |
|
|
|
| 20 Oct 2012 04:35 PM |
| How would I override a function and then call it with _G? |
|
|
| Report Abuse |
|
|
|
| 20 Oct 2012 04:42 PM |
| Is it possible to make the print function act differently in all scripts (overriding it) without using _G, or at least without using _G to call it? |
|
|
| Report Abuse |
|
|
| |
|
|
| 20 Oct 2012 05:00 PM |
Is it possible to make the print function act differently in all scripts (overriding it) without using _G, or at least without using _G to call it?
No. |
|
|
| Report Abuse |
|
|
|
| 20 Oct 2012 05:08 PM |
Okay, then answer me this:
Is there any way at all to change a script's source? |
|
|
| Report Abuse |
|
|
|
| 20 Oct 2012 05:26 PM |
| Say the Source is a StringValue and the Script runs the StringValue... then yes. |
|
|
| Report Abuse |
|
|
rayoma
|
  |
| Joined: 13 Nov 2009 |
| Total Posts: 1911 |
|
|
| 20 Oct 2012 05:29 PM |
script.Source will change the scripts source but what I think you're looking for is this :
http://wiki.roblox.com/index.php/Setfenv#setfenv |
|
|
| Report Abuse |
|
|