Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

After a resident payed my object i want to skip the "touch" process

Tomfox Wiranata
Registered User
Join date: 20 Dec 2006
Posts: 80
02-01-2007 07:14
Hi everyone....

After a resident payed my object he has to touch it again to make the process start. I wanna skip the touch-part and let it start right after he payed. my code so far:


Here is a part of my script. hope it is all you need...
CODE



default
{
state_entry()
{
//llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
state idle;
}
}







state idle
{
state_entry()
{
resetParameters();
llSetPayPrice(PAY_HIDE,[15,30,45,60]);
}


money(key giver, integer amount)
{

integer ch = ChannelFromName(name);
currentUser = giver;

state payed;
}


state_exit()
{

llSetTimerEvent(30);
}



}


state payed
{

state_entry()
{

currentUser = llDetectedKey(0);
}


touch_start(integer total_number)
{
timestamp = llGetTimestamp();
touched(llDetectedKey(0));
}


listen(integer channel, string name, key id, string message)
{
...........
}
}//end state payed




touched(key toucher)
{
if (currentUser == toucher || currentUser == NULL_KEY)
{
llSetTimerEvent(0);
llInstantMessage(toucher,"You are the current user of this terminal");
currentUser = toucher;
llSetTimerEvent(300);
name = llDetectedName(0);
integer ch = ChannelFromName(name);

llListen(ch,"",currentUser,"");
//llDialog(toucher, "Navigate through the dialogs to pick numbers ", start, ch);
llDialog(toucher, "Quick Tip OR Manual Choice ?", QT_MAN,ch);
}

else
{
llInstantMessage(toucher,"This system is already in use. Please use another terminal.");
}

}



I tried to call the touched function within the money() event and wanted to pass the variable "giver" to the touched() function for further listen actions. Problems with that:

- invalid key passed to IM
- listen event did not work...


thank u so much for ur help....

best regards
Edison Swain
Registered User
Join date: 7 Dec 2006
Posts: 51
02-01-2007 08:29
Hi Tomfox,

It looks like you are storing the key of the person who paid you in a global variable called currentUser. If that's the case, then I think you can probably just called the touched() function you have written in the state_entry() event in the state payed by using:

touched(currentUser);
Baron Hauptmann
Just Designs / Scripter
Join date: 29 Oct 2005
Posts: 358
02-01-2007 09:40
. . . like Edison said, and get rid of currentUser = llDetectedKey in state_entry in Payed state. llDetectedKey means nothing outside of an event in which it detects something (like touch). And it will either error there or reset your value. Oh, and PHP tags rather than CODE tags will clean things up even more!

So try:

CODE

default
{
state_entry()
{
//llRequestPermissions(llGetOwner(),PERMISSION_DEBIT );
state idle;
}
}







state idle
{
state_entry()
{
resetParameters();
llSetPayPrice(PAY_HIDE,[15,30,45,60]);
}


money(key giver, integer amount)
{

integer ch = ChannelFromName(name);
currentUser = giver;

state payed;
}


state_exit()
{

llSetTimerEvent(30);
}



}


state payed
{

state_entry()
{

//currentUser = llDetectedKey(0); --commented out, but just get rid of it!
touched(currentUser); //added the function call here
}


touch_start(integer total_number)
{
timestamp = llGetTimestamp();
touched(llDetectedKey(0));
}


listen(integer channel, string name, key id, string message)
{
...........
}
}//end state payed




touched(key toucher)
{
if (currentUser == toucher || currentUser == NULL_KEY)
{
llSetTimerEvent(0);
llInstantMessage(toucher,"You are the current user of this terminal");
currentUser = toucher;
llSetTimerEvent(300);
name = llDetectedName(0);
integer ch = ChannelFromName(name);

llListen(ch,"",currentUser,"");
//llDialog(toucher, "Navigate through the dialogs to pick numbers ", start, ch);
llDialog(toucher, "Quick Tip OR Manual Choice ?", QT_MAN,ch);
}

else
{
llInstantMessage(toucher,"This system is already in use. Please use another terminal.");
}

}


Baron H.
Tomfox Wiranata
Registered User
Join date: 20 Dec 2006
Posts: 80
02-01-2007 15:23
still do not work...gets until the first number u pick....u picked and no dialog shows ever again


CODE



touched(key toucher)
{
if (currentUser == toucher || currentUser == NULL_KEY)
{
llSetTimerEvent(0);
llInstantMessage(toucher,"You are the current user of this terminal");
currentUser = toucher;
llSetTimerEvent(300);
name = llDetectedName(0);
integer ch = ChannelFromName(name);

llListen(ch,"",currentUser,"");
//llDialog(toucher, "Navigate through the dialogs to pick numbers ", start, ch);
llDialog(toucher, "Quick Tip OR Manual Choice ?", QT_MAN,ch);
}

else
{
llInstantMessage(toucher,"This system is already in use. Please use another terminal.");
}

}



default
{
state_entry()
{
//llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
state idle;
}
}





state idle
{
state_entry()
{
resetParameters();
llSetText("",<1,0,0>,1);
llSetPayPrice(PAY_HIDE,[15,30,45,60]);
}


money(key giver, integer amount)
{

integer ch = ChannelFromName(name);

currentUser = giver;
refund = amount;
howlong = ((amount / 15) * 7);
draws = amount / 15;

llDialog(giver,"==========================\nPlease TOUCH the keyboard to pick your numbers.",receipt,ch);

state payed;
}


state_exit()
{

llSetTimerEvent(30);
}



}






state payed
{

state_entry()
{
touched(currentUser);
}


touch_start(integer total_number)
{
timestamp = llGetTimestamp();

}


listen(integer channel, string name, key id, string message)
{
integer ch = ChannelFromName(name);

if(message == "Manual")
llDialog(id, "Navigate through the dialogs to pick numbers ", start, ch);

if(message == "Quick Tip")
createQuickTip(id);



if(message == "1-11")
llDialog(id,"Navigate through the dialogs to pick numbers",PC__01_11,ch);

if(message == "Back")
llDialog(id,"Navigate through the dialogs to pick numbers",start,ch);

if(message == "...")
llDialog(id,"Navigate through the dialogs to pick numbers",start,ch);

if( message == "1" || message == "2" || message == "3" || message == "4")
........"TAKE NUMBER".................





Tiarnalalon Sismondi
Registered User
Join date: 1 Jun 2006
Posts: 402
02-02-2007 05:26
Ok, it's early and I have a headache so I only read through the parts of the code that you seem to be referencing...

state paid only gets called after the money event, meaning they've paid. If you're wanting to execute the code that the person is currently having to touch to get, then why not just put that in the state entry of paid?

But it looks like there's more issues at work here. It looks like you're setting a time limit based on how much they paid, and while I do not like this method, the best way I can think of to do this would be to use an integer and have it loop somehow, and have a timer set to turn this integer false when the time expires.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-02-2007 05:52
Tomfox,

The code posted is incomplete and rather badly laid out, try replacing all tabs with 4 spaces and reposting for easier reading.

And for god's sake use a few else if's!!!!! :)
Tomfox Wiranata
Registered User
Join date: 20 Dec 2006
Posts: 80
02-02-2007 13:04
the timer is for the refunding....if a player pays but does not play...he gets his money back...

@newgate:

yes it is. but i think i copied everything that is important :) sorry about the style....was late...


i will try it with putting all into state_entry of payed


thx
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-02-2007 14:46
Why do you have an empty state idle?

You cannot use a timer event inside a state_exit or rather it is pointless to do so as it will never fire since timers are automatically deleted on state change.

You recalculate ch inside the listen yet it does not appear to be used or necessary as it is teh same user stil being processed.

The code as it stands appears to be missing any connection between taking the first number and displaying a second dialog box?

Somewhere in the listen you should process each selection and then prompt for a second number or is it such that they have to touch the keyboard each time?

I would suggest that you have a counter which you increment each time they make a valid selection and redisplay the first numeric menu for them to select the second number.
You should also remove the chosen number from the available list unless duplicates are allowed.

You can reduce the string comparissons some what by defining all entries as as a list of commands and then performing a straight forward llListFindList and using the numeric result to decide what to do.

From an ergonomics point of view, the majority of people find it easier to 'see' numbers in blocks of 10, and it will make programming your dialog a lot easier!

CODE

list menuCommands = [ "Manual","Quick Tip","1-10", "11-20","21-30","31-40","41-50"];

listen(integer channel, string name, key id, string message)
{
integer ch = ChannelFromName(name);
integer comamnd = llListFindList(menuCommands, [ message ] );
if(command >= 0)
{
if(0 == command)
llDialog(id, "Navigate through the dialogs to pick numbers ", start, ch);
else if(1 == command)
createQuickTip(id);
else if(2 == command) ....
}
}


If you are unwilling or unable to do that for some reason then use else if!!!!

CODE


listen(integer channel, string name, key id, string message)
{
integer ch = ChannelFromName(name);

if(message == "Manual")
llDialog(id, "Navigate through the dialogs to pick numbers ", start, ch);
else if(message == "Quick Tip")
createQuickTip(id);
else if(message == "1-11")
llDialog(id,"Navigate through the dialogs to pick numbers",PC__01_11,ch);
else if(message == "Back")
llDialog(id,"Navigate through the dialogs to pick numbers",start,ch);
else if(message == "...")
llDialog(id,"Navigate through the dialogs to pick numbers",start,ch);
else
{
}
}
Edison Swain
Registered User
Join date: 7 Dec 2006
Posts: 51
02-02-2007 17:36
From: Newgate Ludd
You cannot use a timer event inside a state_exit or rather it is pointless to do so as it will never fire since timers are automatically deleted on state change.


This probably has nothing to do with the issue at hand - but just a question stemming from what you said here.

I was sure that timer events persisted through state changes, as I've seen this behaviour before. I know that listens get automatically deleted on state change, but I'm pretty sure the timer will keep firing.

Also, at least one copy of the wiki says:

http://www.lslwiki.org/index.php/LlSetTimerEvent

(Not that using one in a state_exit event is a usual way of doing things)
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-03-2007 00:27
From: Edison Swain
This probably has nothing to do with the issue at hand - but just a question stemming from what you said here.

I was sure that timer events persisted through state changes, as I've seen this behaviour before. I know that listens get automatically deleted on state change, but I'm pretty sure the timer will keep firing.

Also, at least one copy of the wiki says:

http://www.lslwiki.org/index.php/LlSetTimerEvent

(Not that using one in a state_exit event is a usual way of doing things)



Actually you're right thye wikki does say that, Although it also states
From: Wikki

When a state changes, all pending events are cleared, and all events that require setup (via a function) are defaulted (disabled).


What I meant to say was I think timers are restricted such that they fire only in the state that defined them, and this will not be useful in a state_exit unless you are setting them to trigger on next entry to that state. At least that is the behaviour that i expected but after a quick test I see it is no longer the case, if it ever was.
Tomfox Wiranata
Registered User
Join date: 20 Dec 2006
Posts: 80
02-03-2007 06:13
ok solved the problem...was about the channels....thx to everyone for their patience...


and i will work on "if-else" ;)


thx u guys