Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0008398opensim[REGION] Script Functionspublic2018-10-19 12:182018-10-23 12:49
Reporterslow putzo 
Assigned To 
PlatformAMDOperating SystemLinux monoOperating System VersionFedora 26
Product Version0.9.0.1 
Target VersionFixed in Version 
Summary0008398: osAvatarName2Key not working for NPC's correctly
DescriptionThe function osAvatarName2Key is not working correctly for an NPC.
It appears that it is remembering the UUID it has previously found based on the name, and is not checking to see what the real UUID is for the agent.
This is fine for an avatar because it's UUID stays the same, but an NPC gets a new UUID every time it is rezzed.
osAvatarName2Key keeps returning the first UUID it found for the name of the NPC and not what the actual UUID is for the npc.
Steps To Reproduce- rez an NPC.
- use osAvatarName2Key to get the UUID based on it's name.
- Delete the npa.
- rez the same NPC using the same name.
- use osAvatarName2Key to get the UUID.
It returns the UUID it found the first time, which is not the UUID of this NPC because an NPC gets a new UUID every time it is rezzed.

Additional InformationCode snippit that is failing using the osAvatarName2Key function.

list Agents = osGetAgents(); // get a list of all avatars on this region
integer AgentsLength = llGetListLength( Agents ); // get the list length

if (AgentsLength!=0)
    integer i;
    for (i = 0; i < AgentsLength; i++)
    string AvatarName = llList2String( Agents, i );
    list NameParts = llParseString2List( AvatarName, [" ",".","@"],[]); // break it into parts
    string FirstName = llList2String( NameParts, 0 );
    string LastName = llList2String( NameParts, 1 );
    llSay (0, "AvatarName: "+ AvatarName);
    key AgentUUID = osAvatarName2Key(FirstName, LastName);
    llSay (0, "AgentUUID: "+ (string)AgentUUID);
*** snip ***
TagsNo tags attached.
Git Revision or version numberOSgrid Snail Dev 57ae99b113: 2018-09-30
Run ModeStandalone (1 Region)
Physics EngineubODE
Script Engine
EnvironmentMono / Linux64
Mono Version5.x
ViewerSingularity Viewer 1.8.7
Attached Files

- Relationships

-  Notes
Luisillo_Contepomi (reporter)
2018-10-19 14:09
edited on: 2018-10-20 06:00

Have you create npcs with OS_NPC_SENSE_AS_AGENT option?

osNpcCreate("firstname", "lastname", llGetPos(), "clothes", OS_NPC_SENSE_AS_AGENT) ;

Is working fine for me.
key bot = NULL_KEY;

     touch_end(integer a){
bot = osNpcCreate("firstname", "lastname", llGetPos(), "ropa", OS_NPC_SENSE_AS_AGENT) ;
list Agents = osGetAgents();
integer AgentsLength = llGetListLength( Agents );

if (AgentsLength!=0)
    integer i;
    for (i = 0; i < AgentsLength; i++)
    string AvatarName = llList2String( Agents, i );
    list NameParts = llParseString2List( AvatarName, [" ",".","@"],[]); // break it into parts
    string FirstName = llList2String( NameParts, 0 );
    string LastName = llList2String( NameParts, 1 );
    llSay (0, "AvatarName: "+ AvatarName);
    key AgentUUID = osAvatarName2Key(FirstName, LastName);
    llSay (0, "AgentUUID: "+ (string)AgentUUID);
           if (bot != NULL_KEY){ osNpcRemove(bot);}

UbitUmarov (administrator)
2018-10-20 06:17

should be better on master now
btw the new osGetNPCList() may be a better replacement for your code example
slow putzo (reporter)
2018-10-20 13:48

Thanks for the quick response. I did switch to using osGetNPCList() which simplify some of the follow on code. It supplied me with the UUID so didn't need to use the osAvatarName2Key. It also eliminates detecting the NPC who is doing the scan of, who is on the region.

I looked at the Wiki to understand the options format used to create the NPC and it does not have any information about any options at all. It only shows where they go, but not what they are or what they do.

gGenieID = osNpcCreate(gNPCfname, gNPClname, npcPos, gNewAppearanceCardName, OS_NPC_NOT_OWNED); // create Genie

This is the way I currently generate my NPC's. I got that option from dev Justin back when the options were first added. I have not touched that code for ages now.

What was odd in how osAvatarName2Key (generating the NPC like I do) produced the correct UUID the first time, then if the NPC was removed and created again, it repeated the original UUID, not the current UUID.

If using OS_NPC_SENSE_AS_AGENT, will that cause the osIsNpc function to NOT detect it as a NPC but rather as an agent? Without any information on the options to the osNpcCreate function, it is kind of hard to know for sure if something is or is not a bug.

Responding with the wrong UUID isn't right either. If it is not an AGENT then maybe osAvatarName2Key should silently fail for an NPC that is created like I have done. Or, add some information to the wiki about the operation of both these commands. Reporting the UUID based on the name of an NPC should not result in different results for the same name. I do understand it is completely possible to have several of the same named NPC's on a region. I do that with one named "Sally" as an animated sign holder at different places on one of my regions.

I'm not sure if Ubit fixed or changed the function. I'll use the test script posted earlier to check the way I create the NPC to see if it works right in the current "master". I'll work on doing that over the weekend and report back.

I hate to report a problem and then not provide feedback if something has been changed. That does not show respect for the hard work the Dev's put into this code.

I have the test script ready and tested it on my current opensim code with the bug in it and it fails in two ways. It still does not report the correct UUID but rather the remembered first UUID even using the option of OS_NPC_SENSE_AS_AGENT. However then using that option it now does not detect the NPC as an NPC but as an agent by the osIsNpc function.

I'm not sure why you would want to be creating NPC's that looked as if they were a true AGENT. I guess someone had a good reason for doing this and added that option. In my case I need NPC's to be NPC's and be detected as such. I have too many scripts working with NPC's to have to come up with some other way to detect if they are or are not an NPC.

Technically the osIsNpc function has a bug in it too or it is not named correctly. The OS_NPC_SENSE_AS_AGENT option has crippled other OS functions in this case.

The wiki says this:
integer osIsNpc(key npc)
Returns NPC status on the provided key
Returns TRUE (1) / FALSE (0) if key provided is an NPC
Returns FALSE (0) if the key provided doesn't exist in the scene.

It says nothing about being able to be defeated by using the OS_NPC_SENSE_AS_AGENT option when the NPC was created.

This should be mentioned on the wiki for both of these functions.
Mandarinka Tasty (reporter)
2018-10-20 16:05

@slow putzo

In my opinion, the OSSL function: osAvatarName2Key should not be used to detect UUID of NPC.
The main reason is, as you have noticed above, more than one NPC in a scene = region, can use the same name. So for what to ask about its UUID in such case? Illogical for me. That is why the function osGetNpcList has been designed to return NPC's key.
Certainly, we assume, that you want not only owner of NPC get possibility to find NPC's key, am I right ? Because if only owner should be provided with such info, you may trace all keys of rezzed NPCs using osNpcCreate(...).

The flag; OS_NPC_SENSE_AS_AGENT has been designed to make NPC be recognised as an avatar using such functions like :llSensor etc, but not make NPC become an avatar, that is why you observe certain differences between application of osIsNpc and flag OS_NPC_SENSE_AS_AGENT.
That means = NPC that has been created with possibility to be sensed as an agent ( via llSensor) is still valid NPC. right ?

It is trivial to implement ossl function to return key of NPC via providing its name, I can do that within minutes just for you. but again, what you want to be returned if you rezz 10 NPCs with your name: "Sally" ?
That is why i would recommend you using osGetNpcList().
And i would also remove detection of NPC within osAvatarName2Key as i did with: llName2Key and llRequestUserKey.
slow putzo (reporter)
2018-10-20 19:01
edited on: 2018-10-20 19:02

"That is why i would recommend you using osGetNpcList()"

I totally agree, and have done so in my code. However that does not suggest I agree that osAvatarName2Key is not broken unless we are saying that choice of words isn't important. In that case either osIsNpc or osAvatarName2Key are broken because they do not do specifically what their name implies all of the time under any case.

I won't go into that the wiki is light years behind what the developers have put into opensim. That as a given, exactly where is the documentation on what the developers are building these functions to? Or is it just willy nilly?

osIsNpc is rather specific in it's name. But if I give it the UUID of a NPC that was created using OS_NPC_SENSE_AS_AGENT it returns false. Wonderful, now there is no way short of writing complex, time and cycle consuming routine to do a job a single function says it does.

You can't have it both ways. osAvatarName2Key says it returns the UUID of the avatars name. OK, it does exactly that, and it is listed under the "Avatar" functions in the wiki. However it does not give you correct information if you give it the name of an NPC. It should return something like a NULL_KEY or FALSE, not the UUID of some previous incarnation of a NPC with that name and that is what it is currently doing.

In the case of osIsNpc it says it returns TRUE or FALSE if it is an NPC, and FALSE if it does not exist.

Once again, what the hell does "returns TRUE / FALSE" mean if it is an NPC?
The function is asking is this UUID an NPC. That is a yes or no question. But the present implementation is such that FALSE can be returned by this specific function which is suppose to be telling you if the UUID is or is not a NPC. It's not a scanner where you are looking for "agents". It's a specific function to tell you if it is or is not an NPC.

Oddly enough osGetAvatarList() returns both AGENTS and NPC's if the NPC is created without the OS_NPC_SENSE_AS_AGENT option.
Back to does the name mean anything? Apparently not. The wiki would not give you any indications these functions were exclusive to a specific kind of AVATAR/NPC. There is even an inconsistency in how specific the listing of AVATAR and NPC is since each function is poorly documented and even less obvious based on their names.

I am not suggesting the functions be changed, only that the wiki states what the function does and does not do and under what conditions. Only the code writers are able to provide that information to my knowledge.

To have unpublished specifications only provides a programmer with useless functions because they can be changed to do anything the developer wants and since there are no specifications, they can say working as designed. Well I bet you don't accept that for the language opensim is written in.

Here is the test case I am working with to decide how these instructions work. I have similar logic in my real code but have switched to using osGetNpcList to get the UUID and name. Actually I used osGetAvatarList() because it gave me both, but I most likely will use osGetNpcList.

The issue now is that even getting the UUID of a real NPC I still can't use osIsNpc in an object where I want to know if the person sitting on it is an avatar or NPC. That is because you can defeat the function by using OS_NPC_SENSE_AS_AGENT when creating the NPC.

key bot = NULL_KEY;

    touch_end(integer a)
        llSay(0, "\n");
        osAgentSaveAppearance(llDetectedKey(0), "myclone"); // create appearance card
// bot = osNpcCreate("MyNPC", "Clone", llGetPos(), "myclone", OS_NPC_SENSE_AS_AGENT) ;
        bot = osNpcCreate("MyNPC", "Clone", llGetPos(), "myclone", OS_NPC_NOT_OWNED) ;
        list Agents = osGetAgents();
        integer AgentsLength = llGetListLength( Agents );
        if (AgentsLength!=0)
            integer i;
            for (i = 0; i < AgentsLength; i++)
                string AvatarName = llList2String( Agents, i );
                list NameParts = llParseString2List( AvatarName, [" ",".","@"],[]); // break it into parts
                string FirstName = llList2String( NameParts, 0 );
                string LastName = llList2String( NameParts, 1 );
                key AgentUUID = osAvatarName2Key(FirstName, LastName);
                    llSay(0, "Detected a NPC");
                    llSay (0, "NPC: "+ AvatarName);
                    llSay (0, "AgentUUID: "+ (string)AgentUUID);
                    llSay (0, "botUUID: "+ (string)bot);
                    llSay(0, "Detected an AGENT");
                    llSay (0, "Agent: "+ AvatarName);
                    llSay (0, "AgentUUID: "+ (string)AgentUUID);
                AgentUUID = NULL_KEY;
        if (bot != NULL_KEY) osNpcRemove(bot);

I believe the logic is sound. It points out the issue I posted this bug under, with the use of osAvatarName2Key and osIsNpc.

I concede the fact osAvatarName2Key does not specifically say NPC's.
On the other hand osIsNpc does but will not report an NOC which was created with the option OS_NPC_SENSE_AS_AGENT.

Has anyone checked if this new command osGetNpcList() has this same fault?

If it walks like a NPC, talks like a NPC, it's an NPC.
Sound familiar?
If it walks like a duck, talks like a duck, it's an duck.

slow putzo (reporter)
2018-10-20 19:23


I am having trouble compiling opensim for windows and may need to wait until the next update OSgrid puts out. I was running the OSgrid 9/30/2018 release when I reported this, and have the 10/8/2018 release now running which exhibits the same issue. That predates your comment of "should be better on master now" and I did want to give you reliable feedback.
BillBlight (developer)
2018-10-20 20:47
edited on: 2018-10-20 20:48

What issues compiling on windows, the report says running on linux?

For windows it does require .net 4.6 or it will not compile(correctly).

For linux mono 5.x or higher 5.12x+ is recommended ..

slow putzo (reporter)
2018-10-21 20:23

The standalone is running on Linux but I download and compile everything on my windows 10 machine.

Windows 10 says it is all up to date .NET Framework 4.7

I don't think it's a .net issue I think it's the procedure I use. It is very old as it has been several years since I tried to do a compile.

I'll sit tight and wait for OSgrid release as they have been fairly regular lately.

Thanks for the information though.
BillBlight (developer)
2018-10-21 20:38

compiling on windows and running that same binary on linux is not really the best idea .. Compile on the the system you intend to run on for best results ..
UbitUmarov (administrator)
2018-10-23 07:29

putzo review [^]
always good idea to do it on a clean folder
( and never forgot to go by the pain process of customizing that version ini files for your needs, using older ones as reference only)
kcozens (administrator)
2018-10-23 12:49

commit 8b5b251d1ae22656815217d96585c4798796db52
Author: UbitUmarov <>
Date: Sat Oct 20 14:10:56 2018 +0100

    mantis 8398: fix with previus commits; removed redundante code

- Issue History
Date Modified Username Field Change
2018-10-19 12:18 slow putzo New Issue
2018-10-19 14:09 Luisillo_Contepomi Note Added: 0033198
2018-10-20 02:30 Luisillo_Contepomi Note Edited: 0033198 View Revisions
2018-10-20 02:48 Luisillo_Contepomi Note Edited: 0033198 View Revisions
2018-10-20 06:00 Luisillo_Contepomi Note Edited: 0033198 View Revisions
2018-10-20 06:00 Luisillo_Contepomi Note Edited: 0033198 View Revisions
2018-10-20 06:17 UbitUmarov Note Added: 0033199
2018-10-20 13:48 slow putzo Note Added: 0033204
2018-10-20 16:05 Mandarinka Tasty Note Added: 0033205
2018-10-20 19:01 slow putzo Note Added: 0033206
2018-10-20 19:02 slow putzo Note Edited: 0033206 View Revisions
2018-10-20 19:23 slow putzo Note Added: 0033207
2018-10-20 20:47 BillBlight Note Added: 0033215
2018-10-20 20:48 BillBlight Note Edited: 0033215 View Revisions
2018-10-21 20:23 slow putzo Note Added: 0033234
2018-10-21 20:38 BillBlight Note Added: 0033236
2018-10-23 07:29 UbitUmarov Note Added: 0033250
2018-10-23 12:49 kcozens Note Added: 0033252

Copyright © 2000 - 2012 MantisBT Group
Powered by Mantis Bugtracker