Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

money giver gives money then asks for group tag

Billybob Flatley
Registered User
Join date: 9 Nov 2007
Posts: 36
12-21-2008 11:46
this is what i have.
integer amount=10;// how much you wanna give away

default//this is the normal state we are used to, call it the first one
{
touch_start(integer num_detected)
{
if(llDetectedKey(0)==llGetOwner())
{
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);//asks for permission to give out L$
}
}

run_time_permissions(integer perm)
{
if (perm & PERMISSION_DEBIT)
{
llOwnerSay("Permissions passed...ready to work";);
state run; //if you give it permission it goes to the next state
}
else
{
llOwnerSay("Invalid Permissions...resetting now";);
state reset; //if not it goes to the reset state
}
}
changed(integer change) { // something changed
if (change & CHANGED_OWNER) { state reset;}}
}


state run // the state what runs (the main one in this case)
{
state_entry()
{

llOwnerSay("Ok its time to give out some L$";);
}


touch_start(integer total_number)
{
llGiveMoney(llDetectedKey(0),amount);
state sleep; // The state that sleeps (massachuesetttes?)
}

}


state reset // Saves writing llResetScript all ove the place
{
state_entry()
{
llResetScript();
}
}
state sleep // The sleepy bit sets the time and then goes to the main state
{
state_entry()
{
llSetTimerEvent(86400);
}
timer()
{
state run;
}
touch_start(integer total_number)
{
integer i;
for(i=0;i<total_number;i++)
{
if( llDetectedGroup(i)==FALSE )
{
llSay(0, "Sorry, " + llDetectedName(i) + " but I'm not giving you anything because you're not wearing the right group tag.";);
}
else
{
llSay(0, "Good news, " + llDetectedName(i) + " you are wearing the right tag, so you get the money.";);
// plus whatever it does to give them money, obviously.
}
}
}

}
but when its like this is gives out the money then asks for the group tag.
I want it to only give out the money if they are wearing my group tag
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
12-21-2008 13:05
In the 'run' mode you give the money before you enter 'sleep' mode:
CODE

touch_start(integer total_number)
{
llGiveMoney(llDetectedKey(0),amount);
state sleep; // The state that sleeps (massachuesetttes?)
}

Not until the touch event in the 'sleep' mode you test for group.

So Givemoney comes before group test obviously

remove the one 'llGiveMoney' from your 'run' mode and put it after the test in the 'sleep' mode
You might reconsider your choices of states, it looks to me as if you have too many:)
_____________________
From Studio Dora
Billybob Flatley
Registered User
Join date: 9 Nov 2007
Posts: 36
12-22-2008 09:05
From: Dora Gustafson
In the 'run' mode you give the money before you enter 'sleep' mode:
CODE

touch_start(integer total_number)
{
llGiveMoney(llDetectedKey(0),amount);
state sleep; // The state that sleeps (massachuesetttes?)
}

Not until the touch event in the 'sleep' mode you test for group.

So Givemoney comes before group test obviously

remove the one 'llGiveMoney' from your 'run' mode and put it after the test in the 'sleep' mode
You might reconsider your choices of states, it looks to me as if you have too many:)


Dora I thank you for trying to help here:)
but i dont know what a test is. i am getting a better idea of what im doing here, But just cant seem to get there with what i know yet. also you say there are to many states. how do i know witch ones to take out?
Yumi Murakami
DoIt!AttachTheEarOfACat!
Join date: 27 Sep 2005
Posts: 6,860
12-22-2008 10:59
From: Billybob Flatley
Dora I thank you for trying to help here:)
but i dont know what a test is. i am getting a better idea of what im doing here, But just cant seem to get there with what i know yet. also you say there are to many states. how do i know witch ones to take out?


Hi Billybob,

Remember that when LSL reads scripts, it just reads each line one at a time as it comes to them, completes the command on that line, and then moves on to the next. It doesn't look ahead to see if any future lines could affect the current command.

So, your permissions test is great, but then at:

From: someone

touch_start(integer total_number)
{
llGiveMoney(llDetectedKey(0),amount);
state sleep; // The state that sleeps (massachuesetttes?)
}


When the user touches the object, the first command is the llGiveMoney. SL reads it and gives the money. After that point, ANYTHING which occurs in state sleep cannot affect the giving of the money. It has already happened, all in the past, done and dusted. If your test (ie, your "if" statement) is in state sleep then it's happening too late.

(By the way, what's "state sleep" supposed to do? It looks like you're trying to use a script template for session management, where one person has a continuous dialog "session" with the script that includes several interactions. In that case you need to put a time limit on the whole session because otherwise, the person could walk away without saying goodbye and the script would by unusable by anyone else. But you don't need that for this example, because "click and get money if you're a group member" is just one interaction.)