X39 – User talk

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
m (Blanking)
Tag: Blanking
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Rewrite of [[Debugging_Techniques]]
-----
{{SideTOC}}
{{Quote|Debugging is the process of finding and resolving defects or problems within a computer program that prevent correct operation of computer software or a system.|Wikipedia|https://en.wikipedia.org/w/index.php?title=Debugging&oldid=870846458}}


= For Starters =
Debugging is, most of the time, literally as complicated as writing the actual code itself.
You usually get hinted by the game, where some error happened, and what it was.
However, the actual error reason might be something completely else (eg. you get the error on a variable being [[nil]] somewhere, but the actual error is that you misstyped it where you set it initially).
{{Important|For Arma 3, you need to enable ''Show Script Errors'' in the Launcher or set the corresponding [[Arma_3_Startup_Parameters|-showScriptErrors]] flag}}
A script error will greet you with this box:
[[File:A3_ScriptErrorMsg.jpg|thumb|Script error message|center|500px]]
It tells you what went wrong, shows a snippet of the code that failed and, unless you used a command combination like eg. `[[compile]] [[loadFile]]`, what file and line it occured on.
Knowing this, you now can proceed to find the actual reason why you errored on that specific piece of code.
{{informative|This info can also be found in the RTP log}}
= RPT files =
A [[arma.RPT|RPT]] file, is the log file of the game.
It will dump debug informations and stuff that went wrong in here.
Using commands like [[diag_log]], a scripter also may dump info in here.
{{Important|The RPT file might be disabled using the Arma 3 launcher or by setting the corresponding [[Arma_3_Startup_Parameters|-noLogs]] flag}}
For Arma 3, they can be found at (WINDOWS VISTA / 7 / 8):
<code>'''%userprofile%'''\AppData\Local\Arma 3</code>
= Actual Techniques =
== Using no tools ==
The most simple thing you can do, is to add output. This can be done, using for example [[diag_log]].
Output yourself a few [[Variables|variables]] that relate to your problem (for example: When the error occurs because you land in some [[if]] block, output the corresponding variables inside of the if).
You continue doing this until you hit the actual problem: When [[Variables|variable]] A is not set, go to where [[Variables|variable]] A gets set and check around there, repeat and continue.
The same can be done for non-critical errors like when a method is "just" computing the wrong values.
== Using Tools ==
The community developed numerous tools to make debugging easier.
{| class="wikitable"
! Game
! User
! Addon-/Toolname
! What
! Link
|-
|{{GVI|arma|1.0}}
|[[User:Vektorboson|Vektorboson]]
|
|Debugging console
|<s>[http://home.arcor.de/vektorboson/res/console_3.7z '''''LINK DEAD''''']</s>
|-
|{{GVI|arma|1.0}}
|[[User:Str|Str]]
|
|Debugging console (addon, available in intros, missions and outros)
|<s>[http://www.flashpoint1985.com/cgi-bin/ikonboard311/ikonboard.cgi?s=1593a8bb7375674288e681ba36b48dc3;act=ST;f=70;t=56294 '''''LINK DEAD''''']</s>
|-
|{{GVI|arma|1.0}}
|Charon Productions
|TroopMon
|Debugging system containing informations relevant to mission-makers (especially about AI)
|<s>[http://www.flashpoint1985.com/cgi-bin/ikonboard311/ikonboard.cgi?s=c10d84cce14a63a54ac915506d008e80;act=ST;f=69;t=57493 '''''LINK DEAD''''']</s>
|-
|{{GVI|arma2|1.0}}
|[[User:Str|Str]]
|
|Debug console
|[http://temp.moricky.com/arma2/stra_debug2.rar download]
|-
|{{GVI|arma2|1.0}}
|Charon Productions
|TroopMon3
|Debugging system containing informations relevant to mission-makers (especially about AI)
|[http://www.armaholic.com/page.php?id=7948 download]
|-
|{{GVI|arma2|}}
|[[User:Kju|Kju]]
|DevCon
|
|<s>[http://forums.bistudio.com/showthread.php?t=126249 download]
|-
|{{GVI|arma2|1.0}}
|Chain of Command
|Binary gamefile viewer
|Allows to check variables and script states in save files
|<s>[http://ofp.gamepark.cz/index.php?showthis=6989&newlang=eng '''''LINK DEAD''''']</s>
|-
|{{GVI|tkoh|1.0}}
|[[Bohemia_Interactive|Bohemia Interactive]]
| -/-
|Debug Console capable of executing code and more.
|[[Mission_Editor:_Debug_Console_(Take_On_Helicopters)|Shipped With Game]]
|-
|{{GVI|arma3|1.0}}
|[[Bohemia_Interactive|Bohemia Interactive]]
| -/-
|Debug Console capable of executing code and more.
|[[Mission_Editor:_Debug_Console_(Arma 3)|Shipped With Game]]
|}
-----
-----
-----
Old Stuff
-----
-----
-----
== General debugging techniques ==
=== Addons ===
If you're working with an existing addon, or are developing one, repacking a PBO can be time-intensive, and 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 then running the scenario or mission locally. The easiest way of accomplishing this is by the use of [[Event Scripts]] to run your code such as [[init.sqf]]. Once you have tested your code, using missions in 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.
=== Syntax checking and highlighting ===
Syntax errors can be a frequent occurrence when developing scripts. There are several methods of determining if the syntax is correct before running scripts; [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 [http://www.armaholic.com/page.php?id=8680 here], although errors will only be visible from the absence of highlighting.
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. The plugin will automatically check if you are using all commands with the proper syntax and with proper argument types.
=== Debugging specific sections of code ===
Although primitive, the use of [[diag_log]] and [[format]] can be used to debug the content of variables when entering them into functions. In the case that specific pieces of code do not run, or if specific if conditions don't appear to fire, debugging the contents of that specific variable with diag_log can be useful. As with all debugging, so long as the developer is methodical and logical in checking each section of code that runs, finding bugs and resolving them can be straightforward.
===Keep it simple===
If you're having great difficulty solving a problem, simplify the problem, take the part of the mission which does not work, paste it into a new test mission so that you don't have to watch the effect of the rest of the script(s).
[[Category:Arma 3: Editing]]
[[Category:ArmA 2: Editing]]
[[Category:ArmA: Editing]]
[[Category:Operation Flashpoint: Editing]]
[[Category:Scripting Topics]]

Latest revision as of 21:12, 18 November 2019