AddFixtures(table)

grandMA3 ユーザマニュアル » プラグイン » Lua 関数 - Object-Free API » AddFixtures(table) Version 2.2

説明

AddFixture 関数は、パッチにフィクスチャを追加します。引数はテーブルで、関数が成功するには有効なデータが含まれている必要があります。追加が成功した場合、boolean 値の true を返します。この関数は、正しいパッチ・デスティネーションでコマンドラインとともに実行する必要があります。

引数

  • table:
    テーブルには有効なデータが含まれている必要があります。以下は、テーブルに含めることができる要素の一覧です。すべてを追加する必要はありません。
    • mode:
      有効な "dmx_mode" への handle でなければなりません。これは特定のモードにおける特定のフィクスチャタイプを指定します。
    • amount:
      追加するフィクスチャ数(integer)を指定ます。
    • name (オプション):
      (最初の)フィクスチャ名を含む文字列(string)です。
    • fid (オプション):
      フィクスチャのFIDを表す文字列(string)です。
    • cid (オプション):
      フィクスチャのCIDを表す文字列(string)です。これは、idtype が Fixture 以外の場合にのみ有効です。
    • idtype (オプション):
      IDタイプの名前を表す文字列(string)です。タイプが Fixture 以外の場合にのみ必要です。
    • patch (オプション):
      これは最大8つの文字列を持つ table です。この文字列はユニバースとその開始アドレスを示し、2つはドットで区切る必要があります。各テーブル要素は、パッチ内の最大8つのDMXブレークに用いられます。
    • layer (オプション):
      レイヤ名を含む文字列(string)です。
    • class (オプション):
      クラス名を含む文字列(string)です。
    • parent (オプション):
      親フィクスチャのハンドル(handle)です。フィクスチャが既存フィクスチャのサブフィクスチャとなる場合にのみ必要です。
    • insert_index (オプション):
      挿入インデックス番号(integer)です。
    • undo (オプション):
      アンドゥ・テキストを含む string です。

戻り値

  • boolean または nil:
    成功した場合は true を返します。失敗した場合は何も返しません(nil)。

この例では、FIDとCIDが301、パッチアドレスが "10.001" のディマー・フィクスチャを追加します。条件として、ショーに Generic Dimmer タイプが追加されていて、IDとパッチアドレスが使用可能で、またステージ名が "Stage 1" であることが必要です。この例では、使用可能かどうかのチェックは行われません。

Lua
return function()
    -- Change the command line destination to the root.
    Cmd("ChangeDestination Root")
    -- Enter the "Patch".
    Cmd('ChangeDestination "ShowData"."Patch"')
    -- Enter the fixture location for the "Stage 1" object.
    Cmd('ChangeDestination "Stages"."Stage 1"."Fixtures"')

    -- Create a table.
    local myAddFixtureTable = {}
    -- Set the mode to a 8-bit Dimmer fixture type. 
    myAddFixtureTable.mode = Patch().FixtureTypes.Dimmer.DMXModes["Mode 0"]
    -- Set the amount of fixtures.
    myAddFixtureTable.amount = 1
    -- Set the FID for the fixture.
    myAddFixtureTable.fid = "301"
    -- Set the IdType - it is not needed if the type is "Fixture".
    myAddFixtureTable.idtype = "Channel"
    -- Set the CID - Use only this when the "idtype" is different than Fixture.
    myAddFixtureTable.cid = "301"
    -- Set the name of the fixture.
    myAddFixtureTable.name = "AddedDimmer 301"
    -- Create a patch table with an address.
    myAddFixtureTable.patch = {"10.001"}

    -- Add the fixture to the patch using the table data. Store the result in a local variable.
    local success = AddFixtures(myAddFixtureTable)
    
    -- Provide some feedback.
    if success ~= nil then
        Printf("Fixture " .. myAddFixtureTable.fid .. " is added with patch address " .. myAddFixtureTable.patch[1])
    else
        Printf("AddFixture failed!")
    end
    
    -- Return the command line to the root destination.
    Cmd("ChangeDestination Root")
end