Beer Drink Script.lsl 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // :SHOW:
  2. // :CATEGORY:Drink
  3. // :NAME:Beer Drinking
  4. // :AUTHOR:Ferd Frederix
  5. // :KEYWORDS:
  6. // :CREATED:2015-05-29 12:25:47
  7. // :EDITED:2015-05-29 11:25:47
  8. // :ID:87
  9. // :NUM:116
  10. // :REV:1.1
  11. // :WORLD:Second Life, Opensim
  12. // :DESCRIPTION:
  13. // Drink Script - makes it seem like beer is being drunk
  14. // :CODE:
  15. //: LICENSE: CC-0 (Open Source)
  16. //: DESCRIPTION:
  17. // 1) Make a cylinder and a glass, lets say, of beer. Texture the cylinder to look like the beer liquid - mostly brown, with white foam at one end, and put white on the top of the cylinder. Put this cylinder inside the beer glass. Or make a tapered cylinder and and fit it into another glass.
  18. // 2) Link the glass and any other prims to the beer cylinder. The cylinder need to be the last thing clicked to make it the root prim.
  19. // This script currently requires there be AT LEAST 2 prims. Otherwise LINKNUM must be a 0 for a single prim, or the number of the prim that is the beer prim.
  20. // 3) Add the script below to the root prim. When reset, the beer should dissappear, and appear to fill back up.
  21. // 4) type this in chat:
  22. // /942 Drink
  23. // The beer will decrease by 10% rthwn empty, it shudl announce with a whsiper that "XX, your glass is empty."
  24. // globals
  25. float drink_left;
  26. integer LINKNUM = 1; // Assumes that the cylinder that is being drunk is the root prim.
  27. string DECREASE_FOOD = "Drink";
  28. float X = 1.0;
  29. float Y = 1.0;
  30. float Z = 1.0; // the length of the cylinder
  31. fill()
  32. {
  33. float i = 0 ;
  34. //loop around cutting the length to fuill
  35. while (i < Z)
  36. {
  37. llSetLinkPrimitiveParamsFast(LINKNUM,[PRIM_SLICE, <0, i,0>]);
  38. llSleep(.1);
  39. i += .020 ; // ad 1/10 of a Z each loop
  40. }
  41. drink_left = 1; // 100%
  42. }
  43. drink()
  44. {
  45. drink_left = drink_left - 0.1;
  46. llSetLinkPrimitiveParamsFast(LINKNUM,[PRIM_SLICE, <0, drink_left,0>]);
  47. if (drink_left <= 0)
  48. {
  49. drink_left = 0;
  50. llWhisper(0,llKey2Name(llGetOwner()) + " your glass is empty.");
  51. return;
  52. }
  53. }
  54. default
  55. {
  56. state_entry()
  57. {
  58. // set to empty, then fill it
  59. llSetLinkPrimitiveParamsFast(LINKNUM,[PRIM_SLICE, <0, 0,0>]);
  60. fill();
  61. llListen(942,"","","");
  62. }
  63. listen(integer channel, string name, key id, string message)
  64. {
  65. if (message == DECREASE_FOOD)
  66. {
  67. drink();
  68. }
  69. }
  70. }