GetPresetData(handle[, boolean[, boolean]])

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

説明

GetPresetData 関数は、プリセット・ハンドルに基づいてプリセットデータを含むテーブルを返します。

返されるテーブルは非常に複雑で、テーブル内にもテーブルがあります。

引数

  • handle:
    データが収集されるプリセットのハンドル。
  • boolean または nil (オプション):
    返されるテーブルにフェイザーデータだけを含めるかどうかを決めます。デフォルト値は "false" です。
  • boolean (オプション):
    返されるテーブルに追加オブジェクトを含めるかどうかを指定します。デフォルト値は "true" です。追加のテーブル・オブジェクトは、"by_fixtures" というキーを持ち、返されるテーブルと同じ内容を含みますが、キーはUIチャンネル・インデックスではなくフィクスチャID番号になります。

戻り値

  • table または nil:
    返されるテーブルには、プリセットデータが含まれます。複数レベルのテーブルが含まれます。

この例では、プリセットデータ内にある最初のレベルのテーブルと、プリセット内にある最初のフィクスチャの最初のレベルに関する情報を出力します。これは、必ず存在する Dimmer プリセット1を使用します。

Lua
return function()
-- Get the handle for the first Dimmer preset.
local myPreset = DataPool().PresetPools[1][1]
-- Get the Preset Data of the handle.
local myPresetData = GetPresetData(myPreset, false, false)
-- Check if the GetPresetData returns something.
if myPresetData == nil then
ErrPrintf("Dimmer preset 1 does not exist. Please create one and try again.")
return
end

-- Print the myPresetData table.
for Key, value in pairs(myPresetData) do
if type(value) == "table" then
Printf("Key: " .. Key .. " ; Value type is: " .. type(value))
else
Printf("Key: " .. Key .. " ; Value type is: " .. type(value) .. " ; Value: " .. value)
end
end

-- Create a table object to hold all the integer keys in the myPresetData table.
local myIntegerTableKeys = {}
-- Fill the table.
for key,_ in pairs(myPresetData) do
if type(key) == "number" then
table.insert(myIntegerTableKeys, key)
end
end
-- Sort the table
table.sort(myIntegerTableKeys)

-- Print the elements of the fixture with the lowest ui_channel_index in the preset.
local tableIndex = myIntegerTableKeys[1]
if tableIndex ~= nil then
Printf("=============== TABLE CONTENT START - Table Key: " .. tableIndex .." ===============")
for Key, value in pairs(myPresetData[tableIndex]) do
if type(value) == "table" then
Printf("Key: " .. Key .. " ; Value type is: " .. type(value))
else
Printf("Key: " .. Key .. " ; Value type is: " .. type(value) .. " ; Value: " .. tostring(value))
end
end
Printf("================ TABLE CONTENT END - Table Key: " .. tableIndex .." ================")
end
end