Language: 
To browser these website, it's necessary to store cookies on your computer.
The cookies contain no personal information, they are required for program control.
  the storage of cookies while browsing this website, on Login and Register.

Author Topic:  script context  (Read 137 times)

0 Members and 1 Guest are viewing this topic.

Dolfo

« on: 21, October 2024, 06:25:19 »
I still try to understand where the advantages of script context is. For me looks like another unnessary coding layer, making things only more complicated. For sure we load the full scripts always via lua require().

I found the information that:

Lua require() uses a table called package.loaders to store functions to load modules.

So package.loader handles all nessessary problems here.

We can simple include another script with one line.

Code: [Select]
require("scriptname")

And straight call our functions in there. We also have the knowledge where the included file is.

Using script context, we need first to split if we need an object, a function, a helper, a module and we need to handle this extra api plus the script functions we want to use.

So where is the advantage to use

Code: [Select]
require("script_context")
require("scriptname")
local f = ScriptContext:GetFunction("function name")
local result = f(parameters)

instead of

Code: [Select]
require("scriptname")
local result = function name(parameters)

beside that one is global and other is modular.

I also think that script context will slow down the processing and uses more memory.
« Last Edit: 21, October 2024, 06:31:31 by Dolfo »
Don't believe the shit, you hear in mainstream. Believe your own body. Your body is speaking always the true to you. But you need to understand your body. Hear to your body, not to your ego. And when body is calling to you: "Hey something is wrong!" find the reason(s) for that. Man in White don't go for that, they don't want to heal you. They want earn money and sell you medicine, you should take rest of your life. You are not the patient, you are their customer. Never forget this!

Tags:
 

Related Topics

  Subject / Started by Replies Last post
6 Replies
1809 Views
Last post 27, June 2006, 23:37:05
by Lein
0 Replies
571 Views
Last post 31, October 2006, 14:59:01
by smacky
5 Replies
679 Views
Last post 02, November 2006, 11:29:11
by smacky
2 Replies
761 Views
Last post 23, August 2007, 04:23:17
by tehill
18 Replies
6105 Views
Last post 17, February 2010, 05:15:06
by ankit_1992s