Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

"more input"

Gearsawe Stonecutter
Over there
Join date: 14 Sep 2005
Posts: 614
04-09-2007 18:15
With the wasteful space of lists I was looking for a way to store more in a script. What I needed was a way to store sets of 2 Integers, and Float in a list always in the same order which would then be recalled in the same order. What I did find was converting the into something like a Rotation with a function such as.

CODE
rotation IntIntFloat2Rot(integer int1, integer int2, float float1)
{
return <int1 >> 11, int2 >> 11, ((int1 & 2047) << 11) | (int2 & 2047), float1>;
}


Then later recalling the rotation and converting it back into a list with...

CODE
list Rot2IntIntFloat(rotation in)
{
return [((integer)in.x << 11) | ((integer)in.z >> 11), ((integer)in.y << 11) | ((integer)in.z & 2047), in.s];
}


...which would return the original 2 integers and the float would allow you to store quite a bit more data. What I'm wondering is can anybody else think of a way to store more in a single script? The only other thing I can think of is converting the integer into a Hex string that would be in the format of a serialization float. Then you could store the integers as floats in a vector. But this would probably take quite a bit longer to convert back and forth.

in an almost empty script that would keep adding the 2 integers and a float sets on a list allowed me to store 160 set while the using rotations method gave me 290. Just food for thought.
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
04-10-2007 00:04
You could encode it as a string in hex, at a cost of 1 byte per character + 18 bytes per string. This is especially useful if you don't need the full 4gig range of an int, i.e. if the value of the int will never exceed 255, you only need 2 hex digits.