GetPathOverrideFor(string|integer, string[, boolean])

grandMA3 ユーザマニュアル » プラグイン » Lua 関数 - Object-Free API » GetPathOverrideFor(string|integer, string[, boolean]) Version 2.2

説明

GetPathOverrideFor 関数は、grandMA3 フォルダのパスを示す文字列を返します。これは、卓に接続されたリムーバブルドライブ上にパスがある場合に有効です。

引数

  • string:
    フォルダ名を含む文字列です。
  • string:
    文字列形式のベースパスです。
  • boolean (文字列の場合のオプション):
    true の場合、パスにフォルダが存在しないときに作成されます。
    ― または ―
  • integer:
    "Enum.PathType" テーブル内のインデックスを識別する整数です。
  • string:
    文字列形式のベースパスです。
  • boolean:
    true の場合、パスにフォルダが存在しないときに作成されます。

戻り値

  • string:
    返される文字列は、指定された引数で最初に見つかったフルパスです。

この例では、マクロ・フォルダのオーバーライドパスを System Monitor に出力します。これは、リムーバブルドライブが接続された卓で実行する必要があります。

Lua
return function ()
-- Set a path for the first removable media.
-- Set the initial value to nil.
local myBasePath = nil
-- Itereate the drives and find the first 'Removeable' drive and store the path.
for _, value in ipairs(Root().Temp.DriveCollect) do
local driveType = value.drivetype
if driveType == "Removeable" then
myBasePath = value.path
break
end
end
-- If no removeable drive was found, then provide feedback and exit the function.
if myBasePath == nil then
ErrPrintf("No removeable drive could be found. Please insert one and try again")
return
end

-- Get the integer for the UserMacros path type.
local myPathType = Enums.PathType.UserMacros

-- Gey the string for the path override.
local myOverridePath = GetPathOverrideFor(myPathType, myBasePath)
-- Print the returned string.
Printf("The path is: " .. myOverridePath)
end