How can I touch object and it ask me to supply name for llSetObjectName?
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
09-19-2006 14:03
I kinda got lost here. When touched I want the object to do the following plus ask me what to name the object. Any suggestions? integer lkey; default { touch_start (integer total_number) { if ( llDetectedKey(0) == llGetOwner() ) { lkey = llListen( 8192, "",llGetOwner(),"" ); llSetTimerEvent( 60 ); llDialog( llGetOwner(), "Object Options:", [ "set pos"],8192); } } listen ( integer ch, string nm, key id, string message ) { llListenRemove( lkey ); if ( message == "set pos" ) { llSetObjectName(string)******************** llSetObjectDesc( (string)llGetRootPosition() ); llOwnerSay ( "Name stored as " + llGetObjectName() ); llOwnerSay ( "Position stored as " + llGetObjectDesc() ); llRemoveInventory( llGetScriptName() ); } } timer() { llListenRemove( lkey ); llSetTimerEvent( 0 ); } }
|
|
Bosozoku Kato
insurrectionist midget
Join date: 16 Jun 2003
Posts: 452
|
09-19-2006 14:20
You're close -- you need another listener to listen to YOU. And a dialog button to take your next chat and use that as the object name without actually scripting it (I just woke up, too lazy)... key lkey2; integer _nCatchSpam; // bool default.. state_enter().. _nCatchSpam = FALSE; touch... lkey = llListen(393493, yadda...); lkey2 = llListen(0, You, YourID, ""  ; _nCatchSpam = FALSE; do dialog: ["Set Name", "Set Pos"]...(set timer) listen(..)... if (msg == "Set Name"  _nCatchSpam == TRUE;timer etc.. return; if (msg == "Set Pos"  ..pos stuff; return; if (chan == 0 && _nCatchSpam) // var the msg ..llSetObjectName = msg; llOwnerSay("Name == "+msg); timer() remove listeners, shut off timer
_____________________
float llGetAFreakingRealTimeStampSince00:00:00Jan11970();
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
09-19-2006 16:15
errrr my eyes are crossing now and gonna take a break. There are problems with nCatchSpam and msg being undeclared. This is what I have so far: integer lkey; integer lkey2; integer _nCatchSpam;// bool
default { state_entry() { _nCatchSpam = FALSE; } touch_start (integer total_number) { if ( llDetectedKey(0) == llGetOwner() ) { lkey = llListen( 8192, "",llGetOwner(),"" ); lkey2 = llListen(0,"",llGetOwner(),""); _nCatchSpam = FALSE; llSetTimerEvent( 60 ); llDialog( llGetOwner(), "Object Options:", [ "set name", "set pos"],8192); } } listen ( integer ch, string nm, key id, string message ) { llListenRemove( lkey ); if (message == "set name") { _nCatchSpam == TRUE; llOwnerSay ("What do you want to name me?"); } if ( message == "set pos" ) { llSetObjectDesc( (string)llGetRootPosition() ); llOwnerSay ( "Position stored as " + llGetObjectDesc() ); llRemoveInventory( llGetScriptName() ); } llListenRemove( lkey2 ); if (ch == 0 && nCatchSpam) // var the msg { llSetObjectName((string) msg()); llOwnerSay ("Name stored as ==" + msg); } } timer() { llListenRemove( lkey ); llListenRemove( lkey2); llSetTimerEvent( 0 ); } }
Sorry if it looks completely screwed up anywhere. This is taking me to a whole nother level in scripting.
|
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
09-19-2006 16:32
Well, msg should be message, since that's what you called it in the listen(...) handler. Other than that, you looks like you're on the right track. So... llSetObjectName(message);
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
Woot!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
09-19-2006 19:29
heehee I was just dancing around the living room. I know for many of you all this stuff makes sense. But as for me, well know I now why they call it Linden Scripting LANGUAGE. It is all a foreign language to me. It took me about 5 hours to get this hammered into my head. Anyways I wanted to thank Bosozoku for helping so much. Ziggy, message was part of it but there were still more problems. But still pointing out the part about "message" still set me on right track. I kept running into trouble and then thought of putting the chat input part into a seperate function. Once it worked like that then I was able to streamline it by lumping position in with the name. Here is my finished code and it works exactly like I wanted. If anyone has any suggestions to clean it up better then please chip in. integer lkey; integer lkey2;
default { touch_start (integer total_number) { if ( llDetectedKey(0) == llGetOwner() ) { lkey = llListen( 8192, "",llGetOwner(),"" ); lkey2 = llListen(0,"",llGetOwner(),""); llSetTimerEvent( 60 ); llDialog( llGetOwner(), "Object Options:", [ "name & pos"],8192); } } listen ( integer ch, string nm, key id, string message ) { llListenRemove( lkey ); if (message == "name & pos") { llOwnerSay ("What do you want to name me?"); state nameme; } } timer() { llListenRemove( lkey ); llListenRemove( lkey2); llSetTimerEvent( 0 ); } } state nameme { state_entry() { llListen(0,"",llGetOwner(),""); } listen(integer chan, string name, key id, string message) { llSetObjectName((string) message); llOwnerSay ("Name stored as ==" + message); llSetObjectDesc( (string)llGetRootPosition() ); llOwnerSay ( "Position stored as " + llGetObjectDesc() ); llRemoveInventory( llGetScriptName() ); } }
|
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
09-20-2006 09:56
Cleanup suggestions... doing both in one step is a good idea. But now you have a dialog box menu with only one option. So basically, the person touches the object, gets a menu with one option, touches the menu, and the object does what it needs to. Why do you ned the menu? You can now do the work on the first touch. You needed the menu earlier, since you had 2 separate actions that could be performed. Does that make sense? So here's what I'm talking about: integer lkey2;
default { touch_start (integer total_number) { if ( llDetectedKey(0) == llGetOwner() ) { lkey2 = llListen(0,"",llGetOwner(),""); llOwnerSay ("What do you want to name me?"); llSetTimerEvent( 60 ); } }
listen ( integer ch, string nm, key id, string message ) { llSetObjectName((string) message); llOwnerSay ("Name stored as ==" + message); llSetObjectDesc( (string)llGetRootPosition() ); llOwnerSay ( "Position stored as " + llGetObjectDesc() ); llRemoveInventory( llGetScriptName() ); }
timer() { llOwnerSay("Timed out waiting for name. Touch again to restart."); llListenRemove( lkey2); llSetTimerEvent( 0 ); } }
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
09-20-2006 21:57
Thank you Ziggy. As soon as I tried it and it worked then I immediately saw that there was no need for the menu in it's new combined form and was going to slim it down some more. But it was still good practice anyway learning to work with the menu. It worked out perfect for my next project which uses a menu along with keyboard imput.
Heehee but it also involves lists and that is what I am learning now. Sloooooooooowy getting there.
Again, thanks to both of you for the help!!!!!!!!!!!!!!!!
|