Second Life aujourd’hui en un seul endroit Cadeaux et freebies mis à jour chaque heure 7 langues Gratuit pour inscrire votre boutique
Incident grille
  • Prévu: Scheduled Billing Maintenance, lun. 16 nov. 09:30–10:30 SLT
  • État de la grille: Unscheduled Group Chat Maintenance (investigating)
  • En ce moment: Office du samedi Unitarian Universalist à UUtopia
  • En ce moment: The Dharma of Community : société bouddhiste et householder
  • En ce moment: SLCS Harvest Fest : jeux, musique et amusement
  • 14:00 SLT: NAD GOUGH en live au Moondance à Cascadia, 14 h SLT
  • Actus: REZZ MALL : les marques Second Life dans un centre commercial web
  • Viewer: Second Life Viewer 26.5 modernise le chat
  • Prévu: Scheduled Billing Maintenance, lun. 16 nov. 09:30–10:30 SLT
  • État de la grille: Unscheduled Group Chat Maintenance (investigating)
  • En ce moment: Office du samedi Unitarian Universalist à UUtopia
  • En ce moment: The Dharma of Community : société bouddhiste et householder
  • En ce moment: SLCS Harvest Fest : jeux, musique et amusement
  • 14:00 SLT: NAD GOUGH en live au Moondance à Cascadia, 14 h SLT
  • Actus: REZZ MALL : les marques Second Life dans un centre commercial web
  • Viewer: Second Life Viewer 26.5 modernise le chat
Script LSL

LSL texture changer script (touch to change texture)

Free LSL texture changer for Second Life: touch to cycle through textures by UUID, one face or the whole linkset, safe for items you sell.

37 lignes ·

Let people pick a colour or pattern with one click. This texture changer switches the object to the next texture each time it is touched. It works with texture UUIDs instead of names, which matters if you sell or give the item: in a buyer's copy, textures referenced by name often fail because they are not transferable.

lsl-texture-changer-script.lsl · 37 lignes Vérifier ce script
// Texture Changer - free LSL script from WhatSL (https://whatsl.com/scripts/lsl-texture-changer-script)
// Free to use, change and put in your own creations, also ones you sell.
//
// Touch to switch to the next texture in TEXTURE_LIST.
// It uses texture UUIDs (not names), so it keeps working in copies you give away or sell.
// To get a UUID: right-click a full-permission texture in your inventory > Copy Asset UUID.

list    TEXTURE_LIST  = [TEXTURE_PLYWOOD, TEXTURE_BLANK];  // replace with your own texture UUIDs in quotes
integer TEXTURE_FACE  = ALL_SIDES;  // ALL_SIDES, or one face number such as 0
integer WHOLE_LINKSET = FALSE;      // TRUE = change every prim of the linked object
integer OWNER_ONLY    = FALSE;      // TRUE = only the owner can change it

integer gIndex = 0;

showTexture()
{
    string tex = llList2String(TEXTURE_LIST, gIndex);
    if (WHOLE_LINKSET) llSetLinkTexture(LINK_SET, tex, TEXTURE_FACE);
    else llSetTexture(tex, TEXTURE_FACE);
}

default
{
    state_entry()
    {
        if (llGetListLength(TEXTURE_LIST) > 0) showTexture();
    }

    touch_start(integer total)
    {
        if (OWNER_ONLY && llDetectedKey(0) != llGetOwner()) return;
        integer count = llGetListLength(TEXTURE_LIST);
        if (count == 0) return;
        gIndex = (gIndex + 1) % count;
        showTexture();
    }
}

Libre d’utilisation, de modification et d’intégration dans vos créations, même celles que vous vendez.

How to set it up

  1. Find the UUID of each texture: in your inventory, right-click a full-permission texture and choose Copy Asset UUID.
  2. Put the UUIDs in TEXTURE_LIST, each in quotes and separated by commas, for example ["uuid-one", "uuid-two"].
  3. Add the script to the object and save. Touch it to cycle through the textures.

Settings

  • TEXTURE_LIST: the textures to cycle through. The example uses two built-in textures so you can test it straight away.
  • TEXTURE_FACE: ALL_SIDES, or one face number to change only that face.
  • WHOLE_LINKSET: TRUE changes every prim of a linked object at once.
  • OWNER_ONLY: TRUE lets only the owner change the texture.

Tips

  • To find a face number, use Select Face in the Edit window and look at the texture tab.
  • This script changes classic textures. Objects that use PBR (glTF) materials need a different method.

Frequently asked questions

Why do my textures not change in the copy I sold?

Scripts that set textures by their inventory name fail when the texture is no-transfer for the buyer. This script uses UUIDs, so it keeps working.

Can I change colour instead of texture?

Yes, with a small change: put colours such as <1.0, 0.0, 0.0> in the list and, in showTexture(), use llSetColor(llList2Vector(TEXTURE_LIST, gIndex), TEXTURE_FACE) instead of the two texture lines.

Can I go back to the first texture?

Yes. After the last texture the script starts again at the first one.

Vérifier votre propre script: Vérificateur de syntaxe LSL →

Autres scriptsTous les scripts
Script LSL · 55 lignes

Script de porte LSL : toucher pour ouvrir, se referme seule

Script de porte LSL gratuit pour Second Life. Touchez pour ouvrir et fermer, la porte pivote sur ses gonds et se referme toute seule après quelques secondes. Sons facultatifs.

Script LSL · 69 lignes

LSL sit and pose script for chairs and pose balls

Free LSL sit script for Second Life chairs, benches and pose balls: sit and play your own animation, set the sit position, hide the ball while in use.

Script LSL · 96 lignes

LSL tip jar script with thank-you message and total

Free LSL tip jar script for Second Life clubs, DJs, hosts and stores: quick pay buttons, a thank-you message, the total and last tipper in floating text.