Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

losing a varible ... why ?

Bizcut Vanbrugh
Registered User
Join date: 23 Jul 2006
Posts: 99
09-02-2008 02:20
i am hopeing that you all can help me with this problem. i am trying to get a script to see if a note card is avalible in a prims inventory or not. if it is it sets some stats. if not it sets things to 0. the problem i am having is it seems that i am loseing the string varible for the notecard name.

CODE

string filename;

read()
{
llOwnerSay("attempting to read " + filename + " notecard");
}


default
{
state_entry()
{

llAllowInventoryDrop(TRUE);
string filename = llGetInventoryName(INVENTORY_NOTECARD, 0);
if(llGetInventoryNumber(INVENTORY_NOTECARD) == 1)
{
llOwnerSay("I see " + filename + " as a stat card");
read();

}
if(llGetInventoryNumber(INVENTORY_NOTECARD) == 0)
{
llOwnerSay("no stats to load");
//nostats();
}
}
changed(integer mask)
{
if(mask & (CHANGED_ALLOWED_DROP | CHANGED_INVENTORY))
llResetScript();
}
}


any help would be great thanks
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
09-02-2008 02:26
You have two separate variables called filename, one declared as a global up top, and a second in your state_entry. From the looks of your read() function, you want to change "string filename" down in state_entry to just "filename"
Bizcut Vanbrugh
Registered User
Join date: 23 Jul 2006
Posts: 99
09-02-2008 02:50
and its the simple things that mess us up


thanks loads