Search the Community
Showing results for tags 'maths'.
-
Hi! I've been working on a script somone put into the public domain, trying to adapt it to my purpose, which is to rez an NPC when it receives a message via a Dataserver call. Broadly, it works fine, but upon rezing, I want the NPC to adaopt the included (static) animation and to face a particular direction. It's this last part that won't work. No matter what value I put in for the Z rotation, the NPC will behave as follows: 1) It tends not to change direction at all for small (Less than about 7 or 8 degrees) increments/decrements of Z 2) Then it will suddenly change direction by an estimated 20 or so degrees. 3) it cannot be made to face any direction in between it's two jumps 4) For some values, it jumps into a wildly different direction. 5) Overall, it seems to be a toss up between only about 4 or 5 directions it will face, and none other, no matter which of the 360 degrees I try. Here's the relevant piece of code I believe. Where you see "185" in this example; that's the value I'm changing, but the results don't change as expected/intended. Clearly I'm doing something wrong here, but can anyone tell me what? if(npc_on == FALSE) { npc = osNpcCreate("", "", npcPos, npc); npc_on = TRUE; llSensor("", "", AGENT | NPC, 96.0, PI); vector xyz_angles = <1.0, 1.0, 185.0>; vector angles_in_radians = xyz_angles * DEG_TO_RAD; // Change to Radians rot_xyzq = llEuler2Rot(angles_in_radians); // Change to a Rotation osNpcSetRot(npc, rot_xyzq); osNpcPlayAnimation(npc, "My animation"); } Thank you in advance for your thoughts!
-
OK, hopefully someone can help me here as whatever I do always results in a 0 (zero) output! I'm just trying to do a simple calculation to work out the percentage of memory. It really shouldn't be so difficult, should it?? I thought maybe there was limitation with how much maths could be done in one line, so I split the two calculations up and it still doesn't work as expected. The calculation should look something like: 34968 / 65536 * 100 which rounded up should be about 53%. I wasn't sure if you could use parenthesis in it or not, but it didn't work anyway (eg: (34968 / 65536) * 100) integer used_memory = llGetUsedMemory(); integer total_memory = llGetMemoryLimit(); float percentageMaths = used_memory / total_memory; float percentageMemory = percentageMaths * 100; llOwnerSay("Memory used as percentage: " + (string)llRound(percentageMemory)); //result as: "Memory used as percentage: 0" Any insights?