Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

touch to change texture

Tadao Nordenskiold
Registered User
Join date: 9 May 2009
Posts: 37
11-01-2009 05:55
Hello,

I'm not really sure of how to do this, so I ask here in hope for some light.

I have a mysql database that I get some data from,
A list looking like this:

[4:47] Object: 25_128_NADJ|450|25|128|30
[4:47] Object: 50_128_ADJ1024|1450|50|128|1024
[4:47] Object: 50_128_ADJ512|1200|50|128|512
[4:47] Object: 50_128_ADJ256|1000|50|128|256
[4:47] Object: 50_128_NADJ|650|50|128|30
[4:47] Object: 100_128_ADJ1024|1800|100|128|1024
[4:47] Object: 100_128_ADJ512|1550|100|128|512
[4:47] Object: 100_128_ADJ256|1350|100|128|256
[4:47] Object: 100_128_NADJ|1000|100|128|30
[4:47] Object: 100_96_NADJ|750|100|96|30
[4:47] Object: 100_96_ADJ256|1100|100|96|256
[4:47] Object: 100_96_ADJ512|1300|100|96|512
[4:47] Object: 100_96_ADJ1024|1550|100|96|1024
[4:47] Object: 50_96_ADJ256|800|50|96|256
[4:47] Object: 50_96_ADJ512|1000|50|96|512
[4:47] Object: 50_96_ADJ1024|1250|50|96|1024
[4:47] Object: 100_64_NADJ|550|100|64|30
[4:47] Object: 100_64_ADJ256|900|100|64|256
[4:47] Object: 100_64_ADJ512|1100|100|64|512
[4:47] Object: 100_64_ADJ1024|1350|100|64|1024
[4:47] Object: 50_64_NADJ|300|50|64|30
[4:47] Object: 50_64_ADJ256|650|50|64|256
[4:47] Object: 50_64_ADJ512|850|50|64|512
[4:47] Object: 50_64_ADJ1024|1100|50|64|1024
[4:47] Object: 50_96_NADJ|450|50|96|30
[4:47] Object: 50_192_NADJ|1200|50|192|0
[4:47] Object: 100_192_NADJ|1650|100|192|0

The script I am using is this:

string planrequest;
string server = "http://my-server/";
integer x;

default
{
state_entry()
{
llWhisper(0, "requestion data, please wait";);
planrequest = llHTTPRequest(server + "custom/info.php", [ HTTP_METHOD, "GET"], "";);
}

http_response(key request_id, integer status, list metadata, string body)
{
if (request_id == planrequest)
{
list datalist = llParseString2List(body, ["#"], []);
integer length = llGetListLength(datalist);

for ( x = 0; x < length; x++)
{
llOwnerSay(llList2String(datalist, x)); // for testing purpouse only
}
llOwnerSay((string)llGetListLength(datalist)); // for testing purpouse only
// state set_info;
}
}
}

// state set_info;
//{
// use touch_start to set info here, but how to set/change info?
//}

The first item is the item name and also the name of the teture, second is price, and the s3 is other info that will be used later.

What I need is, when someone is clicking the object, the texture should change accordingly, and then set the price.
So, from start, the texture "Welcome" will be used.
When clicking (according to the list above) texture should be changed to: "25_128_NADJ" and the variables:
name = 25_128_NADJ
price = 450
var1 = 25
var2 = 128
var3 = 30

Next click, should shange everything to:
texture "50_128_ADJ1024"
name = 50_128_ADJ1024
price = 1450
var1 = 50
var2 = 128
var3 = 1024

I hope someone can help me with this. as I have no clue of how to do this.
Tadao Nordenskiold
Registered User
Join date: 9 May 2009
Posts: 37
11-01-2009 10:21
THe way I do to try things out, is to make it say what I want first.
First trying to make it say row by row in the list, but I just can't get it to work.

THis is what I hav tried with now, but I have never done this before, so I really have no clue, and I am getting more and more frustrated. :/

CODE

string planrequest;
string server = "http://my-server/";
integer x;
list datalist;
integer length;

default
{
state_entry()
{
llWhisper(0, "requestion data, please wait");
planrequest = llHTTPRequest(server + "custom/info.php", [ HTTP_METHOD, "GET"], "");
}

http_response(key request_id, integer status, list metadata, string body)
{
if (request_id == planrequest)
{
datalist = llParseString2List(body, ["#"], []);
length = llGetListLength(datalist);

for ( x = 0; x < length; x++)
{
// llOwnerSay(llList2String(datalist, x));
}
// llOwnerSay((string)llGetListLength(datalist));
state set_info;
}
}
}

state set_info
{
touch_start(integer int)
{
if (datalist != [])
{
integer i;
for ( i = 0; i < length; i++ )
{
llOwnerSay(llList2String(datalist,i));
}
}
else
{
llOwnerSay("List empty");
}
}
}
Tadao Nordenskiold
Registered User
Join date: 9 May 2009
Posts: 37
11-01-2009 16:27
No one at all who can come up with an idea?
Or could it be that my explanation of what I am hoping to do is bad? :/
Tadao Nordenskiold
Registered User
Join date: 9 May 2009
Posts: 37
11-01-2009 17:21
I would delete this thread if I could, but I found a solution.

state set_info
{
touch_start(integer int)
{
if (datalist != [])
{
if ( i != length )
{
// Set variables
list current_string = llParseString2List(llList2String(datalist,i), ["|"], []);
string product = llList2String(current_string,0);
integer price = llList2Integer(current_string,1);
integer var1 = llList2Integer(current_string,2);
integer var2 = llList2Integer(current_string,3);
integer var3 = llList2Integer(current_string,4);

llOwnerSay("\nSelected product: " +product
+"\nPrice: L$" +(string)price);

llSetTexture(product, 0);

i++;
}
else if ( i = length )
{
i = 0;
}
}
else
{
llOwnerSay("List empty";);
}
}
}