Jump to content


Photo

Синтаксис в скриптах SQF


Best Answer SteelRat , 20 October 2014 - 17:50

 

В ините бота: null = [this, 300] ExecVM "Scripts\civil.sqf"    

300 - Это радиус поиска зданий относительно бота.

this setVariable ["radLoiter", 300];
null = this ExecVM "Scripts\civil.sqf"
//	Этот скрипт заставляет бота "сланяться" по городу.
 
_unit	= _this;
_radius	= _this getVariable ["radLoiter", 300]; // Если переменная не определена, будет применено значение по умолчанию 300
 
_list = position _unit nearObjects _radius;
_count_l = count _list;
_bPos = _list select floor random _count_l;
_nBuilding = nearestBuilding _bPos;
 
 
_pos = getPos _nBuilding;
_wp = group _unit addWaypoint [_pos, 0];
_wp setWaypointType "MOVE";
_wp setWaypointSpeed "LIMITED";
_wp setWaypointBehaviour "CARELESS";
_wp setWaypointTimeout [5, 15, 30];
_wp setWaypointStatements ["true", "null = this ExecVM 'Scripts\civil.sqf'"];
Go to the full post


  • Please log in to reply
7 replies to this topic

#1 OFFLINE   Dobryi_33RUS

Dobryi_33RUS

    Ефрейтор

  • Пользователи
  • 85 posts
  • Откуда:Россия

Posted 19 October 2014 - 08:01

Пример скрипта:
 
_unit = _this select 0; 
_radius = _this select 1; 
_wp setWaypointStatements ["true", "null = [this, ????] ExecVM 'Scripts\civil.sqf'"]; 
 
Запускается сей скрипт таким оброзом: null = [this, 300] ExecVM "Script.sqf";         
 
 
Вопрос:
 
Как инит вэйпоинта предать значение переменной _radius ?
_wp setWaypointStatements ["true", "null = [this, ????] ExecVM 'Scripts\civil.sqf'"] 
 
 
 
 

  • 0

#2 OFFLINE   vlad333000

vlad333000

    Полковник

  • Пользователи
  • 3224 posts
  • Откуда:Кострома

Posted 19 October 2014 - 09:07

Как инит вэйпоинта предать значение переменной _radius ?

_wp setWaypointStatements ["true", "null = [this, _radius] ExecVM 'Scripts\civil.sqf'"] - не работает?
  • 0

#3 OFFLINE   Dobryi_33RUS

Dobryi_33RUS

    Ефрейтор

  • Пользователи
  • 85 posts
  • Откуда:Россия

Posted 19 October 2014 - 09:22

 

Как инит вэйпоинта предать значение переменной _radius ?

_wp setWaypointStatements ["true", "null = [this, _radius] ExecVM 'Scripts\civil.sqf'"] - не работает?

 

Нет, насколько я понимаю, в ините строка выглядит так же(null = [this, _radius] ExecVM 'Scripts\civil.sqf'"]).

Нужно, что бы в место _radius было цифровое значение.


Edited by Dobryi_33RUS, 19 October 2014 - 09:23.

  • 0

#4 OFFLINE   vlad333000

vlad333000

    Полковник

  • Пользователи
  • 3224 posts
  • Откуда:Кострома

Posted 19 October 2014 - 09:47

Нет

А ты точно проверил?!

насколько я понимаю, в ините строка выглядит так же(null = [this, _radius] ExecVM 'Scripts\civil.sqf'"]).

Пожалуйста Войдите или Зарегистрируйтесь чтобы увидеть скрытое содержание

- все, что арма понимает как строчка
В mission.sqm твоя строчка (если бы писал в вейпойнте) выглядела бы так:
"null = [this, _radius] ExecVM ""Scripts\civil.sqf"";
Можно попробовать и {}
["true", {null = [this, _radius] ExecVM "Scripts\civil.sqf"}]

Edited by vlad333000, 19 October 2014 - 09:47.

  • 0

#5 OFFLINE   Dobryi_33RUS

Dobryi_33RUS

    Ефрейтор

  • Пользователи
  • 85 posts
  • Откуда:Россия

Posted 19 October 2014 - 11:21

 

Нет

А ты точно проверил?!

насколько я понимаю, в ините строка выглядит так же(null = [this, _radius] ExecVM 'Scripts\civil.sqf'"]).

Пожалуйста Войдите или Зарегистрируйтесь чтобы увидеть скрытое содержание

- все, что арма понимает как строчка
В mission.sqm твоя строчка (если бы писал в вейпойнте) выглядела бы так:
"null = [this, _radius] ExecVM ""Scripts\civil.sqf"";
Можно попробовать и {}
["true", {null = [this, _radius] ExecVM "Scripts\civil.sqf"}]

 

Точнее не бывает))

Может ты меня не до понял, объясню по подробней.

 

Вот скрипт целиком:

Этот скрипт заставляет бота "сланяться" по городу.

 

_unit = _this select 0;
_radius = _this select 1; 
 
_list = position _unit nearObjects _radius;
_count_l = count _list;
_bPos = _list select floor random _count_l;
_nBuilding = nearestBuilding _bPos;
 
 
_pos = getPos _nBuilding;
_wp = group _unit addWaypoint [_pos, 0];
_wp setWaypointType "MOVE";
_wp setWaypointSpeed "LIMITED";
_wp setWaypointBehaviour "CARELESS";
_wp setWaypointTimeout [5, 15, 30];
_wp setWaypointStatements ["true", "null = [this, ????] ExecVM 'Scripts\civil.sqf'"];

 

 

В ините бота: null = [this, 300] ExecVM "Scripts\civil.sqf"    

300 - Это радиус поиска зданий относительно бота.

 

Вопрос: 

Как мне это число(в данном случае 300) передать в инит, другими словами, что бы строка в ините вейпоинта(созданной скриптом) была такая же как изначально в ините бота(null = [this, 300] ExecVM "Scripts\civil.sqf")


Edited by Dobryi_33RUS, 19 October 2014 - 11:32.

  • 0

#6 OFFLINE   SteelRat

SteelRat

    Полковник

  • Пользователи
  • 3241 posts
  • Откуда:РФ

Posted 20 October 2014 - 17:50   Best Answer

 

В ините бота: null = [this, 300] ExecVM "Scripts\civil.sqf"    

300 - Это радиус поиска зданий относительно бота.

this setVariable ["radLoiter", 300];
null = this ExecVM "Scripts\civil.sqf"
//	Этот скрипт заставляет бота "сланяться" по городу.
 
_unit	= _this;
_radius	= _this getVariable ["radLoiter", 300]; // Если переменная не определена, будет применено значение по умолчанию 300
 
_list = position _unit nearObjects _radius;
_count_l = count _list;
_bPos = _list select floor random _count_l;
_nBuilding = nearestBuilding _bPos;
 
 
_pos = getPos _nBuilding;
_wp = group _unit addWaypoint [_pos, 0];
_wp setWaypointType "MOVE";
_wp setWaypointSpeed "LIMITED";
_wp setWaypointBehaviour "CARELESS";
_wp setWaypointTimeout [5, 15, 30];
_wp setWaypointStatements ["true", "null = this ExecVM 'Scripts\civil.sqf'"];

  • 0

#7 OFFLINE   Dobryi_33RUS

Dobryi_33RUS

    Ефрейтор

  • Пользователи
  • 85 posts
  • Откуда:Россия

Posted 20 October 2014 - 18:37

 

 

В ините бота: null = [this, 300] ExecVM "Scripts\civil.sqf"    

300 - Это радиус поиска зданий относительно бота.

this setVariable ["radLoiter", 300];
null = this ExecVM "Scripts\civil.sqf"
//	Этот скрипт заставляет бота "сланяться" по городу.
 
_unit	= _this;
_radius	= _this getVariable ["radLoiter", 300]; // Если переменная не определена, будет применено значение по умолчанию 300
 
_list = position _unit nearObjects _radius;
_count_l = count _list;
_bPos = _list select floor random _count_l;
_nBuilding = nearestBuilding _bPos;
 
 
_pos = getPos _nBuilding;
_wp = group _unit addWaypoint [_pos, 0];
_wp setWaypointType "MOVE";
_wp setWaypointSpeed "LIMITED";
_wp setWaypointBehaviour "CARELESS";
_wp setWaypointTimeout [5, 15, 30];
_wp setWaypointStatements ["true", "null = this ExecVM 'Scripts\civil.sqf'"];

Огромное спасибо!

 

 

 

Вот, что у меня получилось:

Скрипт заставляет ботов "сланятся" по городу и заходить друг к другу в гости))

 

активация, в инит:   null = [this, Радиус в метрах***] ExecVM 'Scripts\civil.sqf'"]; 

***Радиус в метрах - относительно бота.

 

 

_unit = _this select 0;
_radius = _this select 1; 
 
 
_unit setVariable ["radius", _radius];
 
_list = position _unit nearObjects _radius;
_count_l = count _list;
_bPos = _list select floor random _count_l;
_nBuilding = nearestBuilding _bPos;
_nBPos = [_nBuilding] call BIS_fnc_buildingPositions;
_nPos = count _nBPos;
_nPos = floor random _nPos;
_pos = getPos _nBuilding;
 
 
 
deleteWaypoint [_unit, all];
_wp = group _unit addWaypoint [_pos, 0];
_wp waypointAttachObject _nBuilding; 
_wp setWaypointHousePosition _nPos;
_wp setWaypointType "MOVE";
_wp setWaypointSpeed "LIMITED";
_wp setWaypointBehaviour "CARELESS";
_wp setWaypointTimeout [5, 15, 30];
_wp setWaypointStatements ["true", "result = this getVariable ['radius', 0];  null = [this, result] ExecVM 'Scripts\civil.sqf'"];

Edited by Dobryi_33RUS, 20 October 2014 - 18:46.

  • 0

#8 OFFLINE   SteelRat

SteelRat

    Полковник

  • Пользователи
  • 3241 posts
  • Откуда:РФ

Posted 21 October 2014 - 01:17

 

 

_wp setWaypointStatements ["true", "result = this getVariable ['radius', 0];  null = [this, result] ExecVM 'Scripts\civil.sqf'"];

 

вполне можно обойтись и без лишней переменной

_wp setWaypointStatements ["true", "null = [this, (this getVariable ['radius', 0])] ExecVM 'Scripts\civil.sqf'"];

  • 0




Яндекс.Метрика