|
| 12 Nov 2014 06:31 AM |
Hello guys! I've been away for ~2 years. I've earned much coding experience and got into Lua coding by Garry's Mod. So i am trying to code on Roblox now but it is all different (No clientside,serverside and less functions)
Now how could i possibly include a script (game.workspace.TestScript) into the currently running script? I need this for making quick change for e.g. scripted blocks i want to change quickly.
Secondly i would like to know how to use functions from other scripts or make global functions.
Thanks! |
|
|
| Report Abuse |
|
|
|
| 12 Nov 2014 06:50 AM |
I've never used Garry's Mod, but Roblox lua has quite a few functions still. It still has client and server to worry about, and with FilteringEnabled on, you need to worry about client and server even more!
If you want to include a script into a running script, the preferred method is with ModuleScripts, which act as modules or libraries. http://wiki.roblox.com/index.php?title=Module_scripts
If both scripts need to run at the same time, you can use Bindable or Remote functions for sending data, or if you just need to share variables and don't want to call functions, you can use _G. http://wiki.roblox.com/index.php?title=Global_function
For example, _G.Hello = 2 Then that works in another script too. |
|
|
| Report Abuse |
|
|
|
| 12 Nov 2014 06:52 AM |
I tried similar, it is way different from gLua which would be _G["Hello"] = 2
I love that Roblox uses lua but i need a challange ;_; |
|
|
| Report Abuse |
|
|
|
| 12 Nov 2014 07:10 AM |
You can do _G["Hello"] = 2 as well.
With a table... local Table = { Hello = 5, ["Bye"] = 7 }
And then you can access either of them with Table["Hello"] or Table.Hello
and
Table["Bye"] or Table.Bye |
|
|
| Report Abuse |
|
|
|
| 12 Nov 2014 07:10 AM |
| I'm almost certain you can do that on GMod too, if GMod uses Lua. |
|
|
| Report Abuse |
|
|
|
| 12 Nov 2014 07:50 AM |
| Yeah you can, it is just a bit of a change because GLua is based 90% of functions which change variables and values and no direct change. |
|
|
| Report Abuse |
|
|