OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Surdus Priest on 24 Oct 2007, 17:14:37

Title: a condition for when a parameter is not set
Post by: Surdus Priest on 24 Oct 2007, 17:14:37

say you have: []exec "blah.sqs"

and in the script i says: _argh = _this select 0

since there is no value to define _argh, not even 0, my question is

what is the condition for when there is nothing in the parameters to define _argh.

basically what does an undefined variable equal? and how would you represent it?
Title: Re: a condition for when a parameter is not set
Post by: JasonO on 24 Oct 2007, 17:33:00
Code: [Select]
_argh = _this select 0
?isnull _argh : _noparams = true

That might do it?

An undefined variable is null I believe.
Title: Re: a condition for when a parameter is not set
Post by: Surdus Priest on 24 Oct 2007, 18:18:09
isnull... lol, why didnt i see that one :D
Title: Re: a condition for when a parameter is not set
Post by: Baddo on 24 Oct 2007, 19:11:32
isNil
Title: Re: a condition for when a parameter is not set
Post by: Planck on 24 Oct 2007, 19:51:36
Baddo is correct, isNil refers to variables, isNull refers to objects, groups, displays and controls.


Planck
Title: Re: a condition for when a parameter is not set
Post by: Mandoble on 24 Oct 2007, 20:27:23
Code: [Select]
if (count _this > 0) then
{
   _argh = _this select 0;
}
else
{
   _argh = your desired default value;
};
Title: Re: a condition for when a parameter is not set
Post by: Surdus Priest on 24 Oct 2007, 23:40:33
thanks, however it seems that it causes the second parameter o become null.  it was only incase the editor didnt use parameters anyway.




i have another questions however;

my script includes an optional feature where numbers being updated constantly in the hint.
i cant figure out how to set the number of decimal points that appear next to the number.
for example, rather than 34.5004242
i want 34.50

surdus

edit: i also need to know how to modify an added action.  because its no good if the action ID goes up every
time the same action is deleted and replaced.  especially if the mission involves many other important actions that
shouldnt be deleted.
Title: Re: a condition for when a parameter is not set
Post by: Mandoble on 25 Oct 2007, 00:45:27
Code: [Select]
_value = _value - (_value % 0.01)
Title: Re: a condition for when a parameter is not set
Post by: Surdus Priest on 25 Oct 2007, 02:35:55
is there a way of doing that inside the hint format, because i dont want the value to change, i only want it to "appear" as 2 decimal points on the hint.

for example

Code: [Select]
_value = 34.5004242;

hint format ["Answer - %1",_value]

then the decimal change would make the hint say:

Answer - 34.50


i can think of a way to do it the way you said, but that would mean modifying a lot of variables then changing them back.

is there an easier way?

Title: Re: a condition for when a parameter is not set
Post by: myke13021 on 25 Oct 2007, 03:17:30
What about to copy the value into another variable and edit this, something like:

Code: [Select]
_showvalue = _value - (_value % 0.01)
hint format ["Answer - %1",_showvalue]
This way the original _value wouldn't be touched.

Myke out
Title: Re: a condition for when a parameter is not set
Post by: Surdus Priest on 25 Oct 2007, 03:47:47
that looks good, thanks :D

edit:

is there a way of doing that, but without changing the value?

because that makes teh value appear 0.01 less than what it actually is, so how to i change it to the
real value, but still keep it at 2 decimal points?