Advertisement
Gayngel

Switch Statement

Oct 1st, 2021
1,878
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. list haystack = ["tomato","Tomatoes are L$0.49","lime","Limes are L$1.49","papaya", "Papayas are $1.29"];
  2.  
  3.  
  4. string switch(string needle)
  5. {
  6.  
  7. needle = llToLower(needle);
  8.  
  9. integer idx = llListFindList(haystack,[needle]);
  10. if( idx != -1)
  11. {
  12.   return llList2String(haystack, idx + 1);
  13. }
  14.  
  15. else
  16. return "Invalid item";
  17.  
  18. }
  19.  
  20.  
  21. default;
  22. {
  23.  
  24.    touch_end()
  25.    {
  26.      
  27.     key Toucher = llDetectedKey();
  28.     string link_name = llGetLinkName(llDetectedLinkNumber(0));
  29.        
  30.     llRegionSayTo(Toucher,0, switch(link_name));
  31.  
  32.    }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement