Jump to content

llParseString2List


Orito Wonder
 Share

You are about to reply to a thread that has been inactive for 4026 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hello,

 

Below I am showing a segment of code that I am having an issue with. The issue is when I right click it to pay, it doesn't show anything. The code may seem a bit redundant, but that's only because it's a piece I'm messing with.

string payTemp;
default
{
    state_entry()
    {
        llSetPayPrice(PAY_HIDE,[]);
        payTemp = "25|50|75|100";
    }
    
    touch(integer num_detected)
    {
        llSetPayPrice(PAY_DEFAULT,llParseString2List(payTemp,["|"],[]));
    }
}

 

Any help is appreciated.

 

Thanks.

Link to comment
Share on other sites

Hello,

 

Below I am showing a segment of code that I am having an issue with. The issue is when I right click it to pay, it doesn't show anything. The code may seem a bit redundant, but that's only because it's a piece I'm messing with.

string payTemp;
default
{
    state_entry()
    {
        llSetPayPrice(PAY_HIDE,[]);
        payTemp = "25|50|75|100";
    }
    
    touch(integer num_detected)
    {
        llSetPayPrice(PAY_DEFAULT,llParseString2List(payTemp,["|"],[]));
    }
}

 

Any help is appreciated.

 

Thanks.

Link to comment
Share on other sites

Hi, you need to have a money event before llSetPayPrice can be active. It doesn't have to do anything special if you are making something like a simple tip jar, but it has to be there. (That is also how we can switch payment off, by changing to another state that doesn't have one.)

  • Like 1
Link to comment
Share on other sites

Thank you for the reply.

 

The code now looks like this...

string payTemp;default{    state_entry()    {        llResetScript();        llSetClickAction(CLICK_ACTION_TOUCH);        llSetPayPrice(PAY_HIDE,[]);        payTemp = "25|50|75|100";    }        touch(integer num_detected)    {        llSetPayPrice(PAY_DEFAULT,llParseString2List(payTemp,["|"],[","]));    }        money(key giver, integer amount)    {    }}

 However, the problem persists.

 

Thanks again.

Link to comment
Share on other sites

This second script works for me, in a simple cube. It lets me pay and the money comes right back to me.

How is the object built? I will toss out this common problem area noted on the wiki --

  • Note that the pay option will only be shown in prims having a running script with a money event (or in all the prims of the object if the root has a running script with a money event).

So, you may have to play a little if the script is in a child prim.

 

  • Like 1
Link to comment
Share on other sites

You need to touch it at least once to get your custom pay options, did you?

And just noticed you need to remove the "," at:

llSetPayPrice(PAY_DEFAULT,llParseString2List(payTemp,["|"],[","]));

Because the list elements are comma separated by system and the SetPayPrice function in your state_entry event is empty which will result in showing the default options. 

 

Example using llParseString2List:

string yourOptions = "1|2|3|4";

list parsedOptions = llParseString2List(yourOptions,["|"], [ ] );

// go on using your parsedOptions list

Link to comment
Share on other sites

Oh right, because llParseString2List only knows strings. You have to convert types yourself. Here is one sleepy way to do it.

 

string payTemp;default{    state_entry()    {        llSetClickAction(CLICK_ACTION_TOUCH);        llSetPayPrice(PAY_HIDE,[]);        payTemp = "25|50|75|100";    }        touch(integer num_detected)    {        list priceStrings = llParseString2List(payTemp,["|"],[","]);        list prices;        integer i;        for (i = llGetListLength(priceStrings) -1; i > -1; i--)        {            prices = (integer)llList2String(priceStrings, i) + prices;        }        llSetPayPrice(PAY_DEFAULT,prices);    }        money(key giver, integer amount)    {    }}

 

  • Like 1
Link to comment
Share on other sites


Orito Wonder wrote:

Thank you for the reply.

 

The code now looks like this...
string payTemp;default{    state_entry()    {        llResetScript();        llSetClickAction(CLICK_ACTION_TOUCH);        llSetPayPrice(PAY_HIDE,[]);        payTemp = "25|50|75|100";    }        touch(integer num_detected)    {        llSetPayPrice(PAY_DEFAULT,llParseString2List(payTemp,["|"],[","]));    }        money(key giver, integer amount)    {    }}

 However, the problem persists.

 

Thanks again.

You seriously want to reset the script in a state_entry event? What's the reason for to do so?

Link to comment
Share on other sites

I'm sorry for asking again but... what? Oô

It just doesnt makes sense to let the script reset in a state_entry event as its the start (entry) point for each script. Usually non of the following functions after a ResetScript gets executed.

 

The following code (usually has to) result in infinite looping the state_entry event without the Whipser("after reset") executing:

 

default{    state_entry()    {        llWhisper(0,"befor reset");        llResetScript();        llWhisper(0,"after reset");    }}

 

 Edit: I did a test and got a loop with the "befor reset"  chat message like 100 times. Then the script stucked, running box is still checked but im not able to get it recompiled by reset or simply saving it. Also a shift copy will result in a broken script somehow. 

 

Disclaimer: If you experience any inconvenience on your sim - It wasn't me (i hope)!

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4026 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...