Jump to content

Recommended Posts

21 hours ago, commy2 said:

Thermal simulation only has these three properties and TI textures only three channels, so this is not going to happen without some deeper changes, R3vo.

If you fire the commanders machine gun on a tank for example, the main gun will heat up and it has been like this since this was implemented. You'd have to overhaul every model and probably add a system that uses selections like the damage material system.

 

Alright, thanks for the information. Let's hope then that one of the DLCs will bring some improvements in this area.

Share this post


Link to post
Share on other sites
1 hour ago, R3vo said:

 

Sound interesting, so are we going to get some sort of 3D action system? ;)

 

https://community.bistudio.com/wiki/addAction

 

Please, btw, make the handlers (return value) of addAction more specific and automatic! It's not a great idea to return a numeric value instead of alphanumeric one.

For many reasons, you can remove the wrong action.

What I suggest is to return the string of the title:
 

_act = player addAction ["Exec the file", "somescript.sqf"] ;
hint format ["%1",_act]; // returns "Exec the file"

 

Share this post


Link to post
Share on other sites
25 minutes ago, pierremgi said:

 

Please, btw, make the handlers (return value) of addAction more specific and automatic! It's not a great idea to return a numeric value instead of alphanumeric one.

For many reasons, you can remove the wrong action.

What I suggest is to return the string of the title:
 


_act = player addAction ["Exec the file", "somescript.sqf"] ;
hint format ["%1",_act]; // returns "Exec the file"

 

 

hint ((player actionParams _act) select 0); // returns "Exec the file"

  • Like 1

Share this post


Link to post
Share on other sites

The new jet DLC functions have quite a few typos in their description. Would be nice if someone could correct those.

Share this post


Link to post
Share on other sites
On 15.4.2017 at 5:56 PM, pierremgi said:

 

Please, btw, make the handlers (return value) of addAction more specific and automatic! It's not a great idea to return a numeric value instead of alphanumeric one.

For many reasons, you can remove the wrong action.

Only if you don't know what you're doing.

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

Am I going nuts or why is this working?

 _cash = 10;
_Showcash = call {hint str format ["You have: $%1",str _cash]};

From all I know _cash inside the call should be undefined?

What's happening?

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites
51 minutes ago, Grumpy Old Man said:

Am I going nuts or why is this working?


 _cash = 10;
_Showcash = call {hint str format ["You have: $%1",str _cash]};

From all I know _cash inside the call should be undefined?

What's happening?

 

Cheers

That's how it's supposed to work. That's why we define private variables in functions. So that they don't change variables outside the function's scope.

_func = {
	hint _var
};
_var = "hello";
call _func // -> hints hello

 

Share this post


Link to post
Share on other sites

In your case, the call is just a child scope of the current scope you're running in. The child scopes inherit variables from the parent scopes. If you want to prevent it, make _cash private in the inner scope.

_cash = 10;

_showcash = {
  private ["_cash"];
  hint str format ["You have: $%1",str _cash];
};

call _showcash; // Will hint "You have: $", quite useless as _cash inside _showcash can never be assigned a value

// Making it useful
_usefulShowcash = {
  private ["_cash"];
  _cash = _this select 0;
  hint str format ["You have: $%1",str _cash]; 
};

[5] call _usefulShowcash; // Will hint "You have: $5"
[_cash] call _usefulShowcash; // Will hint "You have: $10"

This is the reason you'll usually see functions/scripts with large private declarations for the variables they plan to use at the start of the file like this.

private ["_varA", "_varB", "_varC", ...]

This is to isolate the variables in the inner scope from parent scope "leaking" in.

There is also "recently" discovered syntax that people have switched over to using:

_cash = 10;

_showcash = {
  private _cash = _this select 0; // "Recent" syntax
  hint str format ["You have: $%1",str _cash];
};

[20] call _showcash; // Will hint "You have: $20"

Which is basically declaring it as private and assigning a value to it.

Share this post


Link to post
Share on other sites
20 minutes ago, Sniperwolf572 said:

In your case, the call is just a child scope of the current scope you're running in. The child scopes inherit variables from the parent scopes. If you want to prevent it, make _cash private in the inner scope.


_cash = 10;
_Showcash = call { private ["_cash"]; hint str format ["You have: $%1",str _cash]};

This is the reason you'll usually see functions with large private declarations at the start of the file like this.


private ["_varA", "_varB", "_varC", ...]

To prevent the variables from parent scope leaking in. There is also "recently" discovered syntax that people have switched over to using.


private _cash = 10;

Which is basically declaring it as private and assigning a value to it.

 

Thanks for taking time for your answer. I understand some inheritance from parent scope. For example, you can call a code ending by the return value, then use this value later in script. It's like you're pulling the _return out of the call scope.

Here, it's little bit different. you're pushing a (the last) local variable into the call scope. A kind of "reverse" inheritance (sorry for my english).

 

Anyway, I tested:

_cash = 10;
_Showcash = call { private ["_cash"]; hint str format ["You have: $%1",str _cash]};

and

private _cash = 10;
_Showcash = call { private ["_cash"]; hint str format ["You have: $%1",str _cash]};

That doesn't make difference.

 

I sometimes asked for the difference between

_cash = 10; (I guess defining a variable in some RAM buffer)

and

private _cash = 10; (I guess declaring then defining a variable in some RAM buffer also). Not really sure to see the difference in this test but your answer is opening some "curtains" on my comprehension. Thanks.

 

Share this post


Link to post
Share on other sites
21 minutes ago, pierremgi said:

I sometimes asked for the difference between

_cash = 10; (I guess defining a variable in some RAM buffer)

and

private _cash = 10; (I guess declaring then defining a variable in some RAM buffer also). Not really sure to see the difference in this test but your answer is opening some "curtains" on my comprehension. Thanks.

 

 

The difference between private and non private is basically enforcing the variable to be contained to the scope and the child scopes.

When a variable is "private" in a scope, it can't modify the parent scope, and will not automatically "inherit" the value from the parent scope.

Example A - parent _cash gets modified:

_cash = 10;

call { 
  _cash = 20;
};

hint str _cash; // Will hint: 20

Example B - parent _cash remains as is due to private:

_cash = 10;

call { 
  private _cash = 20;
};

hint str _cash; // Will hint: 10

Example C - same as example A, except that this piece of code will not modify the parent scope if this piece of code was executed from another call that also contained a _cash variable:

private _cash = 10;

call { 
  _cash = 20;
};

hint str _cash; // Will hint: 20

 

In simple terms, when you declare something private, you're protecting the current scope and the parent scope:

  • This variable will not inherit the value of a variable with the same name from the parent scope
  • Assigning a value to this variable will not change the value of the same variable name in the parent scope
  • Like 1

Share this post


Link to post
Share on other sites

Wow! Thank you so much! That's clear. This should be mentioned in the BIKI page for private command. "usage of private of keyword" is not explicit.

Share this post


Link to post
Share on other sites

Just to also make sure it's clear if it isn't already:

private ["_a", "_b"];
_a = 1;
_b = 2;

is the same as

private _a = 1;
private _b = 2;

The only difference is the ease of use. It's shorter by a line and you don't have to keep track of and remember your private variables in an array at the (usually) top of your file.

 

Additionally, params will also make your params private, so instead of:

private _a = _this select 0;
private _b = _this select 1;

You can just go:
 

params ["_a", "_b"];

 

  • Like 1

Share this post


Link to post
Share on other sites

Might also add that magic variables like "_x" and "_this" are always set to private to their respective scopes:

private _x = 10;

{} forEach [1,2,3];

_x // 10

 

The iterator (I think that's the technical name for the variable) in a for-loop is also treated like a magic variable:

private _i = 20;

for "_i" from 1 to 3 do {};

_i // 20

 

One mildly interesting detail here is the difference between the unary and the binary syntax of "call".

unary call:

_this = 30;

call {_this = 1};

_this // 1

 

binary call:

_this = 30;

_this call {_this = 1};

_this // 30

 

This proofs that the unary syntax of "call" does not have the magic variable "_this" and only inherits it from the parent scope, while the binary syntax creates a "_this" variable "private" to the call-scope with the value of whatever was passed as argument.

 


 

  • Like 2

Share this post


Link to post
Share on other sites

Is there a reason we don't have a command which would get the local time / date of the machine it was executed on?

Share this post


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

Is there a reason we don't have a command which would get the local time / date of the machine it was executed on?

 

missionStart works sort of, but yeah our options for this are non-existent.

Share this post


Link to post
Share on other sites

Just one noob question: what means a "mission start"?

Does that mean:

- start of the server? I guess no;

- start of the mission on server? should be. but could be more explicit if mentioned as "mission server start", everywhere it's pertinent.

- start of the mission locally:  seems to be, as all files are run (init.sqf, initserver.sqf for server, initPlayerLocal...) with initialization order at this moment.

    - when returning to lobby (MP) : seems to be also; same init  files are run again. But not sure.

    - when switching unit in MP? : no, event after death?? no more if I'm right!

 

Then,

- time seems to be local and not synchronized (except in debug console watch hosted vs JIP???? >> i've got the same time on each PC writing: time ,on a watch line),

- serverTime: probably the time elapsed from the start of the server : BIKI: " serverTime is also different from server time ". Cool!

- missionStart: a kind of time in format [year, month, day, hour, minute, second]. For MP only. Probably on server, not locally?

... i probably omit some other commands.

 

Not saying how all these things work with setTimeMultiplier, setTime, skipTime... not very easy to understand.

Share this post


Link to post
Share on other sites

The missionStart command isn't what I am looking for.

I'd like to have a command which works in SP and Eden so I can attach time and date to saved presents and templates.

Share this post


Link to post
Share on other sites
3 minutes ago, R3vo said:

The missionStart command isn't what I am looking for.

I'd like to have a command which works in SP and Eden so I can attach time and date to saved presents and templates.

setDate with  the date of your PC date/time ?

Share this post


Link to post
Share on other sites
9 hours ago, R3vo said:

I'd like to have a command which works in SP and Eden so I can attach time and date to saved presents and templates.

I guess using extension (like this one) is not an option?

Share this post


Link to post
Share on other sites
8 minutes ago, pedeathtrian said:

I guess using extension (like this one) is not an option?

 

Unfortunately not.

Share this post


Link to post
Share on other sites

Do we have a command or function to get maximum limit of view distance we can set with setViewDistance?

Different numbers appear in comments (10 km, 15 km), also, in ports this distance is decreased, AFAIK, to 6 km (?).

I can use the (productVersion select 6) to get the platform, but then what values do I use?

If somebody gives me values and says they're not the subject to change, that'd be fine too.

 

Why these values? According to BISim::setFog they affect the view distance limitation made by fog. I experimented with different view distance and fog settings and got somewhat similar (exponential downfall) character of view distance dependency on fog value (same rules might apply in BISim and Arma). However, view distance set by setViewDistance does not have any influence on fog effect and only works as cut-off. Thus I need the limit(s).

Thanks.

Share this post


Link to post
Share on other sites

According  to Hint F1 editor  the following command should return an array of known targets  within a specified distance

 

player targets [[EAST, GUER], 100]

However when run it gives:-  error type array expected bool

 

full description

Unit targets [[side..],distance,age,centre]

 

I suspect this command hasn't been implemented, any chance it could be finished or fixed.     

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

×