Unable to use "ACTIVE" as a variable?

Creating scripts
Post Reply
Evans Love
Posts: 4
Joined: Wed Dec 04, 2013 8:14 pm
Has thanked: 0
Been thanked: 2 times

Unable to use "ACTIVE" as a variable?

Post by Evans Love »

Hello,

Please Help! For some reason I get this error when the word "ACTIVE" is used as an integer variable?

(0,0): Error: /usr/local/node/opensim2/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll (Location of the symbol related to previous warning)

I have done some bug testing and found out that if I replace the name of the variable "ACTIVE" with something else, for example, "IS_ACTIVE" it works! This is problematic, however, in that I have imported an .OAR file with a ton of prims that each have scripts using "ACTIVE" as a variable... unfortunately when I import the .OAR into the region, the scripts (which compile and work fine on OpenSim) stop working. Why is this happening, and can it be fixed? I would really not like to have to change hundreds of scripts.

Any advice would be helpful,
- Evans Love
User avatar
Oren Hurvitz
Posts: 361
Joined: Sun Dec 23, 2012 8:42 am
Has thanked: 19 times
Been thanked: 499 times
Contact:

Re: Unable to use "ACTIVE" as a variable?

Post by Oren Hurvitz »

"ACTIVE" is a predefined constant in LSL: see http://wiki.secondlife.com/wiki/ACTIVE .

For example, the following script says "ACTIVE = 2":

Code: Select all

default
{
    state_entry()
    {
        llSay(0, "ACTIVE = " + ACTIVE);
    }
}
So if a script is trying to redefine this constant then it's being very naughty. I'm afraid the solution IS to change the variable name, since it's a reserved name.
These users thanked the author Oren Hurvitz for the post:
Dundridge Dreadlow
User avatar
Oren Hurvitz
Posts: 361
Joined: Sun Dec 23, 2012 8:42 am
Has thanked: 19 times
Been thanked: 499 times
Contact:

Re: Unable to use "ACTIVE" as a variable?

Post by Oren Hurvitz »

There's a trick you may be able to use to make this replacement quickly. First, you said you have an OAR file. So extract it on your hard disk, and go to its "assets" directory. Then, use the program "sed" to replace in all of the scripts at once. "sed" is included in most Linux distributions, and probably in OS X as well. If you're using Windows then this looks like a place where you can download sed: http://gnuwin32.sourceforge.net/packages/sed.htm

Once you have sed, run this command in the "assets" directory:

Code: Select all

cd (oar_directory)/assets
sed -i "s/\bACTIVE\b/IS_ACTIVE/g" *.lsl
Then, use tar to rebuild the OAR file. (You may need to download "tar" as well...):

Code: Select all

cd ..
tar cfz ../my_oar.oar *
Finally, use Replace World to upload the new OAR to Kitely.
These users thanked the author Oren Hurvitz for the post:
Graham Mills
Post Reply