Jump to content
Blitzen88

How to Modify Spawn AI Module Expression Field via Script?

Recommended Posts

How do you modify a Spawn AI Module's Expression Field via a Script?  Particularly, how do you modify it while retaining the existing input?  For instance:

 

Call with: [SpawnModule] execVM ScriptPath

_SpawnModule = _this select 0;

_Expression = ?? Get variable ??

_NewExpression = _Expression + (New Stuff)

Thanks

Share this post


Link to post
Share on other sites

Hey @Blitzen88,

 

Paste this in the expression field of the Spawn AI module:

_this execVM "Script.sqf";

 

You can then save the input as variables using the params command:

// Paste this near the top of your script file.
params ["_Group", "_Module", "_GroupData"];

 

  • _Group = The group that was spawned by the module.
  • _Module = The module where the group was spawned (I think?)
  • _GroupData = An array of various info relating to the group.

 

Honestly, I've only really used the _Group parameter whenever I've used Spawn AI in missions, so take the rest with a grain of salt.

 

Hope this helps! 😎

Share this post


Link to post
Share on other sites
7 hours ago, Mr Elusive said:

Hey @Blitzen88,

 

Paste this in the expression field of the Spawn AI module:


_this execVM "Script.sqf";

 

You can then save the input as variables using the params command:


// Paste this near the top of your script file.
params ["_Group", "_Module", "_GroupData"];

 

  • _Group = The group that was spawned by the module.
  • _Module = The module where the group was spawned (I think?)
  • _GroupData = An array of various info relating to the group.

 

Honestly, I've only really used the _Group parameter whenever I've used Spawn AI in missions, so take the rest with a grain of salt.

 

Hope this helps! 😎

Thanks for the reply. I already use that for scripts which are called from the expression field. Im trying to figure out if you can change the script with another script. 

Share this post


Link to post
Share on other sites
15 hours ago, Blitzen88 said:

Im trying to figure out if you can change the script with another script. 

 

My apologies @Blitzen88 I've obviously misread your post. It was late at night when I looked at it.

 

The contents of the expression field are saved in a variable within the module. You can give the module a variable name, then use getVariable and setVariable commands to edit.

 

For example...

// Grab the current contents of the 'expression' field:
_Expression = _Module getVariable "expression";

// Update the contents of the 'expression' field:
_Module setVariable ["expression", {comment "Your code here"}];

 

Does this help?

Share this post


Link to post
Share on other sites
8 hours ago, Mr Elusive said:

 

My apologies @Blitzen88 I've obviously misread your post. It was late at night when I looked at it.

 

The contents of the expression field are saved in a variable within the module. You can give the module a variable name, then use getVariable and setVariable commands to edit.

 

For example...


// Grab the current contents of the 'expression' field:
_Expression = _Module getVariable "expression";

// Update the contents of the 'expression' field:
_Module setVariable ["expression", {comment "Your code here"}];

 

Does this help?

Thank you, thats what I was looking for!

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×