Library Token/ja: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(New page: {{Languages|Library Token}}{{Translation}}{{#customtitle:ライブラリトークン|ライブラリトークン}} Introduced in MapTool version b46, the Library Token is a special token t...)
 
m (Taustin moved page library Token/ja to Library Token/ja without leaving a redirect)
 
(11 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Languages|Library Token}}{{Translation}}{{#customtitle:ライブラリトークン|ライブラリトークン}}
{{Languages|Library Token}}{{DISPLAYTITLE:ライブラリートークン|ライブラリートークン}}{{Translation}}
Introduced in MapTool version b46, the Library Token is a special token type that acts as a library of properties and trusted macros that may be accessed and called by other macros.  
=ライブラリートークン=
__TOC__
<div style="color:gray">Introduced in MapTool version 1.3b46, the Library Token is a special token type that acts as a library of properties and trusted macros that may be accessed and called by other macros. </div>


==ライブラリトークンの命名==
MapToolバージョン1.3b46で導入された、ライブラリートークンは他のマクロからアクセスし呼び出すことが出来る特性値と承認マクロを収蔵するライブラリーを持つ特殊なトークン種別である。


All library tokens must have a name in the format "Lib:''name''", to indicate that they are to serve as a Library Token and not a "normal" token. Example library token names might be:
==ライブラリートークンの命名==
 
<div style="color:gray">All library tokens must have a name in the format "Lib:''name''", to indicate that they are to serve as a Library Token and not a "normal" token. Example library token names might be:</div>
 
ライブラリートークンの名前は必ず「Lib:''名前''」の書式であり、このトークンがライブラリートークンであり通常のトークンではないことを示している。ライブラリートークン名の例は次の通り:


*Lib:test
*Lib:test
Line 10: Line 16:
*Lib:gamemaster
*Lib:gamemaster


==ライブラリトークンを作成する==
==ライブラリートークンを作成する==


To create a Library Token, do the following:
<div style="color:gray">To create a Library Token, do the following:</div>


ライブラリートークンを作成するには、次の手順になる:
<div style="color:gray">
# Drag a new token on to one of the maps in your campaign.
# Drag a new token on to one of the maps in your campaign.
# Rename it with a name in the format '''Lib''':''name'' (''e.g.'', '''Lib:DnD''', '''Lib:GameRules''', etc.).  
# Rename it with a name in the format '''Lib''':''name'' (''e.g.'', '''Lib:DnD''', '''Lib:GameRules''', etc.).  
# Right click on the token and make sure that '''Visible to Players''' is checked.
# Right click on the token and make sure that '''Visible to Players''' is checked.
# Double-click on it, and go to the '''Ownership''' tab. Make sure that '''''nothing''''' is checked.
# Set the token type to NPC (upper right corner of the Token Configuration dialog).
# Set the token type to NPC (upper right corner of the Token Configuration dialog).
</div>
# キャンペーンのマップ上にトークンを配置する。この地図がプレイヤーに表示されている必要はない。
# 名前を'''Lib''':''name''の書式に変更する(例:'''Lib:DnD'''、'''Lib:GameRules'''など)。
# トークン上で右クリックし、'''プレイヤーに表示'''が有効になっていることを確認する。
# トークン種別をNPCに設定する。(トークン設定ダイアログの右上)
<div style="color:gray">After that, you have a Library Token. Note that you cannot have two library tokens with the same name in the same campaign (even if they're on different maps!). </div>
以上でライブラリートークンの完成だ。同一キャンペーン内で、同じ名前持つライブラリートークンを複数持つことができないことを覚えておくように(それぞれが違うマップにあっても、だ!)。


After that, you have a Library Token. Note that you cannot have two library tokens with the same name in the same campaign (even if they're on different maps!).
<div style="color:gray">Once again, the requirements are:</div>


Once again, the requirements are:
繰り返しになるが、必要条件を挙げておく:


* The library token must be visible to players (make sure Visible to Players is set in the right-click context menu). The library token need not be on the "Token" layer (you can keep it on the "Hidden" layer to hide it from players, although "Visible to Players" must still be set to true).
<div style="color:gray">
* The library token must be visible to players (make sure Visible to Players is set in the right-click context menu).
* The library token need not be on the "Token" layer (you can keep it on the "Hidden" layer to hide it from players, although "Visible to Players" must still be set to true).
* The library token must have a name in the format "Lib:''name''"
* The library token must have a name in the format "Lib:''name''"
* The library token must be present on ''only one'' map in the campaign file.
* The library token must be present on ''only one'' map in the campaign file.
* The library token '''may not''' be owned by any players (it's best not to be owned by ANYONE!)
</div>
 
* ライブラリートークンはプレイヤーに表示していなければならない(右クリックメニューの「プレイヤーに表示(Visible to Players)が有効になっていることを確認)。
* ライブラリートークンは「トークン・レイヤー」にある必要はない(『秘匿』レイヤーに置くことでプレイヤーから隠すことは可能だが、その場合でも『プレイヤーに表示』は有効にしておかなければならない)。
* ライブラリートークンは「Lib:''名前''」の書式でなければならない。
* ライブラリートークンはキャンペーン・ファイルに''ひとつだけ''存在することができる。
 
==ライブラリートークンと承認マクロ==
 
ライブラリートークンは下記の条件を満たすことで[[Trusted Macro|承認マクロ]]の実行、あるいは承認マクロ関数として使用することが出来る:
* ライブラリートークンが'''いずれのプレイヤーにも所有権がない'''、もしくは
* ライブラリートークン上のマクロが、'''プレイヤーが編集できない'''場合。
 
ライブラリートークンがこれらの条件を1つでも満たさないのであれば、''承認マクロを実行することはできない''。これによりプレイヤーが望む''承認されない''マクロのための個人的なライブラリトークンをプレイヤーが作ることが出来るようになり、その一方で、プレイヤーに権限が与えられていないトークンやキャンペーン要素を変更したり操作したりすることを防ぐことにもなる。
 
==ライブラリートークンマクロ==
 
<div style="color:gray">Library token macros are created and edited like macros on any token. Macros on a library token may be called using the [[Macros:Branching_and_Looping#MACRO_Option| [MACRO(): ]]] roll option. Since Library token macros are trusted, they may perform operations not available to regular tokens.
</div>
 
ライブラリートークン・マクロはトークンのマクロと同じように記述する。ライブラリートークンのマクロはロール・オプション:[[Macros:Branching_and_Looping/ja#MACRO_Option| [MACRO(): ]]]を使用することが多い。ライブラリートークンマクロは承認されるので、通常のトークンがなしえない操作を行うことができる。
 
==ライブラリートークン特性値==
 
ライブラリートークンの特性値は {{func|setLibProperty}} と {{func|getLibProperty}} を使用して値の設定と読み出しが可能だ。
 
{{func|getLibProperty}} はキャンペーン特性値の初期値を返す事は無く、ライブラリトークンに値が設定されていない場合は空文字列を返す。これは想定していない初期値を使用することによる意図しない用法のエラーを防ぐことに役立つ。
 
===『libversion』特性値 ===
<div style="color:gray">The special 'libversion' property can be set on a library token to be output with <code>getInfo("client")</code>. The library token's name and the libversion will be a key/value pair in the nested "library tokens" object of the resulting {{func|getInfo}} JSON object. The libversion property value will be displayed 'as-is'; any macro code in libversion will be displayed instead of processed.</div>
 
特殊な 'libversion' 特性値はライブラリトークンに設定でき、<code>getInfo("client")</code> で出力する事ができる。ライブラリトークンの名称と libversion はキーと値のペアとして、 {{func|getInfo}} が返すJSONオブジェクトの一部として入子状の "library tokens" オブジェクトとして得られる。この libversion 特性値の値は『そのまま』表示される; マクロコード上の libversion は処理されることなく表示される。
 
<div style="color:gray">To edit libversion, you can either add libversion to the Library Token's property list in the Campaign Preferences and then edit the token's properties directly, or set it via the chat panel or a macro using the {{func|setLibProperty}} function.</div>
 
libversion を編集するには、キャンペーン設定のライブラリトークンの特性値一覧に libversion を追加し、ライブラリトークンの特性値を直接編集する、或いはチャット・パネルもしくはマクロにおいて {{func|setLibProperty}} 関数を使う。
 
<div style="color:gray">When creating and improving upon a library token as a 'plugin' others use in their games, updating libversion with new releases is good practice. You may consider using [https://semver.org/ Semantic Versioning] to help give version numbers meaning for your users.</div>
 
ライブラリートークンを、ゲーム内で他から使用する『プラグイン』として作成し機能強化する場合、libversion も更新する事が良い習慣だろう。ほかのユーザーにとって解りやすいバージョン番号を決めるには [https://semver.org/lang/ja/ セマンティックバージョニング(意味付けされたバージョン付け)] を参考にすると良いだろう。
 
==ライブラリートークンを onCampaignLoad で起動する==
 
<div style="color:gray">Most users will find it worthwhile to add an [[onCampaignLoad]] macro to your Lib token that will use {{func|defineFunction}} to make your Lib macros accessible like the built-in macro functions and recognized by the macro editor.</div>
 
多くのユーザーは、[[onCampaignLoad]] マクロに、{{func|defineFunction}} を使い自分のライブラリーマクロを追加する事が便利である事に気付くだろう({{func|defineFunction}} はマクロを組み込みマクロ関数と同じように使う事ができるように、そしてマクロエディターで強調表示するために使用する)。
 
==ライブラリートークンのURI接続==
<div style="color:gray">As of version 1.10.0 the properties and macros on Lib:Tokens can be accessed via a URI from within MapTool. URI access can be enabled for a Lib:Token from the token edit dialog.</div>
 
バージョン1.10.0において、ライブラリートークン上の特性値とマクロは、MapTool 内で URI を通して使用することが出来る。ライブラリートークンのURIによる接続を有効にするには『トークン編集』ダイアログを使用する。
 
[[File:LibTokenURI.png|500px]]
 
<div style="color:gray">Once this has been enabled you will be able to access the macros and properties on the Lib:Token with</div>
 
これを有効にすると、下記の様にライブラリートークン上のマクロや特性値を参照する事ができるようになる
 
* lib://''<トークン名称>''/macro/''<macro name>''
* lib://''<トークン名称>''/property/''<property name>''
 
 
<div style="color:gray">Where ''<token name>'' is the token after the lib: part, for example lib://myjs/macro/scripts/script1.js would point to the a macro named scripts/script1.js on the token lib:myjs.
These URIs can be used in the following places.
 
* script tags for including JavaScript in frame5/dialog5/overlay
* link tags for including CSS in frame5/frame/dialog5/dialog/overlay
* As an argument to the {{func|js.evalURI}} macro function.
* As an argument to the {{func|html.dialog}} / {{func|html.dialog5}} macro functions.
* As an argument to the {{func|html.frame}} / {{func|html.frame5}} macro functions.
* As an argument to the {{func|html.overlay}} macro function.
</div>
 
''<トークン名称>''はトークン名称の lib: の後の部分である。つまり lib://myjs/macro/scripts/script1.js であれば、lib:myjs トークンの scripts/script1.js と言う名称のマクロを示している。
これらのURIは下記の場所で使用することが出来る。
 
* frame5/dialog5/overlay 内のJavaScriptを含む『script』タグ
* frame5/frame/dialog5/dialog/overlay 内のCSSを含む『link』タグ
* {{func|js.evalURI}} マクロ関数の引数。
* {{func|html.dialog}} / {{func|html.dialog5}} マクロ関数の引数。
* {{func|html.frame}} / {{func|html.frame5}} マクロ関数の引数。
* {{func|html.overlay}} マクロ関数の引数。
 
'''注記:'''
<div style="color:gray">Since the WebView component does its own internal caching which cant be influenced by the usual methods in the JVM for turning off caching of certain URI a work around needed to be introduced. To ensure that JavaScript/css picks up the latest version the query string cachelib=false needs to be used and the code will do some finagling to ensure it turns into a URL that wont be cached for example </div>


==ライブラリトークンと承認マクロ==
WebViewコンポーネントは、独自の内部キャッシュを使用しており、特定のURIのキャッシュを無効化するJVMの通常の方法では影響を受けないため、迂回する方法を導入する必要があった。JavaScript や CSS が最新版を確実に取得できるようにするには、クエリ文字列 cashelib=false を使用する必要があり、コード上でキャッシュしない事を確実にするには次のように調整する必要がある。
In addition to the above requirements if you want players to be able to run any macro that calls a function designated as a trusted function the following requirement must also be met.
# The library token must ''not'' be owned by any players (in the Ownership tab of the Edit Token dialog, make sure that no boxes are checked)


Multiple library tokens may exist in the same campaign provided no two library tokens have the same token name.
lib://Test/macro/test/test.js?cachelib=false


==ライブラリトークンマクロ==
==参考記事==
* [[Token|MapTool Tokens]]
* [[Token Types]]
* [[Image_Token|Image Token]]
* [[TokenTool Quickstart|TokenTool QuickStart Guide]]
* [[Introduction_to_Tokens|Introduction to Tokens]]
* {{func|getAllowsURIAccess}}
* {{func|setAllowsURIAccess}}


Library token macros are created and edited like macros on any token. Macros on a library token may be called using the [[Macros:Branching_and_Looping#MACRO_Option| [MACRO(): ]]] roll option. Since Library token macros are trusted, they may perform operations not available to regular tokens.


==ライブラリトークンプロパティー==


Library token properties can be accessed by using the {{func|getLibProperty}} function.  Note that default property values do '''NOT''' work using that function.
{{Languages|Library Token}}
{{Languages|Library Token}}
[[Category:Token]]
[[Category:Token]]

Latest revision as of 23:07, 9 May 2023

Languages:  English  • 日本語

ライブラリートークン

Introduced in MapTool version 1.3b46, the Library Token is a special token type that acts as a library of properties and trusted macros that may be accessed and called by other macros.

MapToolバージョン1.3b46で導入された、ライブラリートークンは他のマクロからアクセスし呼び出すことが出来る特性値と承認マクロを収蔵するライブラリーを持つ特殊なトークン種別である。

ライブラリートークンの命名

All library tokens must have a name in the format "Lib:name", to indicate that they are to serve as a Library Token and not a "normal" token. Example library token names might be:

ライブラリートークンの名前は必ず「Lib:名前」の書式であり、このトークンがライブラリートークンであり通常のトークンではないことを示している。ライブラリートークン名の例は次の通り:

  • Lib:test
  • Lib:combat
  • Lib:gamemaster

ライブラリートークンを作成する

To create a Library Token, do the following:

ライブラリートークンを作成するには、次の手順になる:

  1. Drag a new token on to one of the maps in your campaign.
  2. Rename it with a name in the format Lib:name (e.g., Lib:DnD, Lib:GameRules, etc.).
  3. Right click on the token and make sure that Visible to Players is checked.
  4. Set the token type to NPC (upper right corner of the Token Configuration dialog).
  1. キャンペーンのマップ上にトークンを配置する。この地図がプレイヤーに表示されている必要はない。
  2. 名前をLib:nameの書式に変更する(例:Lib:DnDLib:GameRulesなど)。
  3. トークン上で右クリックし、プレイヤーに表示が有効になっていることを確認する。
  4. トークン種別をNPCに設定する。(トークン設定ダイアログの右上)
After that, you have a Library Token. Note that you cannot have two library tokens with the same name in the same campaign (even if they're on different maps!).

以上でライブラリートークンの完成だ。同一キャンペーン内で、同じ名前持つライブラリートークンを複数持つことができないことを覚えておくように(それぞれが違うマップにあっても、だ!)。

Once again, the requirements are:

繰り返しになるが、必要条件を挙げておく:

  • The library token must be visible to players (make sure Visible to Players is set in the right-click context menu).
  • The library token need not be on the "Token" layer (you can keep it on the "Hidden" layer to hide it from players, although "Visible to Players" must still be set to true).
  • The library token must have a name in the format "Lib:name"
  • The library token must be present on only one map in the campaign file.
  • ライブラリートークンはプレイヤーに表示していなければならない(右クリックメニューの「プレイヤーに表示(Visible to Players)が有効になっていることを確認)。
  • ライブラリートークンは「トークン・レイヤー」にある必要はない(『秘匿』レイヤーに置くことでプレイヤーから隠すことは可能だが、その場合でも『プレイヤーに表示』は有効にしておかなければならない)。
  • ライブラリートークンは「Lib:名前」の書式でなければならない。
  • ライブラリートークンはキャンペーン・ファイルにひとつだけ存在することができる。

ライブラリートークンと承認マクロ

ライブラリートークンは下記の条件を満たすことで承認マクロの実行、あるいは承認マクロ関数として使用することが出来る:

  • ライブラリートークンがいずれのプレイヤーにも所有権がない、もしくは
  • ライブラリートークン上のマクロが、プレイヤーが編集できない場合。

ライブラリートークンがこれらの条件を1つでも満たさないのであれば、承認マクロを実行することはできない。これによりプレイヤーが望む承認されないマクロのための個人的なライブラリトークンをプレイヤーが作ることが出来るようになり、その一方で、プレイヤーに権限が与えられていないトークンやキャンペーン要素を変更したり操作したりすることを防ぐことにもなる。

ライブラリートークンマクロ

Library token macros are created and edited like macros on any token. Macros on a library token may be called using the [MACRO(): ] roll option. Since Library token macros are trusted, they may perform operations not available to regular tokens.

ライブラリートークン・マクロはトークンのマクロと同じように記述する。ライブラリートークンのマクロはロール・オプション: [MACRO(): ]を使用することが多い。ライブラリートークンマクロは承認されるので、通常のトークンがなしえない操作を行うことができる。

ライブラリートークン特性値

ライブラリートークンの特性値は setLibProperty()getLibProperty() を使用して値の設定と読み出しが可能だ。

getLibProperty() はキャンペーン特性値の初期値を返す事は無く、ライブラリトークンに値が設定されていない場合は空文字列を返す。これは想定していない初期値を使用することによる意図しない用法のエラーを防ぐことに役立つ。

『libversion』特性値

The special 'libversion' property can be set on a library token to be output with getInfo("client"). The library token's name and the libversion will be a key/value pair in the nested "library tokens" object of the resulting getInfo() JSON object. The libversion property value will be displayed 'as-is'; any macro code in libversion will be displayed instead of processed.

特殊な 'libversion' 特性値はライブラリトークンに設定でき、getInfo("client") で出力する事ができる。ライブラリトークンの名称と libversion はキーと値のペアとして、 getInfo() が返すJSONオブジェクトの一部として入子状の "library tokens" オブジェクトとして得られる。この libversion 特性値の値は『そのまま』表示される; マクロコード上の libversion は処理されることなく表示される。

To edit libversion, you can either add libversion to the Library Token's property list in the Campaign Preferences and then edit the token's properties directly, or set it via the chat panel or a macro using the setLibProperty() function.

libversion を編集するには、キャンペーン設定のライブラリトークンの特性値一覧に libversion を追加し、ライブラリトークンの特性値を直接編集する、或いはチャット・パネルもしくはマクロにおいて setLibProperty() 関数を使う。

When creating and improving upon a library token as a 'plugin' others use in their games, updating libversion with new releases is good practice. You may consider using Semantic Versioning to help give version numbers meaning for your users.

ライブラリートークンを、ゲーム内で他から使用する『プラグイン』として作成し機能強化する場合、libversion も更新する事が良い習慣だろう。ほかのユーザーにとって解りやすいバージョン番号を決めるには セマンティックバージョニング(意味付けされたバージョン付け) を参考にすると良いだろう。

ライブラリートークンを onCampaignLoad で起動する

Most users will find it worthwhile to add an onCampaignLoad macro to your Lib token that will use defineFunction() to make your Lib macros accessible like the built-in macro functions and recognized by the macro editor.

多くのユーザーは、onCampaignLoad マクロに、defineFunction() を使い自分のライブラリーマクロを追加する事が便利である事に気付くだろう(defineFunction() はマクロを組み込みマクロ関数と同じように使う事ができるように、そしてマクロエディターで強調表示するために使用する)。

ライブラリートークンのURI接続

As of version 1.10.0 the properties and macros on Lib:Tokens can be accessed via a URI from within MapTool. URI access can be enabled for a Lib:Token from the token edit dialog.

バージョン1.10.0において、ライブラリートークン上の特性値とマクロは、MapTool 内で URI を通して使用することが出来る。ライブラリートークンのURIによる接続を有効にするには『トークン編集』ダイアログを使用する。

Once this has been enabled you will be able to access the macros and properties on the Lib:Token with

これを有効にすると、下記の様にライブラリートークン上のマクロや特性値を参照する事ができるようになる

  • lib://<トークン名称>/macro/<macro name>
  • lib://<トークン名称>/property/<property name>


Where <token name> is the token after the lib: part, for example lib://myjs/macro/scripts/script1.js would point to the a macro named scripts/script1.js on the token lib:myjs.

These URIs can be used in the following places.

<トークン名称>はトークン名称の lib: の後の部分である。つまり lib://myjs/macro/scripts/script1.js であれば、lib:myjs トークンの scripts/script1.js と言う名称のマクロを示している。 これらのURIは下記の場所で使用することが出来る。

注記:

Since the WebView component does its own internal caching which cant be influenced by the usual methods in the JVM for turning off caching of certain URI a work around needed to be introduced. To ensure that JavaScript/css picks up the latest version the query string cachelib=false needs to be used and the code will do some finagling to ensure it turns into a URL that wont be cached for example

WebViewコンポーネントは、独自の内部キャッシュを使用しており、特定のURIのキャッシュを無効化するJVMの通常の方法では影響を受けないため、迂回する方法を導入する必要があった。JavaScript や CSS が最新版を確実に取得できるようにするには、クエリ文字列 cashelib=false を使用する必要があり、コード上でキャッシュしない事を確実にするには次のように調整する必要がある。

lib://Test/macro/test/test.js?cachelib=false

参考記事


Languages:  English  • 日本語