Jump to content

Noob question about states and variables


goodlighttreeheart
 Share

You are about to reply to a thread that has been inactive for 2996 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hello.
Purely by accident i noticed that taking an object to your inventory doesnt alter its state, can this be used to keep variables across rezzes?

For clarity, i'm trying to find a way to store user specific offsetts for seating animations on furniture, so that when a user has already programmed their seating adjustments if i pick up the object and replace it the data is not lost.

 

Thanks <3

Link to comment
Share on other sites

Scripts will retain their current state and variable settings until they are reset.  In the scanario you have sketched out I would recommend getting a way for the script to chat out it's saved settings, and also maybe have a way to restore them via a notecard drop, however.

If there are only one or two settings to be specified, putting them in the object description line is another way to allow values to be preserved, on reset, the script interrogates the description value to see if it contains a setting to be applied.

  • Like 1
Link to comment
Share on other sites

Scripts always keep their state and variables. Sim restarts, take into inventory, copy into inventory, rezzing - that doesn't change state or varialbles.

If you shift drag copy an object the copied object is reset the original is unchanged.

If you have other experiences then your script resets itself everytime it is rezzed. In this case you need to change your script.

 

  • Like 1
Link to comment
Share on other sites

You are missunderstanding what a sim restart does, it restarts the running exe on the server. Scripts are unafected by restarts as they are not part of the exe. 

ADDED; I should have pointed out that there are more than one running exe on servers so when you do a restart you are only restarting your region exe.

  • Like 1
Link to comment
Share on other sites

"If you shift drag copy an object the copied object is reset" that is not entirely correct, the object and script are only copies in terms of object parameters and written code that are passed to a newly created object, they are asingned a new UUID, its own memory block and there for are a new object and script and not a copy.

  • Like 1
Link to comment
Share on other sites


steph Arnott wrote:

"If you shift drag copy an object the copied object is reset" that is not entirely correct, the object and script are only copies in terms of object parameters and written code that are passed to a newly created object, they are asingned a new UUID, its own memory block and there for are a new object and script and not a copy.

It is also important to remember that when you drag-copy and object it's the one you drag that is the original the one that stays in the original position is the copy.

  • Like 1
Link to comment
Share on other sites

Alll in all, if you are interested in getting values to persist in a scripted object, the least secure way to do it is to save them in the script's memory.  Even if you don't reset a script willingly and therefore wipe its memory, a script can always stall for any number of reasons (a math error, a stack/heap overload, ...) and thus force you to reset it.

It's much smarter to store values in prim properties or in the description or name fields of various prims.  Even smarter, send the values to a helper script in another object (an in-world server) or to a server outside of SL.  Now that we have the use of Experience tools, one of the nicest ways to save data -- especially large databases -- is to dump them to KVP and them retrieve them later with a dataserver event in your script (or in any other script that is also in the same Experience, anywhere in SL).

  • Like 1
Link to comment
Share on other sites

You use to be are able to parse the info in the on_rezz but was limited to two additionals for obviouse reasons, i.e griefing. I not know if that still possible.Scubbed as incorrect. Brain has gone on strike.

Have never tried your other examples, but i do not script anything worth the effort to even try.

Link to comment
Share on other sites

You can read/load any information you like in the on_rez event.  For example,

on_rez(integer param){    giMyChannel = param;    glFriendsUUIDs = llCSV2List(llList2String(llGetLinkPrimitiveParams(3,[PRIM_DESC]),0));    gvPrimColor = (vector)llGetObjectDesc();    grMyRot = (rotation)llList2String(llGetLinkPrimitiveParams(2,[PRIM_NAME]),0);    gfMySoundVolume = llGetAlpha(3);    gkOwner = llGetOwner();    llMessageLinked(5,35,"Send my transaction list, please",NULL_KEY);}
  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2996 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...