Jump to content
krenuds

Excecute script command in the editor?

Recommended Posts

I've spawned many different corpses on the beach. I want to remove all the maps and radios from their equipment but I don't want to click on them one at a time as I've many different corpses to go through. I've tried selecting them all and editing their loadouts together with the loadout editor but it doesn't quite work. It applies the entire (current) loadout to every selected unit. Is there a way that I can run a script within the editor that will do this for me? Not looking for the code, just the technique.

 

Any suggestions?

 

Share this post


Link to post
Share on other sites

Just select all the bodies and edit their init rather than loadout and use unlinkItem command.

if (isServer) then {this unlinkItem "ItemRadio"; this unlinkItem "ItemMap"};

So when the mission loads the items are removed.

If some already have some kind of init code then you could add the above to all the bodies without destroying the pre place code by selecting all the bodies, bring up the debug console and use...

{
    _x set3DENAttribute [ "Init", format[ "if ( isServer ) then { this unlinkItem 'ItemRadio'; this unlinkItem 'ItemMap' }; %1", ( _x get3DENAttribute "Init" ) select 0 ] ];
}forEach get3DENSelected "object";

  • Like 2

Share this post


Link to post
Share on other sites
3 hours ago, pierremgi said:

Without any simple code? Forget. Click on each of your guys.

You can select all corpses, with all corpses selected right click on one of them.

This way you can edit the init field of multiple objects at once.

 

Cheers

Share this post


Link to post
Share on other sites

Thanks guys but perhaps I wasn't that clear. I'm wondering if you can execute scripts from within editor. I do this in Unreal and Unity all the time. They are called editor scripts/extensions.

Share this post


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

Without any simple code? Forget. Click on each of your guys.

I meant that I don't require code examples, I'm just looking for the technique to execute some code inside the editor.

Share this post


Link to post
Share on other sites

No, I don't think you can.

 

The closest you can get is to open the debug console in editor and do some stuff in there, but you are limited as some stuff like namespaces etc hasn't been created at this point.

Share this post


Link to post
Share on other sites

 

5 hours ago, Larrow said:

Just select all the bodies and edit their init rather than loadout and use unlinkItem command.

 


if (isServer) then {this unlinkItem "ItemRadio"; this unlinkItem "ItemMap"};

 

So when the mission loads the items are removed.

If some already have some kind of init code then you could add the above to all the bodies without destroying the pre place code by selecting all the bodies, bring up the debug console and use...

 


{
    _x set3DENAttribute [ "Init", format[ "if ( isServer ) then { this unlinkItem 'ItemRadio'; this unlinkItem 'ItemMap' }; %1", ( _x get3DENAttribute "Init" ) select 0 ] ];
}forEach get3DENSelected "object";

 

 

Do you need the init here for some specific reason, instead of just selecting the objects and running:

{   _x unlinkItem "itemmap";
    _x unlinkItem "ItemRadio";
    save3DENInventory [_x]
    } foreach get3DENSelected "object"

 

  • Like 1

Share this post


Link to post
Share on other sites
4 hours ago, Greenfist said:

Do you need the init here for some specific reason, instead of just selecting the objects and running:

No not especially, just two ways to solve the same issue.

One saves code in init of each object (init is just config entry in sqm) that at mission start changes units loadout.

Other changes config in sqm of each object that at mission load changes units loadout.

Two things same outcome (depends on how large the code/savedInvetory is as to how much it will impact sqm size).

 

6 hours ago, das attorney said:

but you are limited as some stuff like namespaces etc hasn't been created at this point.

All namespaces are created, its just that as the editor is a separate instance (basically its own mission) on mission preview/run missionNamespace is cleared/reset as a new mission is initialised (this is not the case for UINamespace).

 

6 hours ago, krenuds said:

I'm wondering if you can execute scripts from within editor.

No you were perfectly clear.

As I said open the debug console and run what ever code you like (just remember most things will need to be scripted using eden commands else the results will not remain in your mission i.e setting a position with setPos will move an object but the changes will be lost, instead use _object set3denAttribute[ "position", [0,0,0]]).

You can even run scripts from your mission folder using execvm.

You can even run functions defined in the mission description.ext you just need to call BIS_fnc_recompile first in the debugConsole to make the game compile them and then they will be available as per usual within missionNamespace (set allowFunctionsRecompile = 1 in the description.ext so you can recompile any script changes).

There are other options available as well, like your own editor windows but these require an addon to accomplish.

  • 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

×