Search the Community
Showing results for tags 'loadstring'.
Found 2 results
Hello! So i want to load external lua files in my resource and i do it with loadstring (Link). Like this: function loadLuaFile( path ) local file = fileOpen(path, true) if (not file) then outputChatBox("Failed") return else local string = "" local buffer while not fileIsEOF(file) do buffer = fileRead(file, 100) if (buffer) then string = string .. buffer end end loadstring(string)() end fileClose(file) end Loading a few script: loadLuaFile(":shared/oop.lua") loadLuaFile(":shared/test1.lua") loadLuaFile(":shared/test2.lua") And i found a wierd thing. It doesn't matter how many lua files i load in, the memory usage in performancebrowser doesn't change. Is it a bug? Or somehow its recognize this code was loaded in another resource?
Hey, I have a problem with loading script files of maps into an environment. If a map uses "addEventHandler" to e.g. add the event "onClientMarkerHit" it most likely uses the "source" variable inside the attached function. However, this source variable does not exist in the scripts environment. The only way to still make it work at the moment is to let it have access to the _G environment, where the variable seems to exist. Is there a way to make it work without that? Bonsai