0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

LSLのデータ型まとめ

Last updated at Posted at 2025-04-07

📦 LSLの主なデータ型まとめ

基本データ型一覧

データ型 説明 使用例
integer 整数(-2,147,483,648 ~ 2,147,483,647) integer count = 5;
float 小数(単精度) float time = 3.14;
string 文字列(セリフや名前など) string name = "賢ちゃん";
key UUID(オブジェクトやアバターの識別子) key avatar = llDetectedKey(0);
vector 3次元の位置やサイズ(x, y, z) vector pos = <10.0, 20.0, 30.0>;
rotation 回転(クォータニオン) rotation rot = <0, 0, 0, 1>;
list 複数のデータを1つにまとめる配列的な型 list names = ["A", "B", "C"];

型ごとの詳細

integer(整数)

  • 演算OK(+, -, *, /, %
  • TRUE / FALSE1 / 0 として扱われる

float(小数)

  • 小数点あり、時間や比率、座標などに使う
  • 丸め誤差に注意(例:0.1 + 0.2 ≠ 0.3)

string(文字列)

  • メッセージ、名前、UUID文字列の保持などに使う
  • 結合は + 演算子でOK → "Hello " + name

key(UUID)

  • オブジェクトやアバターなどを識別する「ユニークID」
  • llDetectedKey()llGetOwner() で取得

vector(座標・サイズなど)

  • <x, y, z> の3D座標で構成
  • 位置、色、サイズなどで使用される

rotation(回転)

  • <x, y, z, s> のクォータニオン形式
  • 直感的ではないけど LSL では標準

list(リスト)

  • 異なる型をまとめて保持できる
  • 要素取得に llList2String() などを使用

型変換(キャスト)

string s = (string)123;               // 整数 → 文字列
integer i = (integer)"456";           // 文字列 → 整数
float f = (float)"3.14";              // 文字列 → 小数
vector v = (vector)"<1.0,2.0,3.0>";   // 文字列 → ベクター

list型チェック(リストの中身)

0番目の要素の型を以下のように取得できる

llOwnerSay("Type: " + (string)llGetListEntryType(myList, 0));
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?