Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Massive script inefficencies

Gordon Wendt
404 - User not found
Join date: 10 May 2006
Posts: 1,024
08-26-2007 19:50
I'm trying to grab sim data and then have it update llSetText when it does, that's the easy part since that only has to be done once on state_entry but at the same time I'm having llSetText being done by a clock, the way I've done it thus far is using one llSetText call every 1 second when the clock updates but at the same time I've had trouble getting it to only call the values of everything else and not calling the functions themselves which is radically inefficent. Below is the code so far.


CODE


default
{
state_entry()
{
llSetTimerEvent(1.0);
}

timer()
{

list lstParcelDetails = llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_NAME, PARCEL_DETAILS_DESC, PARCEL_DETAILS_OWNER, PARCEL_DETAILS_GROUP, PARCEL_DETAILS_AREA]);
// Set Parcel Variables
string ParcelName = llList2String(lstParcelDetails, 0); // Parcel's Name (63 Characters Max)
string ParcelDesc = llList2String(lstParcelDetails, 1); // Parcels Description (127 Characters Max)
key ParcelOwner = llList2Key(lstParcelDetails, 2); // Parcel Owners Key (AV Or Group Key If Group Owned)
key ParcelGroup = llList2Key(lstParcelDetails, 3); // Parcel's Group Key (NULL_KEY Unless Group Set Or Owned By Group)
integer ParcelArea = llList2Integer(lstParcelDetails, 4); // Parcel's Size (In Meters Squared. ie: 512, 1024...)


integer hours;
integer minutes;
integer seconds;
integer t;

t = (integer)llGetWallclock(); // seconds since midnight

// one hour has 3600 seconds
hours = t / 3600; // get hours (integer division chops off the decimals)

// the modulo operator % gets the remainder of a divison
// in this case, the remaining seconds after removing the full hours
minutes = (t % 3600) / 60; // divide by 60 because we want minutes, chops off decimals again


seconds = t % 60; // get the seconds that didn't fit into full minutes

llSetText("Region \n" + llGetRegionName() + "\n \n" + "Parcel" + "\n" + (string)ParcelName + "\n \n" + "Parcel Owner" + "\n" + (string)ParcelOwner + "\n \n" + "Parcel Area (m2)" + "\n" + (string)ParcelArea + "\n \n" + "Current Time:" + "\n" + (string)hours + ":" + (string)minutes + ":" + (string)seconds + "\n \n \n \n \n \n \n \n", <1.0,0.0,0.0>,1.0);
}


touch_start(integer total_number)
{
llSetText("Resetting Scripts",<0,0,0>,1.0);
llResetScript();
}
}

_____________________
Twitter: http://www.twitter.com/GWendt
Plurk: http://www.plurk.com/GordonWendt

GW Designs: XStreetSL

Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
08-26-2007 20:23
Maybe..

CODE

string gBaseText;
vector gLastPos;

GetBaseText()
{
list lstParcelDetails = llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_NAME, PARCEL_DETAILS_DESC, PARCEL_DETAILS_OWNER, PARCEL_DETAILS_GROUP, PARCEL_DETAILS_AREA]);

gBaseText = "Region\n" + llGetRegionName() + "\n\n" +
"Parcel" + "\n" + llList2String(listParcelDetails, 0) + "\n\n" +
"Parcel Owner" + "\n" + llList2String(listParcelDetails, 2) + "\n\n" +
"Parcel Area (m2)" + "\n" + llList2String(listParcelDetails, 4) + "\n\n" +
"Current Time:" + "\n";

gLastPos = llGetPos();
}

default
{
state_entry()
{
GetBaseText();
llSetTimerEvent(1.0);
}

timer()
{
if (gLastPos != llGetPos())
{
GetBaseText();
}

integer hours;
integer minutes;
integer seconds;
integer t;

t = (integer)llGetWallclock(); // seconds since midnight

// one hour has 3600 seconds
hours = t / 3600; // get hours (integer division chops off the decimals)

// the modulo operator % gets the remainder of a divison
// in this case, the remaining seconds after removing the full hours
minutes = (t % 3600) / 60; // divide by 60 because we want minutes, chops off decimals again

seconds = t % 60; // get the seconds that didn't fit into full minutes

llSetText(gBaseText + (string)hours + ":" +
(string)minutes + ":" +
(string)seconds +
"\n \n \n \n \n \n \n \n",
<1.0,0.0,0.0>,1.0);
}


touch_start(integer total_number)
{
llSetText("Resetting Scripts",<0,0,0>,1.0);
llResetScript();
}
}

Untested but should be close...
Gordon Wendt
404 - User not found
Join date: 10 May 2006
Posts: 1,024
08-26-2007 20:42
From: Sindy Tsure
Maybe..


Thanks, I don't have time to try it tonight but I'll give it a try first thing tommorow.
_____________________
Twitter: http://www.twitter.com/GWendt
Plurk: http://www.plurk.com/GordonWendt

GW Designs: XStreetSL