Lou Montana/Sandbox – User

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Update w/ links)
 
(97 intermediate revisions by 5 users not shown)
Line 1: Line 1:
[[Debugging Techniques]] are ways in which developers can debug, or find out where errors or unexpected outcomes are occurring within their scripts.
[[Category: Sandbox]]
Several methods of debugging exist, however there is no debugging system as such available to developers similar to that which is found within an '''I'''ntegrated '''D'''evelopment '''E'''nvironment or with other languages.
{{Feature|informative|To go on [[Initialisation Order]].}}


{| class="wikitable sortable align-center align-left-col-1"
|+ Order of Initialisation (use column sorting for respective machine order)
! rowspan="2" class="unsortable" style="text-align: center" | Task
! rowspan="2" | Exec Environment
! rowspan="1" colspan="5" class="unsortable" | Machine
|-
! Single Player
! Dedicated Server
! Hosted Server
! Multiplayer Client
! [[Multiplayer Scripting#Join In Progress|JIP]] MP Client


== Code ==
|-
| [[Arma 3: Functions Library|Functions]] with <syntaxhighlight lang="cpp" inline>recompile</syntaxhighlight> {{Link|Arma 3: Functions Library#Attributes 3|attribute}} are recompiled
| {{n/a}}
| 1 <!-- Single Player -->
| 1 <!-- Dedicated Server -->
| 1 <!-- Hosted Server -->
| 1 <!-- Multiplayer Client -->
| 1 <!-- JIP MP Client -->


=== Syntax Highlight ===
|-
| [[Arma 3: Functions Library|Functions]] with <syntaxhighlight lang="cpp" inline>preInit</syntaxhighlight> {{Link|Arma 3: Functions Library#Attributes 3|attribute}} are called
| [[Scheduler#Unscheduled Environment|Unscheduled]]
| 2 <!-- Single Player -->
| 2 <!-- Dedicated Server -->
| 2 <!-- Hosted Server -->
| 2 <!-- Multiplayer Client -->
| 2 <!-- JIP MP Client -->


Syntax errors can be a frequent occurrence when developing scripts. '''Syntax highlight''' will help you find typos in commands
|-
| Object Init Event Handlers are called
| [[Scheduler#Unscheduled Environment|Unscheduled]]
| 3 <!-- Single Player -->
| 3 <!-- Dedicated Server -->
| 3 <!-- Hosted Server -->
| 3 <!-- Multiplayer Client -->
| {{Icon|unchecked}} <!-- JIP MP Client -->


[https://sites.google.com/site/macsarmatools/squint Squint] provides a fully-featured code editor which allows for syntax highlighting, displaying of errors and code correction.
|-
A simpler solution of code highlighting for Notepad++ is also available, although errors will only be visible from the absence of highlighting.
| Expressions of [[Eden Editor: Configuring Attributes|Eden Editor entity attributes]] are called<ref name="isPlayer"><sqf inline>isPlayer _entity</sqf> does not return [[true]] immediately. Once the entity has become a [[player]], it is transferred to the client.</ref>
The plugin will automatically check if you are using all commands with the proper syntax and with proper argument types.
| [[Scheduler#Unscheduled Environment|Unscheduled]]
Using [https://forums.bohemia.net/forums/topic/202181-sqdev-sqf-developing-in-eclipse/ SQDev] you will get code validation (linting) while you are typing it.
| 4 <!-- Single Player -->
| 4 <!-- Dedicated Server -->
| 4 <!-- Hosted Server -->
| {{Icon|unchecked}} <!-- Multiplayer Client -->
| {{Icon|unchecked}} <!-- JIP MP Client -->


Many tools are available:
|-
* [https://forums.bohemia.net/profile/797692-sanjo/ Sanjo]'s Notepad++ SQF (npp-sqf): [http://www.armaholic.com/page.php?id=8680 Forum post] - [https://github.com/Sanjo/npp-sqf GitHub repository]
| Object initialisation fields are called
* [https://forums.bohemia.net/profile/1044335-krzmbrzl/ krzmbrzl]'s SQDev: [https://forums.bohemia.net/forums/topic/202181-sqdev-sqf-developing-in-eclipse/ Forum post] - [https://github.com/Krzmbrzl/SQDev GitHub repository]
| [[Scheduler#Unscheduled Environment|Unscheduled]]
* [[User:Sbsmac|Sbsmac]]'s Squint: [https://forums.bohemia.net/forums/topic/101921-squint-the-sqf-editor-and-error-checker/ Forum post] - [https://sites.google.com/site/macsarmatools/squint website]
| 5 <!-- Single Player -->
| 5 <!-- Dedicated Server -->
| 5 <!-- Hosted Server -->
| 4 <!-- Multiplayer Client -->
| 3 <!-- JIP MP Client -->


=== Finding Errors ===
|- style="background-color: #95F0AD"
| [[Event Scripts#init.sqs|init.sqs]] is executed
|
| 6 <!-- Single Player -->
| <!-- Dedicated Server -->
| <!-- Hosted Server -->
| <!-- Multiplayer Client -->
| <!-- JIP MP Client -->


To solve an issue, you must first find out there is one. Besides your script not having the wanted effect (if any), an error message helps you locate the code issue.
|- style="background-color: #95F0AD"
* Be sure to use [[Arma 3 Startup Parameters#Developer Options|<tt>-showScriptErrors</tt> startup parameter]] to display the error on-screen
| [[Event Scripts#init.sqf|init.sqf]] is executed
* Read [[Crash Files|RPT files]] for more information (make sure <tt>-noLogs</tt> startup parameter is not enabled or the logs will never be filled)
| [[Scheduler#Scheduled Environment|Scheduled]]<ref name="enginewaits">Note '''in single player''' that while the environment is [[Scheduler#Scheduled Environment|Scheduled]] ([[canSuspend]] returns true), the engine seems to wait until the script is done executing, essentially behaving similarly to an [[Scheduler#Unscheduled Environment|Unscheduled environment]] - infinite loops will freeze the game, [[uiSleep]] may pause the game for up to ~20s (postInit), [[waitUntil]] can cause catastrophic issues, etc.</ref>
** Scripts running on a server use the '''ArmaXServer.RPT''' file which has varying locations depending upon the type of server being run.
| <!-- Single Player -->
** Scripts running on a client use the '''ArmaX.RPT''' file.
| <!-- Dedicated Server -->
** RPT files location is usualle <tt>%localappdata%\ArmaX</tt>
| <!-- Hosted Server -->
| <!-- Multiplayer Client -->
| <!-- JIP MP Client -->


=== Removing Errors ===
|-
| Expressions of [[Eden Editor: Configuring Attributes|Eden Editor scenario attributes]] are called<ref name="playerCommandNotAvailable">[[player]] is not available immediately.</ref>
| [[Scheduler#Unscheduled Environment|Unscheduled]]
| <!-- Single Player -->
| <!-- Dedicated Server -->
| <!-- Hosted Server -->
| <!-- Multiplayer Client -->
| <!-- JIP MP Client -->


Once the script error is located: '''be sure to check the BiKi page corresponding to the command/function you are using!!''
|- style="background-color: #95DEF0"
| Persistent functions are called
|
| <!-- Single Player -->
| <!-- Dedicated Server -->
| <!-- Hosted Server -->
| <!-- Multiplayer Client -->
| <!-- JIP MP Client -->


{{Informative|
|-
If you're having great difficulty solving a problem, the good way is to bring the issue to the simplest code;
| [[Modules]] are initialised
take the mission part that doesn't work, paste it into a new test mission and work from here.
|
Doing so will avoid you dealing with other scripts side effects!}}
| <!-- Single Player -->
| <!-- Dedicated Server -->
| <!-- Hosted Server -->
| <!-- Multiplayer Client -->
| {{Icon|unchecked}} <!-- JIP MP Client -->


==== Common errors ====
|- style="background-color: #DEF0AD"
* If a ''generic error'' happens on a [[sleep]]/[[uiSleep]]/[[waitUntil]], you may be in [[Scheduler#Unscheduled Environment|unscheduled environment]]
| [[Event Scripts#initServer.sqf|initServer.sqf]] is executed
| [[Scheduler#Scheduled Environment|Scheduled]]
| <!-- Single Player -->
| <!-- Dedicated Server -->
| <!-- Hosted Server -->
| {{n/a}} <!-- Multiplayer Client -->
| {{n/a}} <!-- JIP MP Client -->


=== Working with Addons ===
|- style="background-color: #DEF0AD"
If you are working on an addon, repacking a PBO can be time-intensive.
| [[Event Scripts#initPlayerLocal.sqf|initPlayerLocal.sqf]] is executed
This operation can be replaced simply by creating a basic mission in the "Missions" or "MPmissions" (if your feature is multiplayer-specific) folder of your game installation, and running the mission locally.
| [[Scheduler#Scheduled Environment|Scheduled]]
The easiest way of accomplishing this is by the use of [[Event Scripts]] to run your code such as [[init.sqf]].
| <!-- Single Player -->
Once you have tested your code this way, you can then sequentially pack your PBO when major changes have been made, rather than for each debug session of a script or piece of code.
| {{n/a}} <!-- Dedicated Server -->
| <!-- Hosted Server -->
| <!-- Multiplayer Client -->
| <!-- JIP MP Client -->


=== Debugging specific sections of code ===
|- style="background-color: #DEF0AD"
Although primitive, the use of [[diag_log]], [[systemChat]]/[[hint]] and [[format]] can be used to debug the content of variables when entering them into functions.
| [[Event Scripts#initPlayerServer.sqf|initPlayerServer.sqf]] is executed on the server
In the case that specific pieces of code do not run, or if specific ''if'' conditions don't appear to fire, debugging the variable content with [[diag_log]] can be useful.
| [[Scheduler#Scheduled Environment|Scheduled]]
As with all debugging, as long as the developer is methodical and logical in checking each section of code that runs, finding bugs and resolving them can be straightforward.
| <!-- Single Player -->
| {{n/a}} <!-- Dedicated Server -->
| ?? <!-- Hosted Server -->
| <!-- Multiplayer Client -->
| <!-- JIP MP Client -->


|-
| [[Arma 3: Functions Library|Functions]] with <syntaxhighlight lang="cpp" inline>postInit</syntaxhighlight> {{Link|Arma 3: Functions Library#Attributes 3|attribute}} are called
| [[Scheduler#Scheduled Environment|Scheduled]]<ref name="enginewaits"/>
| <!-- Single Player -->
| <!-- Dedicated Server -->
| <!-- Hosted Server -->
| <!-- Multiplayer Client -->
| <!-- JIP MP Client -->


== Debug Console ==
|- style="background-color: #95DEF0"
| [[Event Scripts#init.sqs|init.sqs]] is executed
| [[Scheduler#Scheduled Environment|Scheduled]]
| <!-- Single Player -->
| <!-- Dedicated Server -->
| <!-- Hosted Server -->
| <!-- Multiplayer Client -->
| <!-- JIP MP Client -->


A '''Debug Console''' is a powerful tool; it is very helpful at debugging your scripting in real time.
|- style="background-color: #95DEF0"
* {{arma3}}
| [[Event Scripts#init.sqf|init.sqf]] is executed
** The game already features [[Mission Editor: Debug Console (Arma 3)|Arma 3 Debug Console]].
| [[Scheduler#Scheduled Environment|Scheduled]]
** [https://forums.bohemia.net/profile/761667-charon-productions/ Charon Productions]' [http://www.armaholic.com/page.php?id=19898 TroopMon3] for Arma 3 (alpha)
| <!-- Single Player -->
* {{tkoh}}
| <!-- Dedicated Server -->
** The game already features [[Mission Editor: Debug Console (Take On Helicopters)|TKOH Debug Console]].
| <!-- Hosted Server -->
* {{arma2}}
| <!-- Multiplayer Client -->
** [[User:Str|Str]]'s [http://temp.moricky.com/arma2/stra_debug2.rar Debug console]
| <!-- JIP MP Client -->
** [https://forums.bohemia.net/profile/761667-charon-productions/ Charon Productions]' [http://www.armaholic.com/page.php?id=7948 TroopMon3] for Arma 2 ([http://www.armaholic.com/page.php?id=7948 TroopMon2] being obsolete and rewritten into this TroopMon3)
** [http://forums.bistudio.com/showthread.php?t=126249 DevCon] by [[User:Kju|Kju]]
* {{arma}}
** [https://forums.bohemia.net/profile/761667-charon-productions/ Charon Productions]' [http://www.armaholic.com/page.php?id=727 TroopMon v0.8b] - Complex debugging system providing lot of information for mission-makers, especially about AI.
** [[User:Str|Str]]'s [http://www.armaholic.com/page.php?id=549 Debug Console] - available in all singleplayer missions, intros and outros. Easy and simple to use (Escape-Enter execute)
* {{ofp}}
** [[User:Vektorboson|Vektorboson]]'s [http://home.arcor.de/vektorboson/res/console_3.7z Debug Console]


|-
| [[remoteExec]]'s [[Multiplayer Scripting#Join In Progress|JIP]] queue
| {{n/a}}
| {{n/a}} <!-- Single Player -->
| {{n/a}} <!-- Dedicated Server -->
| {{n/a}} <!-- Hosted Server -->
| {{n/a}} <!-- Multiplayer Client -->
| 42 <!-- JIP MP Client -->


== Tools ==
|- style="background-color: #EEE"
| ''Scenario going''
| {{n/a}}
| <!-- Single Player -->
| <!-- Dedicated Server -->
| <!-- Hosted Server -->
| <!-- Multiplayer Client -->
| <!-- JIP MP Client -->


* {{arma3}}
|-
** [[User:X39|X39]]'s [https://forums.bohemia.net/forums/topic/210118-sqf-vm-an-sqf-emulator/ SQF VM] - an SQF emulator
| [[Event Scripts#exit.sqf|exit.sqf]]
<!--
|
* {{arma2}}
| <!-- Single Player -->
** -
| <!-- Dedicated Server -->
* {{arma}}
| <!-- Hosted Server -->
** -
| <!-- Multiplayer Client -->
* {{ofp}}
| <!-- JIP MP Client -->
** -
-->


|-
| [[Event Scripts#exit.sqs|exit.sqs]]
|
| <!-- Single Player -->
| <!-- Dedicated Server -->
| <!-- Hosted Server -->
| <!-- Multiplayer Client -->
| <!-- JIP MP Client -->


[[Category:Arma 3: Editing]]
|-
[[Category:ArmA 2: Editing]]
| {{Link|Arma 3: Mission Event Handlers#Ended|"Ended" Mission Event Handler}}
[[Category:ArmA: Editing]]
|
[[Category:Operation Flashpoint: Editing]]
| <!-- Single Player -->
[[Category:Scripting Topics]]
| <!-- Dedicated Server -->
| <!-- Hosted Server -->
| <!-- Multiplayer Client -->
| <!-- JIP MP Client -->


|-
|  {{Link|Arma 3: Mission Event Handlers#MPEnded|"MPEnded" Mission Event Handler}}
|
| <!-- Single Player -->
| <!-- Dedicated Server -->
| <!-- Hosted Server -->
| <!-- Multiplayer Client -->
| <!-- JIP MP Client -->


[[Category:Sandbox]]
|}
 
 
== See Also ==
 
* [[Arma 3: Functions Library]]<!--
* [[Arma 2: Functions Library]] -->
* [[Arma 3: Remote Execution]], [[BIS_fnc_MP]] <!-- keep? -->
* [[Eden Editor: Configuring Attributes|Eden Editor: Configuring Attributes]]
* [[Event Scripts]]
* [[Scheduler]]

Latest revision as of 01:29, 18 March 2024

Order of Initialisation (use column sorting for respective machine order)
Task Exec Environment Machine
Single Player Dedicated Server Hosted Server Multiplayer Client JIP MP Client
Functions with recompile attribute are recompiled N/A 1 1 1 1 1
Functions with preInit attribute are called Unscheduled 2 2 2 2 2
Object Init Event Handlers are called Unscheduled 3 3 3 3 Unchecked
Expressions of Eden Editor entity attributes are called[1] Unscheduled 4 4 4 Unchecked Unchecked
Object initialisation fields are called Unscheduled 5 5 5 4 3
init.sqs is executed 6
init.sqf is executed Scheduled[2]
Expressions of Eden Editor scenario attributes are called[3] Unscheduled
Persistent functions are called
Modules are initialised Unchecked
initServer.sqf is executed Scheduled N/A N/A
initPlayerLocal.sqf is executed Scheduled N/A
initPlayerServer.sqf is executed on the server Scheduled N/A ??
Functions with postInit attribute are called Scheduled[2]
init.sqs is executed Scheduled
init.sqf is executed Scheduled
remoteExec's JIP queue N/A N/A N/A N/A N/A 42
Scenario going N/A
exit.sqf
exit.sqs
"Ended" Mission Event Handler
"MPEnded" Mission Event Handler


See Also

  1. isPlayer _entity does not return true immediately. Once the entity has become a player, it is transferred to the client.
  2. 2.0 2.1 Note in single player that while the environment is Scheduled (canSuspend returns true), the engine seems to wait until the script is done executing, essentially behaving similarly to an Unscheduled environment - infinite loops will freeze the game, uiSleep may pause the game for up to ~20s (postInit), waitUntil can cause catastrophic issues, etc.
  3. player is not available immediately.