ingen-lab / Ruth

Project Ruth - an Open Source Mesh Avatar by Shin Ingen
56 stars 38 forks source link

Method to prevent a texture from being dropped into the wrong prim? #26

Closed SundanceHaiku closed 6 years ago

SundanceHaiku commented 6 years ago

Shin, or anyone who might have a solution . . .

I've been working on a HUD which allows you to drop in different fingernail textures: little hearts, zebra designs, etc.. It uses Shin's cool idea of dropping skins via the Skin applier.

I found, however, that if one happens to accidentally drop, say a zebra texture, in the root prim (the backdrop of the HUD), then the backdrop picks up the texture. There's no way of backing out it. Your backdrop now has a zebra design on it.

I'd like to restrict it so people can only drop textures to the prims designed to receive them and not the backdrop.

I tried using llAllowInventoryDrop set to FALSE in the backdrop. However, if you have full permissions (and I want to provide this HUD with full permissions), it won't stop you from dropping a texture into the backdrop. (With full permission, you can drop anywhere.) It is possible to use llAllowInventoryDrop, but only if the HUD is set to No Modify. (This still allows people to drop textures to the prims designed to receive them.) If possible, I'd like to keep things set to No Modify.

Can anyone suggest a way of doing this?

Sundance

SundanceHaiku commented 6 years ago

Okay. Figured it out. I ended up using the following:

changed(integer change) { if (change & CHANGED_TEXTURE)
{ // } }

Unfortunately, the change event doesn't tell you where the texture change is taking place, i.e. which prim is being changed. To find out where it occurs, it's necessary to create a list of prims and their textures during the State Entry event.

After a change is detected, loop through the prims and compared textures with the original list. Look for a texture that is different from the original list. When the texture is different, that's the prim where the change occurred. If it's a texture you don't want changed, then replace the changed texture with the original texture,

It seems like there must be an easier way, but not discovering anything better, this solution ended up working for me:

aiaustin commented 6 years ago

Would a solution be to identify the background prim at state entry time and just save its texture. Then have a statement on texture change which reverts the unintended change only if that prim is involved?

If you are willing to allow a separate script for the background prim it could just have this revert function perhaps.

typhartez commented 6 years ago

You can store the texture uuid in each prim description when it's changed (and script reset). Then you can compare with the actual texture set

2018-03-03 23:26 GMT+01:00 Ai Austin notifications@github.com:

Would a aolution be to identify the background prim at state entry time and just save its textire. Then have a statement on texture change which reverts the texture change only if that prim is involved?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Outworldz/Ruth/issues/26#issuecomment-370184866, or mute the thread https://github.com/notifications/unsubscribe-auth/APytPi3QIvTJj-WpZTj0seydQV0IKZm1ks5taxikgaJpZM4Saq8F .

-- It is easier to disintegrate an atom than a prejudice (Albert Einstein)

SundanceHaiku commented 6 years ago

Thanks Ai and Typhartez!

SundanceHaiku commented 6 years ago

I think this is pretty well solved and this issue can be closed. I'll have the code posted and available as open source shortly.

SundanceHaiku commented 6 years ago

Closing this issue. It's all sorted.