Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llDialog

Shippou Oud
The Fox Within
Join date: 11 Jul 2005
Posts: 141
02-17-2007 20:44
The problems with the script is it will not print out what the values of the strings and integers I put into it, How can I fix this to were it displays the values/items correctly, and does not cspit out blanks?
The script works, but is not compleated yet.
From: someone

list null= ["OK"];
string name = "The Green Machine";
string f1 = " banana ";
string f2 = " cherry ";
string f3 = " apple ";
integer cha;
integer f1a = 15;
integer f2a = 25;
integer f3a = 35;
string LP;
integer JP;
default
{
state_entry()
{
cha = (integer) llFrand(999999998) + 1;
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
llSetPayPrice(PAY_HIDE, [10, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
JP = 1000;
llSetText(name +" \n Last Player: " + LP + "\n Jack Pot $L" + (string) JP,<0,1,0>,1);
}

touch_start(integer total_number)
{
llInstantMessage(llDetectedKey(0),"Current Pay outs are 3 " + f1 + (string) f1a + " , 3 " + f2 + (string) f2a + " , 3 " + f3 + (string) f3a + " . Only $L10 to play";);
}
money(key play, integer mon)
{
JP = JP + 1;
string w1;
string w2;
string w3;
float win;
integer a1 = (integer) llFrand(3) + 1;
if (a1 == 1)
{
string w1 = f1;
win = win + 1.1;
}
if (a1 == 2)
{
string w1 = f2;
win = win + 5.5;
}
if (a1 == 3)
{
string w1 = f3;
win = win + 10.9;
}
integer a2 = (integer) llFrand(3) + 1;
if (a2 == 1)
{
string w2 = f1;
win = win + 1.1;
}
if (a2 == 2)
{
string w2 = f2;
win = win + 5.5;
}
if (a2 == 3)
{
string w2 = f3;
win = win + 10.9;
}
integer a3 = (integer) llFrand(3) + 1;
if (a3 == 1)
{
string w3 = f1;
win = win + 1.1;
}
if (a3 == 2)
{
string w3 = f2;
win = win + 5.5;
}
if (a3 == 3)
{
string w3 = f3;
win = win + 10.9;
}
integer ww = (integer) llFrand(5) + 1;
integer ww1 = (integer) llFrand(5) + 1;
integer wmu = (integer) llFrand(25) + 1;
integer wmu1 = (integer) llFrand(25) + 1;
LP = llKey2Name(play);
llInstantMessage(play,"Thank you " + LP + " . Good luck";);
llDialog( play , " " + w1 + w2 + w3, null ,cha);
if (ww == ww1)
{
llDialog( play ,"You Won $L5", null ,cha);
llGiveMoney(play,5);
}
if (win == 3.3)
{

llDialog( play ,"You Won $L" + (string) f1a, null ,cha);
llGiveMoney(play, f1a);
}
if (win == 16.5)
{

llDialog( play ,"You Won $L" + (string) f2a, null ,cha);
llGiveMoney(play, f2a);
}
if (win == 32.7)
{

llDialog( play ,"You Won $L" + (string) f3a, null ,cha);
llGiveMoney(play, f3a);
}
win = 0;
llSetText(name +" \n Last Player: " + LP + "\n Jack Pot $L" + (string) JP,<0,1,0>,1);
}
}
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
Needle in a Haystack!
02-18-2007 03:07
Firstly, let me reproduce the script so everyone can read it! :p

CODE
list null= ["OK"];
string name = "The Green Machine";
string f1 = " banana ";
string f2 = " cherry ";
string f3 = " apple ";
integer cha;
integer f1a = 15;
integer f2a = 25;
integer f3a = 35;
string LP;
integer JP;

default
{

state_entry()
{
cha = (integer) llFrand(999999998) + 1;
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
llSetPayPrice(PAY_HIDE, [10, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
JP = 1000;
llSetText(name +" \n Last Player: " + LP + "\n Jack Pot $L" + (string) JP,<0,1,0>,1);
}

touch_start(integer total_number)
{
llInstantMessage(llDetectedKey(0),"Current Pay outs are 3 " + f1 + (string) f1a + " , 3 " + f2 + (string) f2a + " , 3 " + f3 + (string) f3a + " . Only $L10 to play");
}

money(key play, integer mon)
{
JP = JP + 1;
string w1;
string w2;
string w3;
float win;

integer a1 = (integer) llFrand(3) + 1;
if (a1 == 1)
{
string w1 = f1;
win = win + 1.1;
}
if (a1 == 2)
{
string w1 = f2;
win = win + 5.5;
}
if (a1 == 3)
{
string w1 = f3;
win = win + 10.9;
}

integer a2 = (integer) llFrand(3) + 1;
if (a2 == 1)
{
string w2 = f1;
win = win + 1.1;
}
if (a2 == 2)
{
string w2 = f2;
win = win + 5.5;
}
if (a2 == 3)
{
string w2 = f3;
win = win + 10.9;
}

integer a3 = (integer) llFrand(3) + 1;
if (a3 == 1)
{
string w3 = f1;
win = win + 1.1;
}
if (a3 == 2)
{
string w3 = f2;
win = win + 5.5;
}
if (a3 == 3)
{
string w3 = f3;
win = win + 10.9;
}

integer ww = (integer) llFrand(5) + 1;
integer ww1 = (integer) llFrand(5) + 1;
integer wmu = (integer) llFrand(25) + 1;
integer wmu1 = (integer) llFrand(25) + 1;
LP = llKey2Name(play);
llInstantMessage(play,"Thank you " + LP + " . Good luck");
llDialog( play , " " + w1 + w2 + w3, null ,cha);

if (ww == ww1)
{
llDialog( play ,"You Won $L5", null ,cha);
llGiveMoney(play,5);
}
if (win == 3.3)
{
llDialog( play ,"You Won $L" + (string) f1a, null ,cha);
llGiveMoney(play, f1a);
}
if (win == 16.5)
{
llDialog( play ,"You Won $L" + (string) f2a, null ,cha);
llGiveMoney(play, f2a);
}
if (win == 32.7)
{
llDialog( play ,"You Won $L" + (string) f3a, null ,cha);
llGiveMoney(play, f3a);
}

win = 0;
llSetText(name +" \n Last Player: " + LP + "\n Jack Pot $L" + (string) JP,<0,1,0>,1);
}
}
I think your problem is that you keep declaring the same variables over and over... string w1, string w2, etc.

I'd suggest that you carefully declare your variables, once only, at the beginning of the Event. Every time you put string variable between braces {}, you are in effect declaring a new variable that exists just in the scope of those braces.

I suspect other people can suggest other things about the code but I'll give you just one...

CODE
a1 = (integer) llFrand(3) + 1;

if (a1 == 1)
{
w1 = f1; // remember, do not declare the variable here
win = win + 1.1;
}
else if (a1 == 2)
{
w1 = f2; // or here
win = win + 5.5;
}
else if (a1 == 3)
{
w1 = f3; // and not here either :)
win = win + 10.9;
}
Where ifs are mutually exclusive else if will speed things up.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-18-2007 03:34
You are declaring strings w1, w2 and w3 twice.
And Use else if's where appropriate.

EDIT:Pale once again beats me to the post!
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
02-18-2007 03:55
hehe... you had like, since 5am this morning. :p
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-18-2007 05:23
From: Pale Spectre
hehe... you had like, since 5am this morning. :p


Yeah Well I sleep :),
Actually there is soemthing weird though, your post didnt show up when I first looked at the OP hence my reply and yet I didnt take that long to type it!
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
02-18-2007 14:05
From: Pale Spectre
Where ifs are mutually exclusive else if will speed things up.


yea that if tree almost made me cry :)
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-18-2007 15:07
From: Osgeld Barmy
yea that if tree almost made me cry :)



Just Glad Osgeld and Jesse didnt see it.....
Shippou Oud
The Fox Within
Join date: 11 Jul 2005
Posts: 141
02-18-2007 21:57
thanks. Something so simple can cause so many problems.