Tool-Texture cube hollow face
Jump to navigation
Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Tool-Texture cube hollow face v0.1.0
--BETLOG Hax GMT+10: 20090210 0222 [SLT: 20090209 0922]
A tool for adjusting texture repeats for inside (hollow) face of cubes.
I made some attempt to accommodate other prim types, but never actually finished it.
//=========================================================================
f_setHollowX(float Xrepeats)
{ list data = llGetPrimitiveParams([PRIM_TYPE]);
vector cut = llList2Vector(data, 2);
float hollow = llList2Float(data, 3);
if (hollow == 0.0)
{ llOwnerSay("ERROR: not hollow.");
return;
}
if (llList2Integer(data, 0) != PRIM_TYPE_BOX)
{ llOwnerSay("WARNING: not a box. This is completely UNTESTED");
}
integer face = 5;
if (cut.y - cut.x <= 0.75) face = 4;
if (cut.y - cut.x <= 0.5) face = 3;
if (cut.y - cut.x <= 0.25) face = 2;
//llOwnerSay((string)cut+"\t"+(string)face);
float rpt = Xrepeats/-hollow;
float ofs = (((Xrepeats/-hollow)+Xrepeats) / 2.0)+(Xrepeats/2.0/Xrepeats);
if ((ofs > 1.0) || (ofs < -1.0))
ofs -= (float)llFloor(ofs);
vector o = llGetTextureOffset(face);
vector r = llGetTextureScale(face);
llSetPrimitiveParams([PRIM_TEXTURE, face
, llGetTexture(face)
, <rpt, r.y, 0.0>//repeats
, <ofs, o.y, 0.0>//offsets
, 0*DEG_TO_RAD
]);
}
//======================================================================================
default
{ on_rez(integer start_param)
{ llResetScript();
}
state_entry()
{ llOwnerSay(
"\n Type number of X texture repeats for the hollow face of a cube."
+"\n Type 'done' to delete script and finish.");
llListen(0, "", llGetOwner(), "");
}
listen(integer channel, string name, key id, string message)
{ if ((float)message != 0.0)
{ f_setHollowX((float)message);
}
if (llToLower(message) == "done")
{ llOwnerSay("OK, removing script.");
llRemoveInventory(llGetScriptName());
}
}
}
//=========================================================================