[Opensim-users] NPC Persistence over server restarts

Marcus Llewellyn marcus.llewellyn at gmail.com
Fri Oct 14 03:55:42 UTC 2011


On Thu, Oct 13, 2011 at 3:00 PM, Ai Austin <ai.ai.austin at gmail.com> wrote:

>
> I am wanting to have a set of NPCs as assistants set up with MyCyberTwin
> chat capabilities and left in I-Rooms to assist users.  Rather than simple
> 3D people like objects.  But of course they all need to be set back up after
> server restart.
>
>
This is fairly simple to script if you're controlling your NPC from an
unattached object. When you create the NPC, you'll first want to store the
UUID you're given somewhere persistent, like a notecard or the description
field of the object running your NPC script. If your NPC script resets, it
will be able to retrieve your NPCs UUID and continue merrily on its way.

Next you'll want to set up a timer that periodically checks to see whether
your NPC's UUID is still valid. If llKey2Name(UUID) returns your NPC's name,
everything is fine. If it returns an empty string, you can reasonably assume
that the NPC's body isn't present, and recreate it with a new UUID.

This method has allowed NPCs to automatically recreate themselves after a
sim restart on my OSGrid simulator for about two weeks now.

Marcus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://opensimulator.org/pipermail/opensim-users/attachments/20111013/ef6ec855/attachment.html>


More information about the Opensim-users mailing list