generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: _G Overriding functions

Previous Thread :: Next Thread 
PuzzleCrazy is not online. PuzzleCrazy
Joined: 01 Feb 2010
Total Posts: 1245
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
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
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
PuzzleCrazy is not online. PuzzleCrazy
Joined: 01 Feb 2010
Total Posts: 1245
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
PuzzleCrazy is not online. PuzzleCrazy
Joined: 01 Feb 2010
Total Posts: 1245
20 Oct 2012 04:35 PM
How would I override a function and then call it with _G?
Report Abuse
PuzzleCrazy is not online. PuzzleCrazy
Joined: 01 Feb 2010
Total Posts: 1245
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
PuzzleCrazy is not online. PuzzleCrazy
Joined: 01 Feb 2010
Total Posts: 1245
20 Oct 2012 04:55 PM
bump
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
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
PuzzleCrazy is not online. PuzzleCrazy
Joined: 01 Feb 2010
Total Posts: 1245
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
thecaptain97 is not online. thecaptain97
Joined: 17 Jun 2010
Total Posts: 4987
20 Oct 2012 05:26 PM
Say the Source is a StringValue and the Script runs the StringValue... then yes.
Report Abuse
rayoma is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image