Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Library: Scripted Gesture System

daiz Papp
Registered User
Join date: 31 Jul 2007
Posts: 7
05-20-2008 16:50
this is script to make gesture controlled by script even if script cannot be written.
please look at next comment about explanation.


// script code

list Trigger = [];
list Gesture = [];
list Item = ["Chat","Wait","Sound","AnimStart","AnimStop"];
list Link = [];
list Type = [];
list Name = [];

integer Listen1 = 0;
integer Listen2 = 0;
integer Channel1 = 0;
integer Channel2 = 0;
integer Finish = FALSE;
integer Preload = TRUE;

integer Begin = 0;
integer End =0;
integer Count = 0;
integer NoteLine = 0;
string NoteName = "";
integer NoteIndex = 0;
string BackButton = "! << BACK ! ,";
string NextButton = "! NEXT >> ! ,";

Say(integer enable,string data)
{
if(enable)
llOwnerSay(data);
}

list GetList(integer begin, integer end)
{
list List = [];
integer Length = llGetListLength(Gesture);
if(end > Length)
end = Length;
integer i = 0;
for(i = begin; i < end; i++)
List = llListInsertList(List, [llList2String(Gesture, i)], i);
return List ;
}

PlayList(integer start, integer stop)
{
integer i = start;
for(i = start; i < stop; i++)
{
integer Index = (integer)llList2String(Type, i);
if(Index == 0)
llSay(0,llList2String(Name, i));
else if(Index == 1)
llSleep((float)llList2String(Name, i));
else if(Index == 2)
llPlaySound(llList2String(Name, i),1);
else if(Index == 3)
llStartAnimation(llList2String(Name, i));
else if(Index == 4)
llStopAnimation(llList2String(Name, i));
}
}

Play(integer index)
{
Say(!Finish,"load notecard...ok";);
integer Start = 0;
integer Stop = 0;
integer i = 0;
if(index == -1)
Stop = llGetListLength(Type);
else
{
list List = llCSV2List(llList2String(Link,index));
Start = (integer)llList2String(List,0);
Stop = (integer)llList2String(List,1);
i = Start;
}
if(Preload)
{
Say(!Finish,"cashing sound...";);
for(i = Start; i < Stop; i++)
{
integer Index = (integer)llList2String(Type, i);
if(index == 2)
llPreloadSound(llList2String(Name, i));
}
Say(!Finish,"cashing sound...ok";);
}
Say(!Finish,"test playing...";);
PlayList(Start, Stop);
Say(!Finish,"test playing...ok";);
}

Reset(integer enable)
{
if(enable)
{
Trigger = [];
Gesture = [];
Type = [];
Name = [];
Count = 0;
NoteLine = 0;
NoteName = "";
NoteIndex = 0;
}
Channel1 = (integer)llFrand(123456789);
if(Channel1 < 10000)
Channel1 = Channel1 + 10000;
Channel2 = Channel1 + 1;
llListenRemove(Listen1);
llListenRemove(Listen2);
Listen2 = llListen(0, "", llGetOwner(), "";);
llResetTime();
llSetTimerEvent(0.0);
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
integer Length = llGetInventoryNumber(INVENTORY_NOTECARD);
integer i = 0;
if(enable)
{
for(i = 0; i < Length; i++)
{
list List = llCSV2List(llGetInventoryName(INVENTORY_NOTECARD, i));
if(llGetListLength(List) == 2)
{
Trigger = llListInsertList(Trigger, [llList2String(List,1)], i);
Gesture = llListInsertList(Gesture, [llList2String(List,0)], i);
}
else
{
Trigger = llListInsertList(Trigger, [""], i);
Gesture = llListInsertList(Gesture, [llGetInventoryName(INVENTORY_NOTECARD, i)], i);
}
}
Say(!Finish,"reset script...ok";);
}
}

NoteCard(list List, string data)
{
integer Index = llListFindList(List,[data]);
if(Index != -1)
{
if(!Finish)
{
Count = 0;
NoteLine = 0;
NoteName = llList2String(Gesture, Index);
if(llList2String(Trigger, Index) != "";)
NoteName = NoteName + "," + llList2String(Trigger, Index);
Type = [];
Name = [];
Say(!Finish,"load notecard...";);
llGetNotecardLine(NoteName, NoteLine);
}
else
Play(Index);
}
}

Menu(key id)
{
integer Back = 0;
integer Next = llGetListLength(Gesture);
if(Next == 0)
{
llListenRemove(Listen1);
llDialog(llGetOwner(), "there is no notecard", [], Channel1);
return;
}
if(Next > 9)
Next = 9;
list List = GetList(Back,Next);
if(Next == 9 || Next < 9)
Next = 0;
if(llGetListLength(Gesture) > 9)
Next = 9;
string BACK = BackButton + (string)Back;
string NEXT = NextButton + (string)Next;
llListenRemove(Listen1);
Listen1 = llListen(Channel2, "", llGetOwner(), "";);
llDialog(llGetOwner(), "select nortcard", [BACK, llList2String(["MENU","-"], Finish), NEXT] + List, Channel2);
}

Dialog(key id)
{
llListenRemove(Listen1);
Listen1 = llListen(Channel1, "", llGetOwner(), "";);
string Data = "[x]Preload";
if(!Preload)
Data = "[-]Preload";
llDialog(llGetOwner(), "main menu", ["Reset", "Note", "Finalize", Data], Channel1);
}

default
{
on_rez(integer i)
{
Reset(FALSE);
}

touch_start(integer i)
{
if(!Finish)
Dialog(llDetectedKey(i));
else
Menu(llDetectedKey(i));
}

state_entry()
{
Reset(TRUE);
}

dataserver(key id, string data)
{
if(data != EOF)
{
list List = llCSV2List(data);
if(llGetListLength(List) == 2)
{
integer Check = llListFindList(Item,[llList2String(List,0)]);
if(Check != -1)
{
Type = llListInsertList(Type, [(string)Check], Count);
Name = llListInsertList(Name, [llList2String(List,1)], Count);
Count ++;
End ++;
}
}
NoteLine ++;
llGetNotecardLine(NoteName, NoteLine);
}
else
{
if(!Finish)
Play(-1);
else
{
Link = llListInsertList(Link, [(string)Begin + "," + (string)End], NoteIndex);
Begin = End;
NoteLine = 0;
NoteIndex ++;
if(NoteIndex < llGetListLength(Gesture))
{
NoteName = llList2String(Gesture, NoteIndex);
if(llList2String(Trigger, NoteIndex) != "";)
NoteName = NoteName + "," + llList2String(Trigger, NoteIndex);
llGetNotecardLine(NoteName, NoteLine);
Say(1,"[" + (string)NoteIndex + "]" + NoteName + "...";);
}
else
Say(1,"finalize script...ok";);
}
}
}

listen(integer ch, string name, key id, string message)
{
if(ch == 0)
NoteCard(Trigger, message);
else if(ch == Channel1)
{
if(Finish)
return;
if(message == "Reset";)
Reset(TRUE);
else if(message == "Note";)
{
Menu(id);
return;
}
else if(message == "[x]Preload";)
Preload = FALSE;
else if(message == "[-]Preload";)
Preload = TRUE;
else if(message == "Finalize";)
{
Finish = TRUE;
Say(1,"finalize script...";);
integer Length = llGetListLength(Gesture);
if(Length == 0)
Say(1,"there is not notecard...";);
else
{
Begin = 0;
End =0;
Count = 0;
NoteLine = 0;
NoteIndex = 0;
NoteName = llList2String(Gesture, NoteIndex);
if(llList2String(Trigger, NoteIndex) != "";)
NoteName = NoteName + "," + llList2String(Trigger, NoteIndex);
llGetNotecardLine(NoteName, NoteLine);
Say(1,"[" + (string)NoteIndex + "]" + NoteName + "...";);
}
}
llListenRemove(Listen1);
}
else if(ch == Channel2)
{
integer CheckBack = llSubStringIndex(message, BackButton);
integer CheckNext = llSubStringIndex(message, NextButton);
if(CheckBack != -1 || CheckNext != -1)
{
integer Back = 0;
integer Next = 0;
if(CheckBack != -1)
{
string Data = llDeleteSubString(message, CheckBack, llStringLength(BackButton) - 1);
if(Data == "0";)
Data = "9";
Back = (integer)Data - 9;
Next = (integer)Data;
}
else
{
integer Data = (integer)llDeleteSubString(message, CheckNext, llStringLength(NextButton) - 1);
Back = Data;
Next = Data + 9;
}
if(Back < 0)
Back = 0;
list List = GetList(Back,Next);
integer Length = llGetListLength(Gesture);
if(Length < Next || Length == Next)
Next = Back;
string BACK = BackButton + (string)Back;
string NEXT = NextButton + (string)Next;
llDialog(llGetOwner(), "select nortcard", [BACK, llList2String(["MENU","-"], Finish), NEXT] + List, Channel2);
return;
}
else
{
if(message == "MENU";)
{
if(Finish)
return;
Dialog(id);
return;
}
else if(message == "-";)
llListenRemove(Listen1);
else
NoteCard(Gesture, message);
}
llListenRemove(Listen1);
return;
}
}
}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Library bump
05-21-2008 07:12
:)
_____________________
i've got nothing. ;)
daiz Papp
Registered User
Join date: 31 Jul 2007
Posts: 7
readme, manual by english
05-21-2008 10:35
[object name]

Scripted Gesture System

[creation date]

Feb.17.2008 (2008/02/17)

[how to use]

this is script to make gesture controlled by script even if script cannot be written.

object(prim) is made, and "main" script in contents. notecard for gesture is prepared.
*)trigger can be added to name of notecard.

"name,trigger(chat)" ... "tenshi no uta,tenshi"
please do not use comma for name of notecard besides.

notecard is opened, and instruction for gesture is written at intervals of one line.

command list [Chat Sound AnimStart AnimStop Wait]

#example --------

[command,name]

Chat,Hello
Sound,hi
AnimStart,waves
Wait,5
AnimStop,waves

#example --------

when notecard is completed, puts in contents. reset button is pushed clicking object.
please do reset processing when you add new notecard.
gesture is selected with "Note" clicking object again.
*)please put sound and animation used in same contents.

[others]

you can sell gesture made by this script.
reading notecard is shortened by Finalize.
daiz Papp
Registered User
Join date: 31 Jul 2007
Posts: 7
readme, manual by japanese
05-21-2008 10:48
[使い方]

スクリプトが書けない人でもスクリプトによってコントロールされるジェスチャーを作成するためのスクリプトです。

オブジェクトを作成してコンテンツ内に "main" スクリプトを入れてください。設定用のノートカードを用意します。
*)ノートカードの名前にトリガーを加えることができます。 "名前,トリガー" ... "tenshi no uta,tenshi"

ノートカードを開いてジェスチャーの命令を一行ずつ書いていきます。命令リスト [Chat Sound AnimStart AnimStop Wait]

(例)

[command,name]

Chat,Hello
Sound,hi
AnimStart,waves
Wait,5
AnimStop,waves

ノートカードを書き終えたら作成したオブジェクトのコンテンツ内に入れて、それをクリックしてリセットしてください。
新しいノートカードを追加したらリセット処理を行ってください。 ダイアログの"Note"でノートカードを選択して再生します。
*)使用するアニメーションやサウンドは同じコンテンツ内に入れてください。

[その他]

ファイナライズ処理によりノートカードの読み込みを短縮できます。
このスクリプトで作成したジェスチャーを販売することができます。

// どんなことに使えば良いのか?

例えるならセカンドライフ内で存在するCDプレイヤーに似ています。ジェスチャーで10秒間のサウンドを繋げて再生する時に、スクリプトならそれよりも長く作ることができるでしょう。

何に使えば良いかと言うと
武器の場合、1)斬ったとき、2)撃ったとき、3)相手の攻撃が当たったときのように、それぞれの動作を作り、それを並行して実行するようなシステムとして役に立ちます。

一連の流れは途中でストップさせる必要がほとんどなく、結果を戻したり分析する必要がないためストリーミングのように並列で実行させて、そのまま破棄します。
Mentaro Franzos
Registered User
Join date: 26 Apr 2008
Posts: 1
Gesture script
03-11-2009 22:35
I have tried this script... it works fabulously... but one hiccup... when i trigger the gesture.. I can only hear the sound locally, I cant get it so that the sound accompanying the chat text plays globally so that all can hear it. I have tried this with several people and i get the same results. I hope someone can help :0))
Ewer Short
Registered User
Join date: 24 Jun 2008
Posts: 1
Play sound in-world from attachment or HUD
04-02-2009 08:28
If the object playing the sound is a HUD, the sound is only heard by the user the HUD is attached to.
To play a sound inworld from a HUD use llTriggerSound.
information found at: http://wiki.secondlife.com/wiki/LlPlaySound

Hope this helps :))
HulkHogan Hendrassen
Registered User
Join date: 19 Feb 2009
Posts: 10
07-23-2009 23:33
I set this up. But how do i allow people to use it. It only allows me to use this when someone tries to click on the object it doesn't do anything for them just for me.
CThomas Warrhol
Registered User
Join date: 22 Oct 2009
Posts: 1
the answer
01-09-2010 01:05
Just swtich LLSound to LLTriggerSound.... and that should get what your looking for
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-09-2010 03:00
you're about 5 months late... at best =)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Dekka Raymaker
thinking very hard
Join date: 4 Feb 2007
Posts: 3,898
01-09-2010 06:11
From: Void Singer
you're about 5 months late... at best =)

still faster than Linden Labs then?
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-09-2010 12:40
From: Dekka Raymaker
still faster than Linden Labs then?

hare to their tortoise =)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -