Jump to content
Sign in to follow this  
breeze

help with Fockers Hints

Recommended Posts

I am having a problem with the hints when it comes to variables

This is all placed in a hint.sqf file and being called from the addaction command of the player

I am supposed to get back a value of the target being MikeJ The addaction works but the value comes back as ANY instead of Mike J

What is not clear is where the 1st line goes in the tutorial it shows this line and I know this defines _this

Then the variable having its 3 parts target caller and id are defined the hint format is to call one area of the object _this

I am not sure what I am doing wrong here.

_this = [MikeJ,MikeJ,1];

_target = _this select 0;

_caller = _this select 1;

_id = _this select 2;

Hint format ["target = %1",_target];

Share this post


Link to post
Share on other sites
I am having a problem with the hints when it comes to variables

This is all placed in a hint.sqf file and being called from the addaction command of the player

I am supposed to get back a value of the target being MikeJ The addaction works but the value comes back as ANY instead of Mike J

What is not clear is where the 1st line goes in the tutorial it shows this line and I know this defines _this

Then the variable having its 3 parts target caller and id are defined the hint format is to call one area of the object _this

I am not sure what I am doing wrong here.

_this = [MikeJ,MikeJ,1];

_target = _this select 0;

_caller = _this select 1;

_id = _this select 2;

Hint format ["target = %1",_target];

well for starters you cant use _this or this as a variable because its reserved. From what you've posted caller and id vars are totally redundent as they aren't used anywhere, and the target I can assume is nothing so of course it returns any because there is no data given at all.

Share this post


Link to post
Share on other sites

So then how do I get the return hint I am supposed to here??

The objective to this is to illustrate the use of the variable so when the player hits the addaction in his menu it returns the name mike j as the target where is mike j defined?

or should _this be _player?

Edited by Breeze

Share this post


Link to post
Share on other sites
So then how do I get the return hint I am supposed to here??

The objective to this is to illustrate the use of the variable so when the player hits the addaction in his menu it returns the name mike j as the target where is mike j defined?

or should _this be _player?

Ok since I don't know what your action looks like I'll just use my own as an example (created with Arma 3 Editing Tool):

player addaction ["Your Action","YourScript.sqf",0,1,False,True,"",' my-Variable-Here '];

in yourScript.sqf

_target = mikeJ; //no spaces allowed in reference names like this, make a string variable to hold the text representation
_targetStr = "mike J"; //string representation

hint format ["Your Target is: %1",_targetStr];

Note that one is pretty much static.

Also what tutorial were you using to create that code above?!

Either you misunderstood it or theres a serious problem with it, with that syntax you used for the array, anyhow this is pretty much irrelevant to your issue.

Share this post


Link to post
Share on other sites

But let’s say we wanted to hint who was calling the script. At last a Variable can be used, you didn’t read all that crap for nothing.

The addaction technically sent the following to the hint.sqf script…

_this = [Mikie J,Mikie J, 1];

It declared its own MAGIC variable of “ _this †and gives it three parameters to give to the hint.sqf script. It never shows in the script as that, as we can’t see it. It just as happens that I know what my player name is, and that I am also the caller.

“_this “ is a magic word used by BIS coding structure, and IN THIS SPECIFIC CASE it is an array of things. Again not going into too much depth but in this particular usage it’s a variable that holds more than one value. Just remember when you want to choose the first Mikie J/or target – it is in position 0, not position1. Yes there are three items in the array, but they are in the following sequence. [0,1,2]

We need to create three variables to assign each of those parameters to.

Type the following in the hint.sqf

_target = _this select 0; _caller = _this select 1; _id = _this select 2;

The variable _target has been given the first passed parameter from the addaction - the value Mikie J.

POS = 0 , 1 , 2 _this = [Mikie J,Mikie J, 1];

What you technically have done is accessed “_this†– which is an array or list containing (Mikie J , Mikie J, and 1) , and you have asked it to select position 0 from that list. Well in position 0 of this particular array is the first Mikie J. So looking at “_caller†variable – you have asked it to select position 1 from the array which contains (Mikie J , Mikie J, and 1) and selected the second Mikie J. And then for _id you have passed the third parameter number 1 to it, by selecting position 2.

Ok, so now we should have

_target = _this select 0;

_caller = _this select 1;

_id = _this select 2;

Add the following..

Hint format [“Target = %1â€,_target];

Save the hint.sqf, Alt-Tab back to the game and preview or restart the mission.

Now when you load in scroll to the addaction, call our hint script, and select it. You should have a hint on the screen. Which says something like…

Target = A1:1-1 [FOCK]Mikie J

Go back to the editor, Alt-Tab into the hint.sqf file.

Now change the hint line in the hint.sqf to the following…

Hint format [“Caller = %1â€,_caller];

Save the file and Alt-Tab back into the editor. Preview or restart the mission

Now when you load in scroll to the addaction once again, call our hint script, and select it. You

should have a hint on the screen. Which says something like… Caller = A1:1-1 [FOCK]Mikie J

This is Fockers tutorial

---------- Post added at 22:26 ---------- Previous post was at 22:22 ----------

And see in your example you are defining the target in his he is trying to illustrate the variable having three values target, caller and id; I am trying to learn this where when you guys explain something with terms it doesnt fly over my head which it normally does. I hate to continually ask for things to be made that I should be able to do. I just need to find moire things like this that explain it and don't just give me a listing of commands.

Share this post


Link to post
Share on other sites
But let’s say we wanted to hint who was calling the script. At last a Variable can be used, you didn’t read all that crap for nothing.

The addaction technically sent the following to the hint.sqf script…

_this = [Mikie J,Mikie J, 1];

It declared its own MAGIC variable of “ _this †and gives it three parameters to give to the hint.sqf script. It never shows in the script as that, as we can’t see it. It just as happens that I know what my player name is, and that I am also the caller.

“_this “ is a magic word used by BIS coding structure, and IN THIS SPECIFIC CASE it is an array of things. Again not going into too much depth but in this particular usage it’s a variable that holds more than one value. Just remember when you want to choose the first Mikie J/or target – it is in position 0, not position1. Yes there are three items in the array, but they are in the following sequence. [0,1,2]

We need to create three variables to assign each of those parameters to.

Type the following in the hint.sqf

_target = _this select 0; _caller = _this select 1; _id = _this select 2;

The variable _target has been given the first passed parameter from the addaction - the value Mikie J.

POS = 0 , 1 , 2 _this = [Mikie J,Mikie J, 1];

What you technically have done is accessed “_this†– which is an array or list containing (Mikie J , Mikie J, and 1) , and you have asked it to select position 0 from that list. Well in position 0 of this particular array is the first Mikie J. So looking at “_caller†variable – you have asked it to select position 1 from the array which contains (Mikie J , Mikie J, and 1) and selected the second Mikie J. And then for _id you have passed the third parameter number 1 to it, by selecting position 2.

Ok, so now we should have

_target = _this select 0;

_caller = _this select 1;

_id = _this select 2;

Add the following..

Hint format [“Target = %1â€,_target];

Save the hint.sqf, Alt-Tab back to the game and preview or restart the mission.

Now when you load in scroll to the addaction, call our hint script, and select it. You should have a hint on the screen. Which says something like…

Target = A1:1-1 [FOCK]Mikie J

Go back to the editor, Alt-Tab into the hint.sqf file.

Now change the hint line in the hint.sqf to the following…

Hint format [“Caller = %1â€,_caller];

Save the file and Alt-Tab back into the editor. Preview or restart the mission

Now when you load in scroll to the addaction once again, call our hint script, and select it. You

should have a hint on the screen. Which says something like… Caller = A1:1-1 [FOCK]Mikie J

This is Fockers tutorial

---------- Post added at 22:26 ---------- Previous post was at 22:22 ----------

And see in your example you are defining the target in his he is trying to illustrate the variable having three values target, caller and id; I am trying to learn this where when you guys explain something with terms it doesnt fly over my head which it normally does. I hate to continually ask for things to be made that I should be able to do. I just need to find moire things like this that explain it and don't just give me a listing of commands.

I'm not sure if your reply to my attempt to help was supposed to be snobby, but if it was then you can find stuff out on your own, I and nobody else will help if your going to crap on us for trying to help.

Anyways I'll just leave what I already posted under here for you. Your welcome buddy.

my example would suit your purpose fine. As long as 'mikeJ' refers to an object it should spit out information like you stated, you can simply change the _targetStr part to _target. For the caller part you only need to change what you send to the script (instead of target, the caller) and change what the hint says.

Share this post


Link to post
Share on other sites

I am not being snotty at all I attached everything I could so you could see what the tutorial was trying to teach me, I understood that this part of the question was not clear in my first post and you were answering with the info you had. I should have placed this with all of the info the first time. So I am sorry if my post came off that way it was not my intention at all I am aware of the fact you are helping and I appreciate it greatly, especially as these forums seem to have much less action on them then when I used to play.

---------- Post added at 22:40 ---------- Previous post was at 22:37 ----------

If you are still ok with helping I am still trying to find out what i did wrong in regard to his tutorial and understand the three parts of the variable.

Share this post


Link to post
Share on other sites

Your problem is that you don't need to define _this as a variable and assign it parameters. His name is Mikie J so that's what the code will return as the parameters. All you need to do is take "_this = [MikeJ,MikeJ,1];" out of your script. It's not working because you're trying to call the target off the addaction, which should be you. But because you tried to define _this as a variable it's not working properly.

I hope that somewhat made sense. Basically take out that first line and your fine. In game it will show you you're arma profile name in the hint, not Mikie J's.

Share this post


Link to post
Share on other sites
The addaction technically sent the following to the hint.sqf script…

_this = [Mikie J,Mikie J, 1];

It declared its own MAGIC variable of “ _this †and gives it three parameters to give to the hint.sqf script.

What Mike is trying to get over in his tutorial here is (paying specific attention to the bolded bits above).

An action when run will pass the target, caller, actionID and any addition arguments specified in the addAction into the actions code when the action is used.

These values are all bundled up into an array called _this for easy access to them. _this is referred to as a magic variable as it is not defined anywhere but is made available in the addActions code via the game engine. So he is basically saying the contents of _this will technically look like [Mikie J,Mikie J, 1] as to show you the reader what to expect in the _this variable.

For instance if i were to place down a unit in the editor and give it a name of Larrow and write in its init box

player addAction [ "myAction", { hint str _this}];

I would get of hint of [Larrow,Larrow,0,<null>]

The first variable in the _this array is the target e.g me as the action was added to the player, so Larrow as this is the name i gave the unit i am currently controlling as the player

The second variable in the _this array is the caller e.g me as it was me that ran the action by selecting it from my action menu in game so Larrow

The third variable in the _this array is the actionID e.g 0 as it is the first action that has been added to the player object (remember id's are 0 based so the first one is 0)

The fourth variable in the _this array is any additional arguments passed in the addAction command e.g <null> as there was nothing passed, we did not use this feature of the addAction command.

Instead of hinting them straight from the addAction code, like i have above, Mike is passing the contents of the _this variable to another script.

player addAction [ "myAction", { _this execVM "myScript.sqf" }];

Where he is then teaching you to use the select command to query each index of the passed array and hint them to the screen.

myScript.sqf

_target = _this select 0;
_caller = _this select 1;
_actionID = _this select 2;
_arguments = [ _this, 3, [], [ [] ] ] call BIS_fnc_param;

hint format [ "%1 used the action on the object %2 with ID of %3\nThe action had addition arguments passed of %4 ",
_caller,
_target,
_actionID,
_arguments
];

Take note that the _this variable in myScript.sqf is NOT the same variable as _this in the action code. Although it holds the exact same data, _this here is yet again another magic variable holding what ever data was passed to the script. e.g

player addAction [ "myAction", { [ "Hello" ] execVM "myScript.sqf" }];

myScript.sqf

_message = _this select 0;
hint format [ "%1 %2", _message, name player];

Hope that helps and is not to confusing.

Edited by Larrow
spelling

Share this post


Link to post
Share on other sites

Well yes it is very confusing but not due to your explanation but to my inexperience, your detailed explanation is fantastic and very much appreciated.. So if you do not mind I have some further questions. What I have retained so far is I think I am understanding the magic variable when using (_this) _this as a local variable can contain anything you give it which is why you call it the magic variable where other variables need to have a certain type of data returned such as a string, object, etc _this can have anything that's why it is the magic variable??

Some things that I do not follow yet that drive me crazy

The use of { } vs the use of [] what the heck is the difference in the brackets?

Also when I write a trigger and I put in any _variable it is local however if I put it in brackets it is not??

So if I take a group and place it with the editor and i call the group _squad1 place another group and call it _squad2 I do this by placing the _sq1 = this inside of the group leaders init line and declare it as a variable. here it does not require a bracket???

But now I use a trigger and want that group to do something?? now I use _squad1 it is now global and not local? (because I get that as an error.. So In a trigger I have to use {_squad1 with the command} and then it is local command?

Also the handles all variables need a handle so how do I know when to use [] and not to?

I see a lot of examples 0=[] {_squad1 do action or command}??

I am understanding the pieces I think in terms of identifying strings, objects and variables but I am not sure how to place them yet for instance..

If I go here to this link and want to understand the use of this command https://community.bistudio.com/wiki/moveInCargo

It will show an example like here

Example 1:

_soldierOne moveInCargo _jeepOne;

Example 2:

_soldierOne moveInCargo [_jeepOne, 1];

However when I go to use this I run into I don't know an hour or so before it is right and that is because I come here and someone says do it this way but I am not following the handle they use and why they chose it.

Also the use of %1 or %2 what does it mean? When is it important for me to use it?

I am sorry for all of the questions but I really do want to understand this.

Share this post


Link to post
Share on other sites
The use of { } vs the use of [] what the heck is the difference in the brackets?

This {} denotes a block of code. It can be referred to as a scope. These structures can be seen all over script e.g

nul = spawn {
//do blah
};

Here it holds a block of code that is run via the spawn command.

if ( something ) do {
//Do some other thing
};

Here it holds a block of code that will run if the IF condition is true.

Placing a _ in front of a variable makes it a local variable to the scope it was defined in. The variable will be deleted once the scope it was defined in has ended.

For instance lets combine the two examples above..

nul = spawn {

_msg1 = "Hello";

if ( true ) do {

	_msg2 = "World";

	systemChat _msg1;
	systemChat _msg2;

};

systemChat _msg1;
[color="#FF0000"]systemChat _msg2;[/color]

};

Here we have a block of code ( scope ) that will be run via the spawn command. This code also contains another block of code that is part of the IF structure.

_msg1 is defined inside the spawn's code block. It is available to be used anywhere within the this scope including inside the if's code block as the IF itself is also part of this scope.

_msg2 on the other hand is defined inside the if's code block. As it has been defined within the if's scope it will be unavailable outside of this scope. So the second hint _msg2 ( in red ) will throw an undefined error as it does not know what _msg2 is as the variable was deleted as we left the if's scope.

This [] denotes a list/array. It is a container for things, these can be anything from strings, numbers, gameObjects etc.

_myArray = [ 1, "Hello", mySoldier ]

Here we have an array that is holding three things, a number ( 1 ), a string ( "Hello" ) and a gameObject ( mySoldier ).

There are many commands for manipulating arrays some of which are...

select - can be used to retrieve a certain thing inside the array by specifying its index ( remember arrays are 0 based, so the first index is 0 )

_myNumber = _myArray select 0;
_myString = _myArray select 1;
_myUnit = _myArray select 2;

count - will return a number of how many things the array holds...

_numberOfThings = count _myArray

_numberOfThings will be 3.

Also when I write a trigger and I put in any _variable it is local however if I put it in brackets it is not??
Placing any code inside a box in the editor be this a units init, a trigger onAct, a waypoint statement or what ever, you can think of the box as being the {}, that piece of code is its own scope. The code in these boxes are run in what is known a global space in which you can not even use local variables, how ever starting a new scope within these is allowed which then allows you to declare local variables within this new scope.

Inside a objects init box this refers to the object you are placing. To define a variable that you can use in other places for this object you need to define a global variable ( remember as discussed in this last paragraph local variables are useless here ).

mySoldier = this;

mySoldier is now a global variable holding a reference to the unit, this variable can now be used anywhere else in any of your code to refer to the unit. Global variables are not scope dependent so will exist until either the mission ends or you delete them yourself by assigning them the NIL.

The other option is to just name the unit in the name box mySoldier which would have exactly the same results as placing the line of code from above. When the mission runs it takes the name and makes it a global variable holding a reference to the unit ( there are some differences but nothing i am going to go into here ). You can now use this name in any of your code to refer to the unit.

I see a lot of examples 0=[] {_squad1 do action or command}??

I think your miss quoting the code as that would not work.

0 = this spawn {
_mySoldier = _this;
_mySoldier moveInCargo myVehicle;
};

Imagine this is in a soldiers init box. Here we spawn a new piece of code ( a new scope ) passing in the unit this. The 0 = is needed as the command spawn passes back a handle to this new scope and without it would throw an error when used in global space. Inside our new scope we are now free to use local variables. We define a local variable of _mySoldier assigning it the unit we passed in _this ( as discussed in my last post ). We then use this local variable to move the unit into a vehicle called myVehicle as cargo.

Of course this is a rubbish example and could of just of easily of been done by just saying

this moveInCargo myVehicle

straight in the init box.

Also the use of %1 or %2 what does it mean? When is it important for me to use it?

I am sorry for all of the questions but I really do want to understand this.

These you have most likely seen as part of a format command. Format takes a string and replaces any %number's with the following variables, e.g

_msg = format [ "%1 says %2", "Larrow", "Hello" ];

%1 will be replaced with Larrow and %2 would be replace with Hello leaving _msg holding a string that says "Larrow says Hello";

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  

×