mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-30 13:13:00 +00:00 
			
		
		
		
	Update lua.lua require logic.
This makes it more consistent in situations when someone requires with path starting with /.
This commit is contained in:
		| @@ -25,21 +25,13 @@ local tEnv = { | |||||||
| } | } | ||||||
| setmetatable(tEnv, { __index = _ENV }) | setmetatable(tEnv, { __index = _ENV }) | ||||||
|  |  | ||||||
| -- Replace our package.path, so that it loads from the current directory, rather | -- Replace our require with new instance that loads from the current directory | ||||||
| -- than from /rom/programs. This makes it a little more friendly to use and | -- rather than from /rom/programs. This makes it more friendly to use and closer | ||||||
| -- closer to what you'd expect. | -- to what you'd expect. | ||||||
| do | do | ||||||
|  |     local make_package = require "cc.require".make | ||||||
|     local dir = shell.dir() |     local dir = shell.dir() | ||||||
|     if dir:sub(1, 1) ~= "/" then dir = "/" .. dir end |     _ENV.require, _ENV.package = make_package(_ENV, dir) | ||||||
|     if dir:sub(-1) ~= "/" then dir = dir .. "/" end |  | ||||||
|  |  | ||||||
|     local strip_path = "?;?.lua;?/init.lua;" |  | ||||||
|     local path = package.path |  | ||||||
|     if path:sub(1, #strip_path) == strip_path then |  | ||||||
|         path = path:sub(#strip_path + 1) |  | ||||||
|     end |  | ||||||
|  |  | ||||||
|     package.path = dir .. "?;" .. dir .. "?.lua;" .. dir .. "?/init.lua;" .. path |  | ||||||
| end | end | ||||||
|  |  | ||||||
| if term.isColour() then | if term.isColour() then | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Wojbie
					Wojbie