mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: Lua - add to package.path current content plugin path
This commit is contained in:
parent
9805ccfb01
commit
01fa62cf11
2 changed files with 17 additions and 0 deletions
|
|
@ -30,6 +30,7 @@ uses
|
|||
Classes, SysUtils, lua;
|
||||
|
||||
procedure RegisterPackages(L : Plua_State);
|
||||
procedure SetPackagePath(L: Plua_State; const Path: String);
|
||||
function LuaPCall(L : Plua_State; nargs, nresults : Integer): Boolean;
|
||||
function ExecuteScript(const FileName: String; Args: array of String): Boolean;
|
||||
|
||||
|
|
@ -463,6 +464,20 @@ begin
|
|||
ReplaceLib(L);
|
||||
end;
|
||||
|
||||
procedure SetPackagePath(L: Plua_State; const Path: String);
|
||||
var
|
||||
APath: String;
|
||||
begin
|
||||
lua_getglobal(L, 'package');
|
||||
lua_getfield(L, -1, 'path');
|
||||
APath := lua_tostring(L, -1);
|
||||
APath := APath + ';' + Path + '?.lua';
|
||||
lua_pop(L, 1);
|
||||
lua_pushstring(L, PAnsiChar(APath));
|
||||
lua_setfield(L, -2, 'path');
|
||||
lua_pop(L, 1);
|
||||
end;
|
||||
|
||||
function LuaPCall(L: Plua_State; nargs, nresults: Integer): Boolean;
|
||||
var
|
||||
Status: Integer;
|
||||
|
|
|
|||
|
|
@ -897,6 +897,8 @@ begin
|
|||
|
||||
RegisterPackages(L);
|
||||
|
||||
SetPackagePath(L, ExtractFilePath(FFileName));
|
||||
|
||||
if DoScript(Self.FFileName) = 0 then
|
||||
Result := True
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue