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 Opensim version of Dispenser  

Opensim version of Dispenser

A dispenser fo items on a sim

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

the Zip file

Download all files for Opensim version of Dispenser
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. remote.lsl
Get file # 2. server.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
4 integer debug = 0;
5
6 // 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.
7
8 integer talkback = -99291;
9 integer talktoserver = -99290;
10
11
12 integer listener;
13
14 key avatar = NULL_KEY;
15 string desc;
16 integer gPrice;
17
18 // give the item to a customer
19 dispense(key toWhom, string item, string avatar, integer amt)
20 {
21 llRegionSay(talktoserver,"Sold|" + llGetObjectDesc() + "|" + (string) toWhom + "|" + avatar + "|" + (string) amt); // bought
22 }
23
24 default
25 {
27 {
28 listener = llListen(talkback,"","","");
30
31 llRegionSay(talktoserver,"Describe|" + llGetObjectDesc() );
32 }
33
34 touch_end(integer total_number)
35 {
36 // if someone touches object describe what's for sale
37 listener = llListen(talkback,"","","");
38 llRegionSay(talktoserver,"Describe|" + llGetObjectDesc());
39 avatar = llDetectedKey(0);
40 }
41
42 listen( integer channel, string name, key id, string message )
43 {
44 if(debug) llOwnerSay("heard " + message);
45
46 list result = llParseString2List(message,["|"],[""]);
47 string command = llList2String(result,0);
48
49 if(command == "texture")
50 llSetTexture(llList2String(result,1),0); // side 0
51 else if(command == "say")
52 desc = llList2String(result,1);
53 else if(command == "price")
54 {
55 gPrice = llList2Integer(result,1);
56 llSetPayPrice(gPrice, [gPrice, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
57
58 if(avatar != NULL_KEY)
59 llInstantMessage(avatar,desc + ", only " + (string) gPrice + " dollars");
60
61 llListenRemove(listener);
62 }
63
64
65
66
67 }
68
69 money(key id, integer amt)
70 {
71 if(amt >= gPrice)
72 {
73 // customer has given us at least enough money
74 amt -= gPrice;
75 string name = llKey2Name(id);
76 string item = llGetObjectDesc();
77 dispense(id, item, name, gPrice);
78 }
79 if(amt > 0) // give back change
80 {
81 llInstantMessage(id,"Oops,you overpaid!. Refunding " + (string) amt);
82 llGiveMoney(id, amt);
83 }
84 }
85 }

Opensim version of Dispenser

Opensim version

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
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 = 0;
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 // give the item to a customer
29 dispense(key toWhom,string name)
30 {
31 llGiveInventory(toWhom,name);
32 }
33
34
35
36 default
37 {
39 {
40 listener = llListen(talktoserver,"","","");
41
42 llRegionSay(talktoserver,"Describe|" + llGetObjectDesc() );
43 }
44
45 touch_end(integer total_number)
46 {
47 // if someone touches object describe what's for sale
48 listener = llListen(talkback,"","","");
49 llRegionSay(talktoserver,"Describe|" + llGetObjectDesc());
50 }
51
52 listen( integer channel, string name, key id, string message )
53 {
54 if(debug) llOwnerSay("heard " + message);
55
56 list result = llParseString2List(message,["|"],[""]);
57 string command = llList2String(result,0);
58
59 if(command == "Describe")
60 {
61 integer number = llList2Integer(result,1);
63 key texturekey = llGetInventoryKey(name1);
64 llRegionSay(talkback,"texture|" + (string) texturekey);
65
66 string price = right(name,",");
67 name1 = left(name1,",");
68 llRegionSay(talkback,"say|" + name1);
69 llRegionSay(talkback,"price|" + price);
70
71 }
72
73 if(command == "Sold")
74 {
75 llOwnerSay("Sold");
76 integer number = llList2Integer(result,1);
77 string skey = llList2String(result,2);
78 string sname = llList2String(result,3);
79 string samt = llList2String(result,4);
81 llGiveInventory((key) skey,name2);
82 llInstantMessage(llGetOwner(),sname + " bought " + name2 + " for $" + samt);
83
84 }
85
86
87 }
88
89 }

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