General Barron/Sandbox – User

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (Text replacement - "Category:Armed Assault" to "{{arma1}}")
 
(6 intermediate revisions by 4 users not shown)
Line 13: Line 13:
''The table of content you see at the just below this is automatically created from the section headers (lines surrounded by equal signs).''
''The table of content you see at the just below this is automatically created from the section headers (lines surrounded by equal signs).''


==Formatting==
== Formatting ==
:'''bold'''
:'''bold'''
::''italic''
::''italic''
:::Indentation (one position per colon)
:::Indentation (one position per colon)


==Links==
== Links ==
===Internal Links (pages on this wiki)===
=== Internal Links (pages on this wiki) ===


[[Operation Flashpoint: Easter Eggs]] (use full title for normal pages)
[[Operation Flashpoint: Easter Eggs]] (use full title for normal pages)
Line 25: Line 25:
[[Operation Flashpoint: Easter Eggs|Easter Eggs]] (to name a link use [URL | name])
[[Operation Flashpoint: Easter Eggs|Easter Eggs]] (to name a link use [URL | name])


[[:Category:Armed Assault]] (put colon in first column for category pages)
[[:Category:ArmA: Armed Assault|{{arma1}}]] (put colon in first column for category pages)


===External Links (to other sites)===
=== External Links (to other sites) ===
http://en.wikipedia.org/wiki/Wikipedia:How_to_edit_a_page
http://en.wikipedia.org/wiki/Wikipedia:How_to_edit_a_page


Line 33: Line 33:




<hr><hr>


Info for "displayText" command (1.18 hf6), I sent it in an email but it should go on wiki:


The syntax for the command is as follows:
Notes on preprocessor directives in .sqf files (WIP for wiki page):


<obj> DisplayText ["Text", [x/y/z relative position to object],
Linky: http://www.cplusplus.com/doc/tutorial/preprocessor.html
<3d_True/False>, [rgba color], size (number)]


All parameters are optional after "text".
NOTE: all preprocessor directives are run BEFORE the script is run. So you can't expect it to read the value of variables, for example. Preprocessing basically just does find, replace, and paste operations in your code.


Note that 2d text is visible no matter how far away you are from the
--------
object, even if you do not have LOS.
Macro definitions (#define, #undef): these work as described. Note that the two special operators (# and ##) work as well.
--------


Example:
When including defines in defines, the # operator works after expanding all defines. For example:
player DisplayText ["text", [0,0,5], true, [1,0,0,1], 1.5]


Use displaytext [""] to remove any text.
#define fn_myfunc compile preprocessfile 'myfile.sqf'
#define addquotes(x) #x
addquotes(call fn_myfunc)
result is: "call compile preprocessfile 'myfile.sqf'"


You can also use the syntax #variable in the text, in order to display the
Multi-line notes:
contents of object variables of the attached object. The text will be
changed dynamically. Example:


player setVariable ["myvar",1]
To spread a define across mult lines, add \ at the end of each line (save the last). Example:
player displayText ["myvar = #myvar"]
sleep 10
player setVariable ["myvar",2]


In this example, the text over the player's head will change from "myvar =
#define whatever \
1" to "myvar = 2" automatically.
    dosomething; \
    dosomething else
 
Comments:
 
Comments work at the end of single line defines, but not multi-line defines. Example:
 
#define something "whatever" //comment
(this works)
 
#define something \ //comment
"whatever"
(this doesn't work!!!)
 
Nested defines:
 
Defines can be nested in each other, and they are all expanded. You can't seem to put a multi-line define inside of a multi-line define, nor can you pass a multi-line define in as a parameter of a macro.
 
--------
Conditional inclusions (#ifdef, #ifndef, #if, #endif, #else and #elif)
--------
 
#ifdef, #ifndef, #endif all work in configs, and I would assume in scripts as well. I haven't verified #else #elif or #if.
 
---------
Line control (#line)
Error directive (#error)
Pragma directive (#pragma)
---------
 
Doesn't seem to work? At least not in scripts.
 
In scripts, using any unknown # directive seems to cause the entire file to be returned as empty when preprocessed. Ex: placing #asdf or #error, etc, in a script will make it turn into {} when preprocessed. When combined with #ifdef and #ifndef operators, this could be a useful feature.
 
Need to verify what happens in configs with this!
 
---------
Source file inclusion (#include)
---------
 
This obviously works, and is very useful. For example, you can make a common header file for all your scripts. In this header you can #define constants, rather than having to use variables to store them. Also very useful for #defining a descriptive name for numbers such as IDCs and array indexes.
 
I'm not sure about the difference between "" and <> includes. Normally I use "".
 
Note that the path (at least with "") is relative to the directory of the file where you issue the #include.
 
HOWEVER, if you put a \ slash at the beginning, the path will instead be relative to your vbs2.exe / arma.exe. In this way you can include files that are directly in your install directory.
 
You can also #include stuff that is in addon / pbo files in this way. In this case, the path should be the path to the file when it is in your P: drive (i.e. before the pbo is packed), minus the P:. Example: "\vbs2\customer\vehicles\myvehicle\data\scripts\myscript.sqf"
 
---------
Predefined macro names
---------
 
__LINE__ and __FILE__ both WORK when used in .sqf! Very cool!
 
The others don't work though. I need to check to see if these work in configs.
 
Configs have the __EXEC and __EVAL macros predefined. These macros allow the use of variables and simple scripting expressions within configs (string concatenation, while loops, math operations, etc). See other wiki for documentation on these. These macros do NOT work in scripts! These macros work even if the config isn't cfgConverted.
 
[[Category:Sandbox]]

Latest revision as of 01:43, 20 July 2021

This is your 'Sandbox'.

It is your personal place to experiment with wiki code, keep notes, and to store unfinished articles you are working on.

Feel free to change, replace, or delete whatever is in here.

Please keep in mind to follow the rules you can find in the Guidelines, especially to sign your comments with --~~~~, and to write in English only.


Below are some basic commands that you should know before posting on the wiki.

The table of content you see at the just below this is automatically created from the section headers (lines surrounded by equal signs).

Formatting

bold
italic
Indentation (one position per colon)

Links

Internal Links (pages on this wiki)

Operation Flashpoint: Easter Eggs (use full title for normal pages)

Easter Eggs (to name a link use [URL | name])

Armed Assault (put colon in first column for category pages)

External Links (to other sites)

http://en.wikipedia.org/wiki/Wikipedia:How_to_edit_a_page

More wikitext examples (to name a link use [URL space name])





Notes on preprocessor directives in .sqf files (WIP for wiki page):

Linky: http://www.cplusplus.com/doc/tutorial/preprocessor.html

NOTE: all preprocessor directives are run BEFORE the script is run. So you can't expect it to read the value of variables, for example. Preprocessing basically just does find, replace, and paste operations in your code.


Macro definitions (#define, #undef): these work as described. Note that the two special operators (# and ##) work as well.


When including defines in defines, the # operator works after expanding all defines. For example:

  1. define fn_myfunc compile preprocessfile 'myfile.sqf'
  2. define addquotes(x) #x

addquotes(call fn_myfunc) result is: "call compile preprocessfile 'myfile.sqf'"

Multi-line notes:

To spread a define across mult lines, add \ at the end of each line (save the last). Example:

  1. define whatever \
   dosomething; \
   dosomething else

Comments:

Comments work at the end of single line defines, but not multi-line defines. Example:

  1. define something "whatever" //comment

(this works)

  1. define something \ //comment

"whatever" (this doesn't work!!!)

Nested defines:

Defines can be nested in each other, and they are all expanded. You can't seem to put a multi-line define inside of a multi-line define, nor can you pass a multi-line define in as a parameter of a macro.


Conditional inclusions (#ifdef, #ifndef, #if, #endif, #else and #elif)


  1. ifdef, #ifndef, #endif all work in configs, and I would assume in scripts as well. I haven't verified #else #elif or #if.

Line control (#line) Error directive (#error) Pragma directive (#pragma)


Doesn't seem to work? At least not in scripts.

In scripts, using any unknown # directive seems to cause the entire file to be returned as empty when preprocessed. Ex: placing #asdf or #error, etc, in a script will make it turn into {} when preprocessed. When combined with #ifdef and #ifndef operators, this could be a useful feature.

Need to verify what happens in configs with this!


Source file inclusion (#include)


This obviously works, and is very useful. For example, you can make a common header file for all your scripts. In this header you can #define constants, rather than having to use variables to store them. Also very useful for #defining a descriptive name for numbers such as IDCs and array indexes.

I'm not sure about the difference between "" and <> includes. Normally I use "".

Note that the path (at least with "") is relative to the directory of the file where you issue the #include.

HOWEVER, if you put a \ slash at the beginning, the path will instead be relative to your vbs2.exe / arma.exe. In this way you can include files that are directly in your install directory.

You can also #include stuff that is in addon / pbo files in this way. In this case, the path should be the path to the file when it is in your P: drive (i.e. before the pbo is packed), minus the P:. Example: "\vbs2\customer\vehicles\myvehicle\data\scripts\myscript.sqf"


Predefined macro names


__LINE__ and __FILE__ both WORK when used in .sqf! Very cool!

The others don't work though. I need to check to see if these work in configs.

Configs have the __EXEC and __EVAL macros predefined. These macros allow the use of variables and simple scripting expressions within configs (string concatenation, while loops, math operations, etc). See other wiki for documentation on these. These macros do NOT work in scripts! These macros work even if the config isn't cfgConverted.