Welcome to the Iron Front Fan Forums!
Sign up Latest Topics
 
 
 


Reply
  Author   Comment  
Joe98

Avatar / Picture

Captain
Registered:
Posts: 196
Reply with quote  #1 
The name of the script is:   one


The script is meant to delete a object named box1.  The script is:


{
deletevehicle box1;
}



To call the script in a trigger I use:

nul  =  []   execVM  "one.sqf";     //the spaces are a bit exaggerated


I cannot call the script. Why is that?
.



0
BRS

Captain
Registered:
Posts: 194
Reply with quote  #2 
Hi Joe

{
deletevehicle box1;
}

just remove that brackets and it will work well if the rest of the trigger conditions are ok.

as said. inside one.sqf write:
deletevehicle box1;


0
Joe98

Avatar / Picture

Captain
Registered:
Posts: 196
Reply with quote  #3 
Yes you are correct thank you.

Removing the curly brackets solves the problem.

However in my study of scripts, every script begins with { and ends with }.

My script does not require those. Why is that?
0
BRS

Captain
Registered:
Posts: 194
Reply with quote  #4 
I'm not that deep expert with the Arma scripting so I can just tell you my thoughts about.
First it's not well seen that every script is enclosed by {} in Arma sqf.
So I think it's worth to understand what a script is inside Arma.

You must distinguish between the script (xxx.sqf) itself and the functions inside this sqf.
The script (i.e. 'one.sqf') will collect the used functions and the flow control, simple said the things you want the script to do inside Arma/IFL44. I'll try to explain this later on.
Now if you inserted your script (sqf) and call it during the game, then Arma needs to understand it.
The Engine will read in the script and want the exact syntax otherwise it can't 'understand' what you want it to do.
So it's vital to write scripts, functions the way Arma need it. This is a -must-.
We don't have to go deep into the syntax now, just have a look how a script should be writen (build) so Arma can handle it.
See this example of your one.sqf:

    deletevehicle box1;
There is no {} around, because the Arma engine would not be able to understand that beginning '{' the time it reads in and try to 'interpret' your script. It sinple wants a other 'beginning' In this case it will find the deletevehicle function, know it and execute it.
Let's have a look to an other example of the one.sqf with some flow control inside:

private ["_foo"];

_foo = 1;
if (_foo == 1) then
{
    deletevehicle box1;
};
This time you'll need the {} around the if and while reading in the engine can understand what you want. And the syntax of the if forces you to write it this way so the interpreter can work with it.
Look careful, there are no brackets around the script itself!

An other example of one.sqf with no need of {}:
private["_a"];

_a = 999;
hintsilent format["Count: %1\n, _a];
sleep 5;
_a = _a +1;
hintsilent format["Count: %1\n, _a];
sleep 5;
As I said earlier it's a collection (a row of) of functions which are embedded inside the one.sqf. Again, no brackets needed.

Here is one other example for flow control inside a script:
private ["_max_count"];

_max_count = 555;
for "_k" from 0 to _max_count do
{
hintsilent format["Count: %1\n, _k];
sleep 1;
};
And here is a part out of a little more complex script I did.  Around the rest of this script (main body) you will not find the {} just, like shown, inside the fow control.
while { _fire AND (_fire_counter < _max_salvos) } do 
{
    hint "inside salvo";
    for "_m" from 0 to  _count  do
    {
        _t_Pos = _target_array select _m;
       
        _posX = (_t_Pos select 0) +(round(Random _rnd_dist) - round(Random _rnd_dist));
        _posY = (_t_Pos select 1) +(round(Random _rnd_dist) - round(Random _rnd_dist));

        _posX = _posX + (sin (_dir) * (_inc * _fire_counter));
        _posY = _posY + (cos (_dir) * (_inc * _fire_counter));               
       
        _bomb = _bomb_type createVehicle [_posX, _posY, 400];
       
        _bomb setDir _dir;
        _speed = 2.50;
        _vel =     [ 1.0, 1.0, 1.0];
        _bomb setVelocity [(_vel select 0)+(sin _dir*_speed),(_vel select 1)+ (cos _dir*_speed),(_vel select 2)];    // [x, z, y]
       
        if (_m == 0 OR _m == _count /2 OR _m == _count /4 OR _m == _count) then
        {
            _bomb say3d _sound; // Soundnames from desription.ext cfgsound
        };
        sleep _delay;
    };
    _fire_counter = _fire_counter + 1;
    sleep _delay2;
};

Can't say if I could help you ahead by these huge writing, scripting is complex stuff and not such easy to understand.
Lot trial and error needed and a lot of looking into the wiki to see what functions are inside arma and how to use them inside a script.
Feel free to ask ahead if you couldn't understand what I tried to explain. May be I can find better words or examples then.




0
santiagojamesaea

Sergeant
Registered:
Posts: 106
Reply with quote  #5 
Bs.....and you say you are not an expert.....
I'm still using that spawn an ammo crate script you helped me with-a jeep drives up and "unloads" a custom ammobox and drives off. It works in Arma3 too....
A thousand thanks!!
0
BRS

Captain
Registered:
Posts: 194
Reply with quote  #6 
Thx santiagojamesaea.
I just try to help if I'm able to do so.
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.