Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

need help with a list to integer

Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
10-13-2008 14:19
this is probuly overdoing it slightly it is a experiment im trying this is the concept of the script

car -> 10m/s+ -> brick wall -> crashed

so far the idea scriptwise seams to work but now im geting errors with type mismatch can onlyone find my bug?

CODE

key sound = "(my sound)";
float speedz;
integer crashspeed;
list crashedz;
integer crash;
default
{
state_entry()
{
//llCollisionFilter("wall", NULL_KEY, TRUE);
llMessageLinked(LINK_SET, 0, "repair", NULL_KEY);
llSetTimerEvent(2);
llListen(0,"",llGetOwner(),"");
}
listen( integer channel, string name, key id, string message )
{
if(message == ".crashstart")
{
llMessageLinked(LINK_SET, 0, "crash", NULL_KEY);
}
if(message == ".crashrepair")
{
llMessageLinked(LINK_SET, 0, "repair", NULL_KEY);
}
}
//collision_end(integer x)
collision(integer x)
{
if(llDetectedType(0) & AGENT)
{
}
else if(crash == FALSE)
{
if(crashspeed < 15) // type mismatch
{
llTriggerSound(sound,1);
llMessageLinked(LINK_SET, 0, "crash", NULL_KEY);
crash = TRUE;
}
}
if(crash == TRUE)
{
llSetStatus(STATUS_PHYSICS,FALSE);
}
}
land_collision(vector y)
{
}
timer()
{
speedz = (integer)(llVecMag(llGetVel()) * 1.94384449 + 0.5);
crashedz += speedz;
llSetText((string)speedz,<1,0,0>,1);
llList2String(crashedz, -1);
crashspeed = llList2String(crashedz,-1);

}
on_rez(integer x)
{
llResetScript();
}
}
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
10-13-2008 14:49
where is the typing mismatch coming up at?
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
10-13-2008 14:52
if(crashspeed < 10) // type mismatch
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
10-13-2008 14:53
ah it might need to be

if(crashspeed <= 10)
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
10-13-2008 14:56
geting this error in LSL Editer

Cannot implicitly convert type 'list' to 'integer'

updated code
Nika Talaj
now you see her ...
Join date: 2 Jan 2007
Posts: 5,449
10-13-2008 14:59
I'm more concerned about your timer handling.

From: someone
llList2String(crashedz, -1);
speedz = llVecDist(llGetPos(),llDetectedPos(0));
crashedz += speedz;
crashspeed = crashedz;


Did you mean to set something to what the llList2String call returns?

And, I don't think LSL will do an implicit type conversion of crashedz (a list) to crashspeed (an integer). You would need an llList2Integer call for the element of the list you want, no?
.
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-13-2008 15:00
Throw crashedz & speedz in the trash.

CODE

timer() {
crashspeed += (integer) llVecDist(llGetPos(), llDetectedPos(0));
}
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
10-13-2008 15:11
found the bug, aparently it is in the velcity detect, reupdating script

seams to be doing something with the coords of the sim working to fix it
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-13-2008 15:23
Your logic in the collision event is all screwed up. Straighten it up some and throw llOwnerSay's all through your script to get feedback on what is happening.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
10-13-2008 16:53
I'm surprised you aren't getting a type mismatch now on THIS line:

crashspeed = llList2String(crashedz,-1);

because llList2String() returns a string and you are assigning it to an integer variable. I didn't think there was an implicit cast from string to integer. You SHOULD have to make it explicit like:

crashspeed = (integer)llList2String(crashedz,-1);

or just:

crashspeed = llList2Integer(crashedz,-1);
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
10-13-2008 17:23
hewee to the resue, it works purfectly now :) thanks for the help everyone
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-13-2008 19:02
As I previously pointed out, you can just discard crashedz & speedz. You also need to be able to reset crash back to FALSE & physics back to TRUE at some point in your script.
CODE

key sound = "(my sound)";
integer crashspeed;
integer crash;
default {
state_entry() {
llMessageLinked(LINK_SET, 0, "repair", NULL_KEY);
llSetTimerEvent(1);
llListen(0, "", llGetOwner(), "");
}
listen(integer channel, string name, key id, string message) {
if (message == ".crashstart") {
llMessageLinked(LINK_SET, 0, "crash", NULL_KEY);
}
if (message == ".crashrepair") {
llMessageLinked(LINK_SET, 0, "repair", NULL_KEY);
}
}

collision(integer x) {
if (crash == FALSE) {
if (crashspeed < 10) {
llTriggerSound(sound, 1);
llMessageLinked(LINK_SET, 0, "crash", NULL_KEY);
crash = TRUE;
}
}
else (crash == TRUE) {
llSetStatus(STATUS_PHYSICS, FALSE);
}
}
land_collision(vector y) {
}
timer() {
crashspeed += (integer) llVecDist(llGetPos(), llDetectedPos(0));
}
on_rez(integer x) {
llResetScript();
}
}
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
10-13-2008 19:28
From: Hewee Zetkin
I'm surprised you aren't getting a type mismatch now on THIS line:

crashspeed = llList2String(crashedz,-1);

because llList2String() returns a string and you are assigning it to an integer variable. I didn't think there was an implicit cast from string to integer. You SHOULD have to make it explicit like:

crashspeed = (integer)llList2String(crashedz,-1);

or just:

crashspeed = llList2Integer(crashedz,-1);


i wondered about that as well, but (s)he said that the error was elsewhere so i forgot about it, i did notice before they had asked about list to integer, but i didn't see it anywhere in the script
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
10-14-2008 15:59
i had //llList2Integer but it was in there, ive been looking threw the list info on wiki, but i cant find out, is there a maximum ammount a list can hold?
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-14-2008 16:14
From: Mrc Homewood
i had //llList2Integer but it was in there, ive been looking threw the list info on wiki, but i cant find out, is there a maximum ammount a list can hold?

With the old lsl, a list could hold around 180+/-, including names, vectors and uuids and still be able to manipulate the lists. Using MONO you would have to try really, really hard to put enough entries in it to run into a stak/heap collision.

What I have done in the past when I was worried about it is to get my script like I want and then add a subroutine to add entires comparable to what will really go in the list and have it count as it adds like 10 entries etc to chat. It will also need to manipulate the list in the test run. You will then be able to see exactly how much your particular script can work with safely.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
10-14-2008 16:57
ive been messing with it after i came home from school been geting stackheps every few minutes so i added a timer to reset the script every 60 seconds and havent had much issues, right now ive been debugging and doing multiple tests and stability info any thoughts on the project will be greatfull if you have any :)
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-14-2008 17:35
From: Mrc Homewood
ive been messing with it after i came home from school been geting stackheps every few minutes so i added a timer to reset the script every 60 seconds and havent had much issues, right now ive been debugging and doing multiple tests and stability info any thoughts on the project will be greatfull if you have any :)

Well this was what I was refering to when i said your if tests are screwy. You are taking and putting llvecdist into a list. Every second it reads that integer and adds it to the list making it longer and longer. One minute and you have 60 entries, 5 minutes and you have 300 entries etc. Then you are taking and comparing to see if a list (not an integer) is less then 10, which you can't do. What is the purpose of the list? I don't see anywhere in your script that you need historical data as to what llVecDist was in the past. Why not just toss the list? Declare crashpeed as an integer and not a list and make your timer like this:
CODE

timer() {
crashspeed = (integer) llVecDist(llGetPos(), llDetectedPos(0));
}


Then you are directly comparing an integer to an integer.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum