1
0

KanEd-Test11.lsl 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. integer dialog_channel= 427; // set a dialog channel
  2. list menu = [ "Go up", "Go down" ];
  3. vector startPosition;
  4. float groundLevel;
  5. default
  6. {
  7. state_entry()
  8. {
  9. // arrange to listen for dialog answers (from multiple users)
  10. llListen( dialog_channel, "", NULL_KEY, "");
  11. startPosition = llGetPos();
  12. groundLevel = llGround( startPosition );
  13. }
  14. touch_start(integer total_number)
  15. {
  16. llDialog( llDetectedKey( 0 ), "What do you want to do?", menu,
  17. dialog_channel );
  18. }
  19. listen(integer channel, string name, key id, string choice )
  20. {
  21. vector position = llGetPos();
  22. // if a valid choice was made, implement that choice if possible.
  23. // (llListFindList returns -1 if choice is not in the menu list.)
  24. if ( llListFindList( menu, [ choice ]) != -1 )
  25. {
  26. if ( choice == "Go up" )
  27. {
  28. if( position.z < ( startPosition.z + 10.0 ) )
  29. {
  30. llSetPos( llGetPos() + < 0, 0, 1.0 > ); // move up
  31. }
  32. }
  33. else if( choice == "Go down" )
  34. {
  35. if( position.z > ( groundLevel + 1.0 ) )
  36. {
  37. llSetPos( llGetPos() + < 0, 0, -1.0 > ); // move down
  38. }
  39. }
  40. }
  41. else
  42. {
  43. llSay( 0, "Invalid choice: " + choice );
  44. }
  45. }
  46. }