Jump to content
Sign in to follow this  
TAW_Yonose

Why wont this code activate my script?

Recommended Posts

Hello

Im trying to launch a script through this code

lightning = true;  ["lightning",10] execVM "lightningStorm.sqf";

Do anyone have any idea why this isent working?

All i get when i press OK is "Type Script, expected Nothing"

What am i doing wrong?

Share this post


Link to post
Share on other sites

Post the contents of lightningStorm.sqf. And any other related scripts / code.

Share this post


Link to post
Share on other sites

Well i used this script before and it did work good.

But now it wont work anymore for some reason.

My trigger is:

Type: None

Activation: Blufor

Once

Present

Condition:this

On Act: lightning = true; ["lightning",10] execVM "lightningStorm.sqf";

On Dea: lightning = false;

When i do

this will let me press OK on the trigger, but the script wont work.

null =["lightning",10] execVM "lightningStorm.sqf";

but this wont let me press OK

lightning = true;   ["lightning",10] execVM "lightningStorm.sqf";

Here is the script

/*
Creates an ongoing lightning storm in an area as long as a control parameter remains true
*/

if (isDedicated) exitWith{}; // Dont run serverside unless playerhosted.

_control = _this select 0;
_intensity = _this select 1;
_area = _this select 2; // Not implemented yet...

if (isnil "_intensity") then { _intensity = 10; };

_count = 0;
while (compile _control) do {
    _count = _count +1;

       //hint format["Lightningbolt %1!",_count];

/* Lightning bolt generation code nicked from BangaBob over on bistudios forums. Not sure if he wrote it or got it from somewhere. Creds to whoever did it anyway. :) */        

//Parameters
private ["_position", "_direction", "_distance"];
_position=position player;
_distance=300;
_direction=random 360;
//Relative position
private "_relativePosition";
_relativePosition = [_position, _distance, _direction] call bis_fnc_relPos;

//The bold
private "_bolt";
_bolt = createvehicle ["LightningBolt", _relativePosition, [], 0, "can_collide"];
_bolt setVelocity [0, 0, -10];

//The lighting
_lighting = "lightning_F" createvehiclelocal _relativePosition;
_lighting setdir random 360;
_lighting setpos _relativePosition;

//The light source
_light = "#lightpoint" createvehiclelocal _relativePosition;
_light setpos _relativePosition;
_light setLightBrightness 30;
_light setLightAmbient [0.5, 0.5, 1];
_light setlightcolor [1, 1, 2];

//Some delay
sleep (0.2 + random 0.1);
//Clean up
deletevehicle _bolt;
deletevehicle _light;
deletevehicle _lighting;

sleep 0.8;
//Play thunder sound
//Random thunder sample
private "_thunder";
_thunder = ["thunder_1", "thunder_2"] call BIS_fnc_selectRandom;
playSound _thunder;

/* End BangaBob part */        

       sleep random _intensity;


};

Share this post


Link to post
Share on other sites

The error is the while loop in your script. It needs to be

while {compile _control} do ...

If you want to pass the lightning variable to your script, don't put it in parentheses. Just execute it this way:

lightning = true;   [lightning, 10] execVM "lightningStorm.sqf";

If you don't use lightning anywhere else in your whole mod (as it seems to be a global variable), you could even leave the fist command and simply type

[true, 10] execVM "lightningStorm.sqf";

For the DeAct, simply change the true to false.

EDIT:

That way, you can actually get rid of the while {compile _control} and instead use while {_control}.

As I was reading further through your code, why are you doing such a complicated implementation, passing a variable name and compiling that variable name to get the actual variable?

Also, you should not set a _localVar = globalVar. I don't know how that behaves mixed with "compile", but at least the fist way results in an error. For the sake of stability, try to not assign global variables to local variables. The other way round is fine though.

Regards,

waltenberg aka Johnny

Edited by waltenberg

Share this post


Link to post
Share on other sites

Instead of

lightning = true; ["lightning",10] execVM "lightningStorm.sqf";

try

lightning = true; 0 = ["lightning",10] execVM "lightningStorm.sqf";

Share this post


Link to post
Share on other sites
lightning = true; 0 = ["lightning",10] execVM "lightningStorm.sqf";

Here is the solution. ExecVM needs a script handle in editor.

Share this post


Link to post
Share on other sites

This worked just as same as

null =["lightning",10] execVM "lightningStorm.sqf"; 

this did

lightning = true; 0 = ["lightning",10] execVM "lightningStorm.sqf";

im starting to wonder, if it says in the script that it will need a marker that is named something, or a trigger/player that have to be called something

Or if its already given a position where i cant see..

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
Sign in to follow this  

×