Join us in Phaze Demesnes

LSL Script Library Home   Add a script Show All
Category: Contributor: Description
Animation Vendor Ariane Brodie A animation Vendor
TWO-BUTTON ANIMATION VENDOR
Original script by Thili Playfair
Heavily Modified by Karandas Banjo
Radically modified by Ariane Brodie who converted the texture vendor into an animation vendor script
The Script

Download this script - Please use this link to get this script. If you see all the code on one long line, please use Wordpad or another editor, such as LSLEdit.exe. The .LSL file you will download is an ordinary text file.

1 // TWO-BUTTON ANIMATION VENDOR
2 // Origional script by Thili Playfair
3 // Heavily Modified by Karandas Banjo
4 // Radically modified by Ariane Brodie who converted the texture vendor into an animation vendor script
5 // Please include these names if you modify or
6 // re-distribute this code ^_^
7
8 // To set up your vendor, you will need at least 3 prims,
9 // the main prim, and two buttons.
10
11 // The two buttons must both be linked to the main prim,
12 // one must be called "next", the other called "prev".
13 // The Buttons do NOT need any script if you name them as shown above.
14
15 // Next, enter the price of the animations in this vendor,
16 // and if you want, time to wait for auto-scrolling.
17
18 // After that, just drop your animations into the main prim,
19 // and press one of the scroll buttons, and you're ready
20 // to go!
21
22 integer price = 10; // The price of any animation in this
23 // vendor.
24 // Added touch-giving for when price is set to L$0
25
26
27 float time = 0; // Enter a value if you want time based
28 // scrolling otherwise set to zero.
29
30 // NO TOUCHY BELOW HERE
31
32 string vendorname;
33 integer total;
34 integer counter;
35 integer change;
36 integer anim_on = FALSE;
37 string curranim;
38 string lastanim;
39 vector offset=<0,0,1.0>;
40 key avatar;
41
42 next()
43 {
45 vendorname = llGetObjectName();
46 counter++;
47 if(counter>=total)
48 {
49 counter=0;
50 }
51 lastanim = curranim;
52 curranim = llGetInventoryName(INVENTORY_ANIMATION, counter);
53 if (price > 0)
54 {
55 llSetText(vendorname + "\n" + llGetInventoryName(INVENTORY_ANIMATION, counter) + "\nPay base L$" + (string)price + " to buy", <1,1,1>, 1);
56 }
57 else
58 {
59 llSetText(vendorname + "\n" + llGetInventoryName(INVENTORY_ANIMATION, counter) + "\n Touch to recieve", <1,1,1>, 1);
60 }
61
62 if (anim_on) {
63 llStopAnimation(lastanim);
64 llStartAnimation(curranim);
65 }
66 }
67 prev()
68 {
70 vendorname = llGetObjectName();
71 if (counter > 0)
72 {
73 counter--;
74 }
75 else
76 {
77 counter=total - 1;
78 }
79 lastanim = curranim;
80 curranim = llGetInventoryName(INVENTORY_ANIMATION, counter);
81 if (price > 0)
82 {
83 llSetText(vendorname + "\n" + llGetInventoryName(INVENTORY_ANIMATION, counter) + "\nPay base L$" + (string)price + " to buy", <1,1,1>, 1);
84 }
85 else
86 {
87 llSetText(vendorname + "\n" + llGetInventoryName(INVENTORY_ANIMATION, counter) + "\n Touch to recieve \n", <1,1,1>, 1);
88 }
89
90 if (anim_on) {
91 llStopAnimation(lastanim);
92 llStartAnimation(curranim);
93 }
94 }
95
96 default
97 {
99 {
100 rotation rot = llEuler2Rot(<0,0,PI>);
101 llSetSitText("Animate");
102 llSitTarget(offset,rot);
103 llSetCameraAtOffset(<0.0,0.0,1.0>);
104 llSetCameraEyeOffset(<-4.0,0.0,1.0>);
106 next();
107 llSetTimerEvent(time);
108 }
109
110 touch_start(integer total_number)
111 {
112 if ( llGetLinkName(llDetectedLinkNumber(0)) == "next" )
113 {
114 next();
115 }
116 else if ( llGetLinkName(llDetectedLinkNumber(0)) == "prev" )
117 {
118 prev();
119 }
120 else
121 {
122 if (price > 0)
123 {
124 llWhisper(0, "Right click and Animate to try, Pay L$" + (string)price + " to buy");
125 }
126 else
127 {
129 }
130 }
131 }
132
133 timer()
134 {
135 next();
136 }
137
138 money(key giver, integer amount)
139 {
140 if (amount < price)
141 {
142 llSay(0, "Too little payed, refunding");
143 llGiveMoney(giver, amount);
144 }
145 else if (amount > price)
146 {
147 change = amount - price;
148 llSay(0, "Overpaid. vending item and giving L$" + (string)change + " change");
149 llGiveMoney(giver, change);
151 llInstantMessage(llGetOwner(), llKey2Name(giver) + " bought " + llGetInventoryName(INVENTORY_ANIMATION, counter) + " for L$" + (string)price);
152 }
153 else if (amount == price)
154 {
156 llInstantMessage(llGetOwner(), llKey2Name(giver) + " bought " + llGetInventoryName(INVENTORY_ANIMATION, counter) + " for L$" + (string)price);
157 }
158 }
159
160 on_rez(integer start_param)
161 {
163 }
164
165 changed(integer change)
166 {
167 if(change == CHANGED_LINK)
168 {
169 avatar = llAvatarOnSitTarget();
170 if(avatar != NULL_KEY)
171 {
173 }
174 else
175 {
176 if (llGetPermissionsKey() != NULL_KEY) {
177 llStopAnimation(curranim);
178 anim_on = FALSE;
179 }
180 }
181 }
182 }
183
185 {
187 {
188 llStopAnimation("sit");
189 llStartAnimation(curranim);
190 anim_on = TRUE;
191 }
192 }
193 }