DarkEmperor13 Posted July 11, 2019 Share Posted July 11, 2019 I need some help. I'm trying to make a turret that when senses a player, it points at them. I got the whole rotation thing down. default { state_entry() { llSensorRepeat("", NULL_KEY, AGENT, 15.0, PI, 0.2); llSetLinkColor(LINK_THIS, <0,1,0>, ALL_SIDES); } sensor(integer num_detected) { llSetLinkColor(LINK_THIS, <1,0,0>, ALL_SIDES); } no_sensor() { llResetScript(); } } See, I also have a part of the turret that changes between red and greem. Green = Anonymous/Passive & Red = Detected/Hostile. I got the turn red when detected player worked out, but I cant seem to make it go back to green when a player leaves its detection field. Link to comment Share on other sites More sharing options...
Qie Niangao Posted July 11, 2019 Share Posted July 11, 2019 The logic as written will turn the object red if it senses any avatar within 15 meters, so you cannot test this up close because your own avatar will set it off. If you go more than 15m from the object and there's nobody else around, it turns green again. I tested and that works, by the way. Incidentally, running that sensor five times a second (the 0.2 argument) is way too fast to be a responsible use of sim resources. No turret has ever been worth that kind of lag effect on other scripts. 2 Link to comment Share on other sites More sharing options...
Miranda Umino Posted July 11, 2019 Share Posted July 11, 2019 why to reset script at the event no_sensor ? Link to comment Share on other sites More sharing options...
DarkEmperor13 Posted July 11, 2019 Author Share Posted July 11, 2019 well I was going to change it. I just wanted to make sure it works. Now is there a way to exclude the owner? Link to comment Share on other sites More sharing options...
Profaitchikenz Haiku Posted July 11, 2019 Share Posted July 11, 2019 Inside the sensor event you will have 0 to num_found -1 detected agents, so step through the loop using an index >= 0 && < num_found, and ignore llDetectedKey(index) == owner. (Assume you have already set owner by llGetOwner to save repeated calls in the loop) I'd post more but a cat is biting my leg to show he's starving. Link to comment Share on other sites More sharing options...
Mollymews Posted July 12, 2019 Share Posted July 12, 2019 7 hours ago, DarkEmperor13 said: well I was going to change it. I just wanted to make sure it works. Now is there a way to exclude the owner? it is as Prof says. In the sensor event we check for owner and that the owner is the only avatar picked up by the sensor. Example: sensor (integer num_detected) { integer isOwnerOnly = (num_detected == 1) && (llDetectedKey(0) == llGetOwner()); if (!isOwnerOnly) { llSetLinkColor(LINK_THIS, <1,0,0>, ALL_SIDES); } } Link to comment Share on other sites More sharing options...
Recommended Posts
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