Jump to content

Chat commands after ownership change


Kasia Mistwood
 Share

You are about to reply to a thread that has been inactive for 3463 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hello,

 

I would like to ask If anyone could hep me with rather simple script...

Ive made a script that rotates the texture when I say 'start' in the local chat, and stops it when I say 'stop'. Works perfectly so far.

I wanted to give it to someone and it seems it doesnt work with anyone but me... Ive tried my best to repair it, and make it work after transfer to someone but I failed :(

I would like to keep the local chat start/stop feature for next owner.

 

Here is what I begun with;

 

default
{
    state_entry()
    {
        llListen(0,"",llGetOwner(),"");
    }
 
    listen(integer channel, string name, key id, string message)  
    {
        if(message=="stop")
        {
            llTargetOmega(<0,0,0>,PI,1.0);
        }
        if(message=="start")
        {
            llTargetOmega(<0,0,8>,PI,1.0);
    }
}
}

 

I've tried to change 

 

llListen(0,"",llGetOwner(),"");

 

with

 

llListen( 0, "", NULL_KEY, "" )

 

and later add:

 

 on_rez(integer start_param)
    {
        llResetScript();
    }
 
    changed(integer change)
    {
        if (change & (CHANGED_OWNER | CHANGED_INVENTORY))
            llResetScript();
    }
 

 

but nothing worked...

 

Cant really tell anymore what might be wrong myself... Hoped that simple change would solve the problem but it seems more complex. I would appreciate any solution, thanks a lot for your reply

 

Thanks

Link to comment
Share on other sites

Try

default{    state_entry()    {        llListen(0,"",llGetOwner(),"");    }    changed (integer change)    {        if (change & CHANGED_OWNER)        {            llResetScript();        }    }     listen(integer channel, string name, key id, string message)      {        if(message=="stop")        {            llTargetOmega(<0,0,0>,PI,1.0);        }        if(message=="start")        {            llTargetOmega(<0,0,8>,PI,1.0);        }    }}

 I seriously advise you not to listen on the public chat channel, though.  At the very least, use a low non-zero channel that will have less traffic on it and will cause less lag for the sim.

Link to comment
Share on other sites

Thanks a mill Rolig,

Its working great now, even passed around a lot :D

When it comes to the channels used... At first I was trying to avoid using chat at all. I was looking into making a HUD with a button that clicked would say 'start' on any channel which would make a prim inworld perform simple action. After few failed tries, based on scripts found, I've decided to move back to chat solution... Ill have a look into changing the channel used, but would also like to ask if you knew by a chance where to look for a smiple HUD-prim script? I mean as simple as rotating a prim on HUD click...

Thanks again :)

Link to comment
Share on other sites

There's nothing magical about a HUD script.  It's the same as any script you'd write for a prim rezzed in world that was meant to perform the same actions.  For example, put this in a prim:

integer gON;default{    touch_start (integer num)    {        llSay(-1234,llList2String(["stop","start"],(gON = !gON)) );    }}

 When you click it, it will speak on channel -1234.  The first time you click, the message will be "start".  The next time, it will be "stop".  It will keep alternating like that.  It doesn't make any difference whether the prim is on the ground or attached to your screen as a HUD.  It still works the same way.  If you have some other object within chat distance that is listening on channel -1234, it will hear it.

 

Link to comment
Share on other sites

Dear Rolig,

 

Thanks again for your quick and accurate answer :), and again Im sorry for replying so slowly myself.

 

Ive spent some time experimenting with channels and Im affraid Ill have to ask one or two more questions (Im trying to learn as quick as I can, but...)

 

Ive put the script for the HUD you gave me into an object and worn it as a HUD. It was possible to click the HUD. Then, Ive put the script into an inworld object and tried if the hud switched the object On. Unfortunately It didnt :((

 

The script for receiver was like that, with the channel adapted to sender (-1234):

 

default{    state_entry()    {        llListen(-1234,"",llGetOwner(),"");    }    changed (integer change)    {        if (change & CHANGED_OWNER)        {            llResetScript();        }    }     listen(integer channel, string name, key id, string message)      {        if(message=="stop")        {            llTargetOmega(<0,0,0>,PI,1.0);        }        if(message=="start")        {            llTargetOmega(<0,0,8>,PI,1.0);        }    }}

 

When I changed channel from "-1234" to positive "1234" it also gave nothing, but positive channel made it work using chat command "/1234 start".

 

I understand that there must be something wrong with the say/listen part synchronization:

 

Sender:

 

llSay(-1234,llList2String(["stop","start"],(gON = !gON)) );

 

Receiver:

 

llListen(-1234,"",llGetOwner(),"");

 

...but I couldnt find out what. Ive tried with llMassageLinked and later changing "llGetOwner" into llList2String, but it only created more mismatches...Or maybe its the 'owner' part that makes some troubles here...? Maybe theres something you could suggest looking at those codes, I would be so grateful for that help.

 

Also, would like to thank you again for your help, time and support :D :D :D So much appreciated :D

Link to comment
Share on other sites

The "catch" is that avatars cannot receive messages on negative channels and can't normally send them either.  (The Firestorm viewer and -- I think -- a couple of others are a little more flexible.) So if you write your listen handle as

llListen(-1234,"",llGetOwner(),"")

that pretty much filters out any possible messages that the script might listen for.

Also, when it's your HUD sending a message, the receiving script shouldn't be listening for something from you (llGetOwner), but for something owned by you.  The best way to handle that is to leave the listen handle as

llListen(-1234,"","","")

and then filter later, in the listen event with

if (llGetOwnerKey(id) == llGetOwner)

Your script will be checking to see who owns the object that sent the message and then seeing if that person is you.

BTW, llMessageLinked is never goling to work in this case, because your HUD and the receiving object are not linked.

Link to comment
Share on other sites

  • 2 weeks later...

So Happy :D

 

I have changed the scripts listen handle as you said and its working great, even transferred or copied. That is just awesome, its exactly what i was trying to learn to do :D

 

Thank you so much Rolig, I appreciate it a lot :)

 

Thats how it looks like at the end;

 

Sender:

 

integer gON;default{    touch_start (integer num)    {        llSay(-1234,llList2String(["stop","start"],(gON = !gON)) );    }}

 

Receiver:

 

default{    state_entry()    {        llListen(-1234,"","","");    }    changed (integer change)    {        if (change & CHANGED_OWNER)        {            llResetScript();        }    }     listen(integer channel, string name, key id, string message)      {        if(message=="stop")        {            llTargetOmega(<0,0,0>,PI,1.0);        }        if(message=="start")        {            llTargetOmega(<0,0,8>,PI,1.0);        }    }}

 

:D

 

Link to comment
Share on other sites

Hehe... except that now there's no reason to restart the script when you change owners, since nothing in the script depends on knowing who the owner is.  If you really want to preserve the owner acess feature, you'll still have to include that if test to see whether the owner of the object that sends the On/Off message is the same as the owner of the receiving script.

Link to comment
Share on other sites

Yes, I was thinking about it, and came to few things... At first I thought that its fine that way because It is impossible for any avatar to send any accidental 'ON' command on the local chat (since it cant communicate on negative channels effectively on regular viewer). In the first script, anyone could start the object even by typing 'start' at the local chat accidently (to start something else or so...). Now there is nothing any person can do to start it 'verbally'. So no one passing my house saying start randomly will set it on fire :)

But, there is a possible situation I can imagine when it would be still better to have the owner checked. It is if my object was placed around someone with another HUD or object saying 'start' on -1234 channel. So for example if I made a HUD witch operates my house (like switching all lights, switching halloween particles on my tree and filling the pool) and shared it with my neighbour or shared only the channel number with my neighbour, we would switch each others furnitures ON. Thinking about it Ive tried to change the script again... And when I try to put the part

 

if (llGetOwnerKey(id) == llGetOwner)

 in the listen event, after the part

 

llListen(-1234,"","","");

it tells me the name is not defined within the scope. Should I add another listen event? or should it be as 'key'? Because I understood I should remove the 'reset part' and definitely start with llListen(-1234,"","","")? Like:

 

default{    state_entry()    {        llListen(-1234,"","","");    }     listen(integer channel, string name, key id, string message)      {        if(message=="stop")        {            llTargetOmega(<0,0,0>,PI,1.0);        }        if(message=="start")        {            llTargetOmega(<0,0,8>,PI,1.0);        }    }}

 

Or should I have left the reset part and add the owner part to the  'changed' event?

 

I finished with:

 

default{    state_entry()    {        llListen(-1234,"","","");    }         listen(integer channel, string name, key id, string message)      {    if (llGetOwnerKey(id)==llGetOwner()){        if(message=="stop")        {            llTargetOmega(<0,0,0>,PI,1.0);        }        if(message=="start")        {            llTargetOmega(<0,0,8>,PI,1.0);        }    }}}

 

 But I dont know If its ok. Its working and is possible to save (rare with my scripting). But could you please tell me if it is what was needed to make it work for owner only?

 

Thank you so much again :D

 

Link to comment
Share on other sites

Neither.  Think about the logic here. The goal of that if test is to determine whether the message that your script hears is coming from you (or an object that you own).  If it is, then the script should poay attention.  If not, the script should ignore the message.  So, where should it be asking that question?  In the listen event.  After all, that's where it is hearing the message.  You want to wrap that test around everything in the event, so that the listen is only effective when the result of the test is TRUE.

listen (integer channel, string name, key id, string message){    if (llGetOwnerKey(id) == llGetOwner())    {        // Do stuff    }}

 Now, your basic observation about channel conflicts is a good one.  You always need to keep in mind the possibility that someone else might send a signal on the channel you're using for your device.  Putting an Owner filter on the script will pretty much take care of the problem, but there are other logical way to handle it.  For one, -1234 is a ridiculously easy channel number for someone else to stumble onto.  I used it only as an example, not expecting that you would actually keep it in your final script.  It';s much smarter to use a large negative number like, say, -82711825.  The chances of someone else using it at the same time as you are slim.  (Just remember to use the same channel in your sending script.)  You can also reduce the possibility of conflicts by using signal words that are a bit less obvious than "start" and "stop".  Try "Giddyap!" and ":Whoa!", for example.  :smileytongue:

 EDIT:  Whee!  You did it while I was typing my response.  Congratulations.  Perfect.  :smileywink:

Link to comment
Share on other sites

Yes, I've tried again, and it worked, im so glad it was the same as yours. Just wasnt sure If it was going to work for real or was just going to be an another fail :D

 

I know the -1234  is just an example heheh I will sort out something of my own. And yes, since the comunication is done by touching the prim, the 'start' phrase can be switched to 'giaudohvdaousip' which preety much sorts the problem out for good :)

 

I would like to thank you so much Rolig. Untill today I was touching or telling everything to do things in public :P and now it all got so much easier :) Thanks :)

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3463 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...