>> To Reload Assets use this(link)! <<


The dynamic scripts can be used for quick developments, they allow adding a file in place of a script (can be inside of a function) and reloading it each time from file.
They also allow passing in arguments to function inside of the file(such as self or for example range from Character:PlayerIsInRange( range ) or any other variable).

First you will have to create a new folder in the TUG folder and create new lua file.
Using the following pattern:
function custom(self) -- you can add more arguments here
	-- Insert your code here
end
return custom -- make sure the function name matches

Then you will need to add this script(hook) to the code you want to dynamically reload.
local f = assert(loadfile(NAME_OF_THE_FILE)) -- NAME_OF_THE_FILE is the path from the folder TUG!
f()(self)


Example:

/TUG/dev/torch_spawn.lua (create new file)
function custom(self)
	self:NKGetSound():NKPlay3DSound(self.m_torchSound, true, vec3.new(0, 0, 0), 10.0, 15.0)
end
return custom

Inside of Torch.lua
function Torch:Spawn()
	self:NKSetEmitterActive(true)
	-- self:NKGetSound():NKPlay3DSound(self.m_torchSound, true, vec3.new(0, 0, 0), 10.0, 15.0)
	-- I want to change the NKPlay3DSound function, I have commented it out and added the hook

	local f = assert(loadfile('dev/torch_spawn.lua'))
	f()(self)

end

Now you can change the sound of every new spawned torch by just changing the file(without reloading the game).

Warning functions defined this way will reload (from file) every time they are executed!