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
Gambling Gambling_Engine  

Gambling_Engine

Gambling Engine.lsl

Category: Gambling
By : Hank Ramos
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Gambling_Engine
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Gambling_Engine_1.lsl
1
2 1//Gambling Machine
3 //State Example
4 //by Hank Ramos
5 key playerID;
6 string lastWinner = "None";
7 integer potValue = 50;
8 float odds = 0.905; //Valid values are 0.50 to 0.99.
9 integer moneyIn;
10 integer moneyOut;
11 integer counter;
12 integer maxLosses = 250;
13
14 display(string text)
15 {
16 llSetText(text, <1,1,1>, 1);
17 }
18
19 default
20 {
22 {
23 //Do some initialization here
25 }
26 run_time_permissions(integer permissions)
27 {
28 //Only wait for payment if the owner agreed to pay out money
29 if(permissions)
30 {
31 llSay(0, "Initailized Successfully...");
32 state waiting;
33 }
34 }
35 }
36 state broken
37 {
39 {
40 display("Machine Malfunction. Please Contact Owner");
41 }
42 touch_start(integer num_detected)
43 {
45 {
46 llSay(0, "Resuming...");
47 maxLosses += 50;
48 state waiting;
49 }
50 }
51 }
52 state waiting
53 {
55 {
56 string oddsString;
57
58 oddsString = "1:" + (string)llRound(1/(1-odds));
59
60 llSetColor(<0,0,1>, ALL_SIDES);
61 display("Current Pot: L$" + (string)potValue + "\nPay L$10 to Play!\nOdds " + oddsString + "\nLast Winner: " + lastWinner);
62
63 if((moneyOut - moneyIn) > maxLosses)
64 {
65 state broken;
66 }
67 //llSetTimerEvent(300);
68 }
69 money(key id, integer amount)
70 {
71 if(amount == 10)
72 {
73 playerID = id;
74 moneyIn += amount;
75 state playing;
76 }
77 else
78 {
79 llSay(0, "You must pay L$10 to play. Refunding Money...");
80 llGiveMoney(id, amount);
81 }
82 }
83 touch_start(integer num_detected)
84 {
86 {
87 llSay(0, "L$ Collected: " + (string)moneyIn);
88 llSay(0, "L$ Dispensed: " + (string)moneyOut);
89 }
90 }
91 timer()
92 {
93 //llSay(0, "Play to Win! Only L$10 per play! Current Pot is L$" + (string)potValue + "!");
94 }
95 }
96
97 state playing
98 {
100 {
101 counter = 0;
102 display("Randomizing...");
103 llLoopSound("Cosmic", 1);
104 llSetTimerEvent(0.1);
105 }
106 timer()
107 {
108 counter += 1;
110 if(counter >= 80)
111 {
114 if(llFrand(1) >= odds)
115 {
116 state winner;
117 }
118 else
119 {
120 state loser;
121 }
122 }
123 }
124 }
125
126 state winner
127 {
129 {
130 display("You won L$" + (string)potValue + "!");
131 lastWinner = llKey2Name(playerID) + " L$" + (string)potValue;
132 llSetColor(<0,1,0>, ALL_SIDES);
133 llGiveMoney(playerID, potValue);
134 moneyOut += potValue;
135 potValue = 50;
136 llSleep(5);
137 state waiting;
138 }
139 }
140
141 state loser
142 {
144 {
145 display("Sorry, better luck next time...");
146 llSetColor(<1,0,0>, ALL_SIDES);
147 potValue += 4;
148 llSleep(5);
149 state waiting;
150 }
151 }
152 // END //

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