Пятница, 18.07.2025, 20:30

Мой блог

Главная | Регистрация | Вход
Приветствую Вас Гость
RSS
Форма входа
Календарь
«  Декабрь 2008  »
Пн Вт Ср Чт Пт Сб Вс
1234567
891011121314
15161718192021
22232425262728
293031
Поиск
Друзья сайта
Статистика

Дневник


Главная » 2008 » Декабрь » 14 » Создаем радар
Создаем радар
17:16

Скрипт "радара", радиус действия 100 м.

list gHere = [];

default
{
  state_entry()
  {
  llOwnerSay("Scanner initialised");
  // Clear any text hanging around
  llSetText("", <0,1,0>, 1.0);
  llSetAlpha(1.0, ALL_SIDES);
  // Start a sensor for agents within 20m
  llSensorRepeat("", NULL_KEY, AGENT, 300, PI, 2);
  }

  no_sensor()
  {
  // If nobody is detected, everyone has left
  // Go through old list and say that everyone on it has gone
  llSetText("", <0,1,0>, 1.0);
  if (gHere != []) {
  integer f;
  integer c = llGetListLength(gHere);
  for (f=0; f<c; f++) { // go through old list
  //llOwnerSay(llList2String(gHere, f) + " has left chat range");
  }
  gHere = [];
  }
  }

  sensor(integer total_number)
  {
  integer f;
  string name = "";
  string display = "";
  list here = [];
  string status = "";
  integer info = 0;
  vector myPos = llGetPos();
  // Make a list of people who are within range
  for (f=0; f<total_number; f++) {
  name = llDetectedName(f);
  here += name;
  info = llGetAgentInfo(llDetectedKey(f));
  status = "";
  if (info & AGENT_AWAY) status += " (AWAY)";
  if (info & AGENT_BUSY) status += " (BUSY)";
  if (info & AGENT_TYPING) status += " (TYPING)";
  display += name + " @ " + (string)llRound(llVecDist(llDetectedPos(f), myPos)) + "m" + status + "\n";
  //if (llListFindList(gHere, [name]) == -1) llOwnerSay(name + " has entered chat range");
  }
  // Now check to see if anyone has left,
  // based on the list from the last scan
  here = llListSort(here, 1, TRUE); // sort list
  integer c = llGetListLength(gHere);
  if (here != gHere) { // if new list not the same as old one
  for (f=0; f<c; f++) { // go through old list
  name = llList2String(gHere, f);
  // If anyone on old list is not on new list,
  // say that they have left
  // if (llListFindList(here, [name]) == -1) llOwnerSay(name + " has left chat range");
  }
  }
  // Update old list variable
  gHere = here;
  // Display the people who are here now
  llSetText(display, <0,1,0>, 1.0);
  }

  touch_start(integer n)
  {
  // Turn it off when touched by owner
  if (llDetectedKey(0) == llGetOwner()) state dormant;
  }
}

state dormant
{
  state_entry()
  {
  llOwnerSay("Scanner deactivated");
  llSetText("", <0,0,0>, 1.0);
  llSetAlpha(0.5, ALL_SIDES);
  gHere = [];
  }

  touch_start(integer n)
  {
  // Turn it back on if touched by owner
  if (llDetectedKey(0) == llGetOwner()) state default;
  }
}


Вставляем в объект, прикрепляем к экрану как HUD

Просмотров: 966 | Добавил: volldemar | Рейтинг: 0.0/0 |
Всего комментариев: 0
Имя *:
Email *:
Код *:
Copyright MyCorp © 2025
Сайт управляется системой uCoz