Fiddling with NPC for the first time

Creating scripts
Post Reply
User avatar
Baroun Tardis
Posts: 6
Joined: Sun Feb 28, 2021 8:04 pm
Has thanked: 2 times
Been thanked: 10 times

Fiddling with NPC for the first time

Post by Baroun Tardis »

Scripted a lot in SL, feeling my way around in OS

Ran the OS demo script for create a clone. It works fine so long as the position is below <256,256,z> . Above that, the NPC says it creates, and the key seems legit, and I can use a different script to kill it ... but it rez's at <163,83,21.5>
Attempts to do an osNpcMoveTo or MoveToTarget result in it walking like it's stuck on something.
My little workshop is up around <470,250,22> so I'd really like it to come to me rather than going to it, and I'd like to be able to put it where I want it.

Is there some bug with NPCs and variregions that it gets confused at >256 positions?
It's not even getting there, but hanging up before that.
It does keep trying to get to the destination - the osNpcGetPos changes as it tries to walk through something that's not there.

Is there a better way to do this?
I saw something about animated meshes... is there a sample script for that I can dissect?
These users thanked the author Baroun Tardis for the post:
Ilan Tochner
User avatar
Ilan Tochner
Posts: 6503
Joined: Sun Dec 23, 2012 8:44 am
Has thanked: 4942 times
Been thanked: 4454 times
Contact:

Re: Fiddling with NPC for the first time

Post by Ilan Tochner »

Hi Baroun,

Which OSSL functions are called by this script? Can you paste this demo script here please?
Graham Mills
Posts: 1314
Joined: Sun Dec 23, 2012 2:26 pm
Has thanked: 1134 times
Been thanked: 1141 times

Re: Fiddling with NPC for the first time

Post by Graham Mills »

I've done a little with NPCs on Kitely megaworlds and had them patrol above 256, 256, z.

https://twitter.com/vrsimility/status/1 ... 0207108100

There's a basic animesh script at the end of this thread

viewtopic.php?t=5398

with further comments here

viewtopic.php?t=5437
These users thanked the author Graham Mills for the post:
Ilan Tochner
Joelle Tardis
Posts: 1
Joined: Thu Mar 04, 2021 2:44 pm
Has thanked: 0
Been thanked: 0

Re: Fiddling with NPC for the first time

Post by Joelle Tardis »

Scripts used - -

//
// osNpcCreate Script Exemple
// Author: djphil
//

key npc;

default
{
state_entry()
{
llSay(PUBLIC_CHANNEL, "Touch to see osNpcCreate usage.");
}

touch_start(integer number)
{
key toucher = llDetectedKey(0);
vector npcPos = llGetPos() + <1.0, 0.0, 1.0>;
osAgentSaveAppearance(toucher, "appearance");
npc = osNpcCreate("ImYour", "Clone", npcPos, "appearance");
llOwnerSay((string)npc+" created at "+(string)npcPos);
state hasNPC;
}
}

state hasNPC
{
state_entry()
{
llSetTimerEvent(5.0);
}

timer()
{
llSetTimerEvent(0.0);
osNpcSay(npc, "Hello world!");
}

touch_start(integer number)
{
osNpcSay(npc, "Goodbye!");
llSetTimerEvent(0.0);
osNpcRemove(npc);
npc = NULL_KEY;
state default;
}
}

==================


default
{
state_entry()
{
key npc = "f9c5b295-4c75-4f80-a6fa-88301ee24055";
osNpcSay(npc,"Hello!");
osNpcMoveToTarget(npc,<160,200,23>,OS_NPC_FLY);
llSay(0,(string)osNpcGetPos(npc));
}
}
User avatar
Ilan Tochner
Posts: 6503
Joined: Sun Dec 23, 2012 8:44 am
Has thanked: 4942 times
Been thanked: 4454 times
Contact:

Re: Fiddling with NPC for the first time

Post by Ilan Tochner »

You can try replacing llGetPos with osNpcGetPos.
These users thanked the author Ilan Tochner for the post (total 3):
Graham MillsSnoots DwagonAlexina Proctor
Graham Mills
Posts: 1314
Joined: Sun Dec 23, 2012 2:26 pm
Has thanked: 1134 times
Been thanked: 1141 times

Re: Fiddling with NPC for the first time

Post by Graham Mills »

My quick hack to circulate the NPC between five locations, probably rather laggy at scale.

Code: Select all

list posList =[<1062.40210, 808.17059, 21.35000>,
                <868.92542, 826.17444, 21.35000>,
                <877.43176, 882.00000, 21.35000>,
                <886.46490, 924.84503, 21.35000>,
                <1075.18933, 897.45819, 21.35000>];
vector target;
integer p;
key npc;

default
{

    touch_start(integer n)
    {
        p = 0;
        vector npcPos = llGetPos() + <0.0, 0.0, 1.0>;
        npc = osNpcCreate("ImYour", "Clone", npcPos, "appearance1"); 
        target = llList2Vector(posList, p);
        llSetTimerEvent(2.0);
        osNpcMoveToTarget(npc, target, OS_NPC_NO_FLY);
    }
 
    timer()
    {
        if (llVecDist(osNpcGetPos(npc), target) < 3.0)
        {
            if (p == 4)
            {
                p = 0;
            }
            else
            {
                p++;
            }
            target = llList2Vector(posList, p);
            osNpcMoveToTarget(npc, target, OS_NPC_NO_FLY);
        }
    }
}
These users thanked the author Graham Mills for the post (total 3):
Ilan TochnerSnoots DwagonAlexina Proctor
User avatar
Krull Kitty
Posts: 100
Joined: Thu Aug 06, 2020 1:25 pm
Has thanked: 39 times
Been thanked: 81 times

Re: Fiddling with NPC for the first time

Post by Krull Kitty »

I had no idea NPC's could fiddle. :shock:
User avatar
Snoots Dwagon
Posts: 422
Joined: Mon Jul 30, 2018 9:45 pm
Has thanked: 442 times
Been thanked: 779 times

Re: Fiddling with NPC for the first time

Post by Snoots Dwagon »

Krull Kitty wrote:
Wed Mar 10, 2021 12:39 am
I had no idea NPC's could fiddle. :shock:

You kidding? That's all they do. :mrgreen:
These users thanked the author Snoots Dwagon for the post:
Krull Kitty
~~~~~~~
I'm a dwagon in real life too. (Ask my sister, who totally agrees.)

~~~~~~~
Post Reply