packs dependencies fix + dofile patch
This commit is contained in:
+20
-3
@@ -11,9 +11,6 @@ function is_array(x)
|
||||
return true
|
||||
end
|
||||
|
||||
local __cached_scripts = {}
|
||||
local __cached_results = {}
|
||||
|
||||
-- Get entry-point and filename from `entry-point:filename` path
|
||||
function parse_path(path)
|
||||
local index = string.find(path, ':')
|
||||
@@ -23,6 +20,9 @@ function parse_path(path)
|
||||
return string.sub(path, 1, index-1), string.sub(path, index+1, -1)
|
||||
end
|
||||
|
||||
local __cached_scripts = {}
|
||||
local __cached_results = {}
|
||||
|
||||
-- Load script with caching
|
||||
--
|
||||
-- path - script path `contentpack:filename`.
|
||||
@@ -56,3 +56,20 @@ function sleep(timesec)
|
||||
end
|
||||
end
|
||||
|
||||
_dofile = dofile
|
||||
-- Replaces dofile('*/content/packid/*') with load_script('packid:*')
|
||||
function dofile(path)
|
||||
local index = string.find(path, "/content/")
|
||||
if index then
|
||||
local newpath = string.sub(path, index+9)
|
||||
index = string.find(newpath, "/")
|
||||
if index then
|
||||
local label = string.sub(newpath, 1, index-1)
|
||||
newpath = label..':'..string.sub(newpath, index+1)
|
||||
if file.isfile(newpath) then
|
||||
return load_script(newpath, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
return _dofile(path)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user