Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Transform Key to Integer

Travis Lambert
White dog, red collar
Join date: 3 Jun 2004
Posts: 2,819
10-27-2005 13:38
I'm trying to transform a key into an integer, so that I can pass it as a start parameter.

I experimented with transforming the key (string) to Base64, transforming Base64 to an Integer, and then back again on the destination side from Integer to Base64 to a string. This is getting me nowhere fast, unless I'm doing something wrong :D

Any ideas how I could easily transform a key into an integer suitable for a start parameter, and then on the destination side decode that integer back into a key again?

Thanks in advance for your help! :)
_____________________
------------------
The Shelter

The Shelter is a non-profit recreation center for new residents, and supporters of new residents. Our goal is to provide a positive & supportive social environment for those looking for one in our overwhelming world.
Arito Cotton
Still Addicted
Join date: 25 Aug 2003
Posts: 131
10-27-2005 13:50
Since keys are basically long hexadecimal numbers, something like this should work for ya:

http://secondlife.com/badgeo/wakka.php?wakka=ExampleNumberConversion

Good luck!

Edit: You might have to manually remove the dashes (-) and add them back in later, not sure though!
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
You can't do it...
10-27-2005 14:00
A key, a UUID, has more bits in it than can be passed in an integer.

An integer in Second Life is 32 bits long.

A key is 128 bits long.

You can't fit 128 bits into a 32 bit space.
Arito Cotton
Still Addicted
Join date: 25 Aug 2003
Posts: 131
10-27-2005 14:02
From: Argent Stonecutter
A key, a UUID, has more bits in it than can be passed in an integer.

An integer in Second Life is 32 bits long.

A key is 128 bits long.

You can't fit 128 bits into a 32 bit space.


Ack, true enough!
Gaz Hornpipe
Registered User
Join date: 29 Sep 2005
Posts: 36
10-27-2005 14:04
but why would you bother... these "start param" questions keep coming up time and time again.. and I continue to ask Myself "why?". Just generate a random number (something large or a large negative number), use that as the start param; then use it for both the Listen in the rezzed object and the object that rezzes it to send on....

CODE

integer rez_chan;
default
{
touch_start(integer num)
{
rez_chan = (integer)(llFrand(99999.0) + 500.0);
llRezObject("Something",llGetPos() + <0,0,1>,ZERO_VECTOR,ZERO_ROTATION,rez_chan);
}

object_rez(key obj_id)
{
llSay(rez_chan,(string)llGetKey());
}
}


CODE

integer listening;
key source_key;
integer rez_chan;

default
{
on_rez(integer param)
{
if(param > 0)
{
rez_chan = param;
listening = llListen(param,"","","");
}
}

listen(integer channel, string name, key id, string message)
{
llListenRemove(listening);
if(channel == rez_chan)
source_key = (key)message;
}
}
Travis Lambert
White dog, red collar
Join date: 3 Jun 2004
Posts: 2,819
10-27-2005 14:51
Hehe - that would work splendid... except, I'm trying to make something that doesn't use listens :D

I'm Using llRemoteLoadScriptPin + a start parameter to change textures on a gazillion prim faces that are in no way linked together. Each one has a different texture, so I was hoping to pass the UUID along with the start parameter.

I think I'm going to go with my backup plan.... pump the data that's unique per-prim into the description field, and just pull it from there once the destination script arrives. Instead of using texture keys, I'll just put them in the object's inventory, and call the name - since that is *much* easier to anticipate.

Thanks for the input, everyone! :)
_____________________
------------------
The Shelter

The Shelter is a non-profit recreation center for new residents, and supporters of new residents. Our goal is to provide a positive & supportive social environment for those looking for one in our overwhelming world.
Gaz Hornpipe
Registered User
Join date: 29 Sep 2005
Posts: 36
10-28-2005 05:22
Once you remove the listen... it's no longer...listening...if you want to do that with your "backup" plan.. great but really.. a listen event with no listen doesn't generate any extra lag because.. it's not listening.