CHANGED_TEXTURE is not triggered when texture is changed via script
tracked
Bambi Bubbles
Detecting a texture change is sometimes crucial for a scripted object, for example when a script needs to re-assert it's texture for a status display, or just to 'fix' changes. If a script in another prim in the linkset, or a another script in the same prim triggered a texture change, it can be downright useful for a secondary script to be able to detect that change, if only to 'act in unison' with that texture change.
I ran into this issue while working on a modding project, where I don't have access to modify the original script.
I have a scripted object that operates by changing the texture of a "TV screen", and running animated textures on the face of it. It also sets a PRIM_POINT_LIGHT on that prim. I'd like to disable that light, but there is no way to detect when a light is being enabled. We are supposed to have a way to detect changed textures, but this function seems to be broken for detecting scripted texture changes dating back to at least the Jira, and SVC-914. http://jira.secondlife.com/browse/SVC-914
The unfortunate alternative is that I must now run a timer, constantly checking for the presence of a light on the child prim, in order to disable it when present. Creating additional overhead that could have been avoided if there was a way to simply trigger on the event of the texture being changed by the other script, or the light turning on/off.
Log In
Maestro Linden
updated the status to
tracked
Maestro Linden
The history of this bug is:
- SVC-914 was filed around 2007, describing the issue
- A fix, which made it so that any changes to textures would trigger changed()withCHANGED_TEXTURE, was put out in 2010.
- We quickly learned that the fix broke a widely deployed in-world vendor, which had broken logic similar to this:
changed(integer change)
{
if(change | CHANGED_INVENTORY)
{
llResetScript();
}
The vendor scripts were themselves calling llSetTexture or equivalent as a customer browsed different items for sale. With the bug fixed, the script gets the
changed
event, which (due to a logic error) always causes the script to reset itself and get stuck at the initialization step of prompting the owner for PERMISSION_DEBIT.- We rolled back the fix immediately due to the outcry from residents, leaving the bug open
Maestro Linden
updated the status to
under review
Bambi Bubbles
Unable to edit the post body, so here:
Script that changes texture every 2 seconds:
integer flipFlop;
list textures =
[ "35cc69bf-6cfd-6d33-970b-d3fb18d69b49"
, "2416161d-4eac-83fc-e94f-7377c38198d1"
];
default
{
state_entry()
{
llSetTimerEvent(2);
}
timer()
{
flipFlop = !flipFlop;
llSetLinkPrimitiveParamsFast(LINK_THIS,
[ PRIM_TEXTURE
, ALL_SIDES
, llList2Key(textures, flipFlop)
, <1,1,0>
, <0,0,0>
, 0.0
]);
}
}
Script that detects CHANGED_TEXTURE (that doesn't)
default
{
changed(integer change)
{
if (change & CHANGED_TEXTURE) //note that it's & and not &&... it's bitwise!
{
llOwnerSay("The prims texture or texture attributes have changed.");
}
}
}