Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Dispenser Sim-wide dispenser  

Sim-wide dispenser

Sim wide dispenser from a central prim

Category: Dispenser
By : Ferd Frederix
Created: 2013-09-06 Edited: 2013-09-04
Worlds: Second Life

the Zip file

Download all files for Sim-wide dispenser
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Dispenser.lsl
Get file # 2. Server Script.lsl

This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 // remote dispenser/sign
3 // 7/23/2013 Modified for OpenSim-type string handling
4
5 integer debug = FALSE;
6
7 // Change these channels to something that only you know in the client and the server. Pick a large, negative number less than 2 billion or so.
8
9 integer talkback = -99291;
10 integer talktoserver = -99290;
11
12
13 integer listener;
14
15 key avatar = NULL_KEY;
16 string desc;
17 integer gPrice;
18
19 // give the item to a customer
20 dispense(key toWhom, string item, string avatar, integer amt)
21 {
22 llOwnerSay("Sold|" + GetObjectDesc() + "|" + (string) toWhom + "|" + avatar + "|" + (string) amt);
23 llRegionSay(talktoserver,"Sold|" + GetObjectDesc() + "|" + (string) toWhom + "|" + avatar + "|" + (string) amt); // bought
24 }
25
26 string GetObjectDesc()
27 {
28 if(debug) {
29 llOwnerSay("Debug is on, always using the first item");
30 return "0";
31 }
32 else
33 return llGetObjectDesc();
34 }
35
36 default
37 {
39 {
40 listener = llListen(talkback,"","","");
42 if(debug) llOwnerSay("Describe|" + GetObjectDesc() );
43 llRegionSay(talktoserver,"Describe|" + GetObjectDesc() );
44 }
45
46 touch_end(integer total_number)
47 {
48 // if someone touches object describe what's for sale
49 listener = llListen(talkback,"","","");
50 if(debug) llOwnerSay("Describe|" + GetObjectDesc() );
51 llRegionSay(talktoserver,"Describe|" + GetObjectDesc());
52 avatar = llDetectedKey(0);
53 }
54
55 listen( integer channel, string name, key id, string message )
56 {
57 if(debug) llOwnerSay("Dispenser heard " + message);
58
59 list result = llParseString2List(message,["|"],[""]);
60
61 key akey = (key) llList2String(result,0);
62
63 if(debug) llOwnerSay("Dispenser found key " + akey);
64 if(akey == llGetKey())
65 {
66 string command = llList2String(result,1);
67
68 if(command == "texture")
69 llSetTexture(llList2String(result,2),0); // side 0
70 else if(command == "say")
71 desc = llList2String(result,2);
72 else if(command == "price")
73 {
74 gPrice = (integer) llList2String(result,2);
75 llSetPayPrice(gPrice, [gPrice, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
76 if(debug) llOwnerSay("Setting Pay Price of " + (string) gPrice);
77
78 if(avatar != NULL_KEY)
79 llInstantMessage(avatar,desc + ", only " + (string) gPrice + " dollars");
80
81 llListenRemove(listener);
82 }
83 }
84
85
86
87 }
88
89 money(key id, integer amt)
90 {
91 if(amt >= gPrice)
92 {
93 // customer has given us at least enough money
94 amt -= gPrice;
95 string name = llKey2Name(id);
96 string item = GetObjectDesc();
97 dispense(id, item, name, gPrice);
98 }
99 if(amt > 0) // give back change
100 {
101 llInstantMessage(id,"Oops,you overpaid!. Refunding " + (string) amt);
102 llGiveMoney(id, amt);
103 }
104 }
105 }

Sim-wide dispenser

Sim wide dispenser from one box

Category: Dispenser
By : Ferd Frederix
Created: 2013-09-06 Edited: 2013-09-04
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 // Server Prim
3 // 7/23/2013 Modified for OpenSim-type string handling
4 // Change these channels to something that only you know in the client and the server. Pick a large, negative number less than 2 billion or so.
5
6 integer talkback = -99291;
7 integer talktoserver = -99290;
8
9
10 integer debug = FALSE;
11
12 integer listener;
13
14 string left(string src, string divider) {
15 integer index = llSubStringIndex( src, divider );
16 if(~index)
17 return llDeleteSubString( src, index , -1);
18 return src;
19 }
20
21 string right(string src, string divider) {
22 integer index = llSubStringIndex( src, divider );
23 if(~index)
24 return llDeleteSubString( src, 0, index + llStringLength(divider) - 1);
25 return src;
26 }
27
28
29
30 default
31 {
33 {
34 listener = llListen(talktoserver,"","","");
35 llRegionSay(talktoserver,"Describe|" + llGetObjectDesc() );
36 }
37
38
39
40 listen( integer channel, string name, key id, string message )
41 {
42 if(debug) llOwnerSay("heard " + message);
43
44 list result = llParseString2List(message,["|"],[""]);
45 string command = llList2String(result,0);
46
47 if(command == "Describe")
48 {
49 integer number = (integer) llList2String(result,1);
51
52 key texturekey = llGetInventoryKey(name1);
53
54 llRegionSay(talkback,(string) id +"|texture|" + (string) texturekey);
55
56 string price = right(name1,",");
57 name1 = left(name1,",");
58 llRegionSay(talkback,(string) id+"|say|" + name1);
59 llRegionSay(talkback,(string) id+"|price|" + price);
60
61 }
62
63 if(command == "Sold")
64 {
65 llOwnerSay("Sold");
66 integer number = (integer) llList2String(result,1);
67 string skey = llList2String(result,2);
68 string sname = llList2String(result,3);
69 string samt = llList2String(result,4);
71 llGiveInventory((key) skey,name2);
72 llInstantMessage(llGetOwner(),sname + " bought " + name2 + " for $" + samt);
73
74 }
75
76
77 }
78
79 }

Back to the Best Free Tools in Second Life and OpenSim.