The Real Bunc 136 Posted June 7, 2019 This was a result of trying something out for another thread and its got me stumped. I have a helicopter on ground with crew. I have the helicopter linked to a Spawn vehicle module. In the "expression" box of the SpawnModule I can put code in to fill the helicopter with crew and give the helicopter a waypoint and it all works fine. But the expression box is small and I wanted to deliver a larger bit of code to the expression. So I put the identical code that I had used in the spawn box into an sqf. I need to then pass this code as code to the expression field. The expression box says it takes a variable or code as input. So I try codeforexpression = loadfile "mycode.sqf"; // no deal. it puts "" around my code so when I put codeforexpression into the expression field it doesn't work. ( no debug hint to indicate code was run) codeforexpression = compile loadfile etc // again nothing doing. No indication it was run as code and this time a check via debug shows my code with {} wrapped around it. but the expression code works fine when it is simply entered into the expression box. I just need to deliver a block of code to that expression field in the spawnVehicle module but without it being wrapped as a string with "" or as a code block with {}. Am I missing something obvious? Share this post Link to post Share on other sites
sarogahtyp 1104 Posted June 7, 2019 show code an show a screenshot of that box pls EDIT: what about nul = [yourParamterList] execVM "mycode.sqf"; ? also if the code is executed multiple times then you should use the Function Library to get it precompiled at mission start. With this u are able to call or spawn (depends on your code) it: [yourParamterList] call yourTag_fnc_yourFunctionName; or nul = [yourParamterList] spawn yourTag_fnc_yourFunctionName; this way you get shorter execution times because code does not need to get compiled each time you run it. (this is the case with execVM) Share this post Link to post Share on other sites
Larrow 2779 Posted June 7, 2019 //initServer.sqf //This SEH( Scripted Event Handler ) is exactly the same //as what the expression field in the respawnVehicle module does [ missionNamespace, "respawn", { params[ "_spawnedVeh", "_oldVeh" ]; //parameters passed to the code //This will be called by ALL vehicleRespawn modules //If you have more than one make sure its the one you are monitoring //Name given to helo in editor "MyHelo" if ( vehicleVarName _spawnedVeh isEqualTo "MyHelo" ) then { //Your expression code createVehicleCrew _spawnedVeh; _grp = group driver _spawnedVeh; _wp = _grp addWaypoint[ getMarkerPos "MyHeloWaypoint", 0 ]; _wp setWaypointStatements[ " true ", " vehicle this setDamage 1; " ]; }; }] call BIS_fnc_addScriptedEventHandler; TEST MISSION Helo will spawn and fly to waypoint (via waypoint given for initial crew in editor). Blow up. Repeat (using crew and waypoint spawned by SEH). 3 2 Share this post Link to post Share on other sites
The Real Bunc 136 Posted June 7, 2019 That's bang on target Larrow and works great and bypasses the problem of getting code to register through the input box. It's interesting seeing you use a scripted event handler given the active discussion of those on another thread as well. Could you say a little about how this scripted event handler is linking to the spawnvehicle event? Is that the reference to Missionnamespace "Respawn" ? Share this post Link to post Share on other sites
The Real Bunc 136 Posted June 7, 2019 Larrow, got to say thank you. Ive just finally clocked what scripted event handlers do. I realise that respawn in missionnamespace is one of the listed events for scripted event handlers. Am I right in thinking that if I set my own variable then in a namespace I can set the Boolean value of that variable and so trigger any scripted event handler ive set to use that event? I think that was wrong. Reading the Biki again I think I use callscriptedeventhandler to trigger my own scripted event handlers. Agh ha! Share this post Link to post Share on other sites