Lou Montana/Sandbox – User

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Getting started; recommended skills to do the thing and some minor changes)
m (Future Template:Header/Tutorial template)
(32 intermediate revisions by the same user not shown)
Line 1: Line 1:
__NOTOC__
[[Category: Sandbox]]
[[Category: Sandbox]]
{{Informative | Future [[Code Best Practices]] page}}
<noinclude>
{{Important | this is at the moment '''only a list of topics''' and absolutely not the final render. Almost each list entry will result in a chapter.}}
-----
 
Future [[Template:Header/Tutorial|Header/Tutorial]] template
 
</noinclude><includeonly>{{Feature|informative
----
|
 
* {{#if:{{{target|}}}
[[:Category: Scripting Topics]]
| Target: {{#switch:{{{target}}}
 
  |0= newcomer
==Getting start==
  |1= beginner
 
  |2= moderate
===Recommended skills and things===
  |3= advanced
*An Arma game
  |4= expert
*Passion
  |#default= -wrong target defined-
*Little bit English knowledge and/or access to a translator to your mother language
}}
*Tutorial/example article (Such as this)
| -no target defined-}}
*Skill of Googling
* {{#if:{{{difficulty|}}}
*Advanced text editor (Such as Notepad++)
| Difficulty: {{#switch:{{{difficulty}}}
 
  |0= easy {{Colorball|green}}
== Best practices ==
  |1= normal {{Colorball|orange}}
 
  |2= hard {{Colorball|red}}
=== Make it readable ===
  |#default= -wrong difficulty defined-
 
}}
{{Informative | See [[Code Optimisation#Make it readable|Make it readable]] for the short version!}}
| -no difficulty defined-}}
* Some general coding tips from [https://www.topcoder.com/blog/coding-best-practices/ here]: standards, line lengths, etc
{{#if:{{{prerequisites|}}}
** Variable names should indicate what they store / are used for.
|
;Example:
* Prerequisites:<br>
<code>{{cc|Instead of}}
{{{prerequisites}}}
[[private]] _cd = 360;
}}
{{cc|do}}
}}</includeonly><noinclude>{{Doc/Template
[[private]] _countDown = 360;</code>
|descr= Tutorial header.
 
|param1= target
* Format, indentation, no one-line, spacing, line returns
|descr1= number in range 0..4: newcomer - beginner - moderate - advanced - expert
* Be consistent (space/tab indentation, (camel)casing, [https://en.wikipedia.org/wiki/Indentation_style#K&R_style K&R style] / [https://en.wikipedia.org/wiki/Indentation_style#Allman_style Allman style] indenting)
|param2= difficulty
* Use comments frequently to explain ''not'' what the code does, but ''why'' it is done this way.
|descr2= number in range 0..2: easy - normal - hard
 
|param3= prerequisites
=== Make reusable functions ===
|descr3= (Optional) free text for prerequisite tutorials/knowledge. make a (sub-)list with <nowiki>**</nowiki> and new lines
 
|example1= <nowiki>{{Header/Tutorial}}</nowiki>
* Don't copy and paste the same code, make functions
|result1= {{User:Lou_Montana/Sandbox}}
* Don't make macros to replace SQF code
|example2= <nowiki>{{Header/Tutorial|target=0}}</nowiki>
 
|result2= {{User:Lou_Montana/Sandbox|target=0}}
=== Variables ===
|example3= <nowiki>{{Header/Tutorial|target=0|difficulty=0}}</nowiki>
 
|result3= {{User:Lou_Montana/Sandbox|target=0|difficulty=0}}
* Prefix your public variables and [[setVariable]] with your tag
|example4= <nowiki>{{Header/Tutorial|target=0|difficulty=1|prerequisites=a prerequisite}}</nowiki>
* PRIVATE (or params) your variables
|result4= {{User:Lou_Montana/Sandbox|target=0|difficulty=1|prerequisites=a prerequisite}}
* Use {{Inline code|#define SOME_CONST}} for constant values instead of variables
|example5= <span style="white-space: pre"><nowiki>{{Header/Tutorial|target=0|difficulty=2|prerequisites=** prerequisite 1
 
** prerequisite 2}}</nowiki></span>
=== Code location ===
|result5= {{User:Lou_Montana/Sandbox|target=0|difficulty=2|prerequisites=** prerequisite 1
 
** prerequisite 2}}
* '''Nothing''' in init box ''but'' [[local]] commands for this specific unit - '''all''' the init boxes are run client-side on client connection
}}</noinclude>
* {{Inline code|<span style{{=}}"background-color: #FCC">'''0 {{=}}''' </span>''myCommand''}} is "useful" only for editor fields that for no apparent reason refuse commands returning a value.
 
 
== Final words ==
 
* Learn from others' scripts but don't steal code and pretend it's yours — be a decent human being.
* Don't try to obfuscate your code: it is considered rude, especially since you learnt from others.
* Have fun!

Revision as of 16:05, 16 April 2021



Future Header/Tutorial template Tutorial header.

This template is used on these pages.

Usage

{{Lou Montana/Sandbox|target|difficulty|prerequisites}}

  • target: number in range 0..4: newcomer - beginner - moderate - advanced - expert
  • difficulty: number in range 0..2: easy - normal - hard
  • prerequisites: (Optional) free text for prerequisite tutorials/knowledge. make a (sub-)list with ** and new lines
Examples
Code Result
{{Header/Tutorial}}
  • -no target defined-
  • -no difficulty defined-
{{Header/Tutorial|target=0}}
  • Target: newcomer
  • -no difficulty defined-
{{Header/Tutorial|target=0|difficulty=0}}
  • Target: newcomer
  • Difficulty: easy
{{Header/Tutorial|target=0|difficulty=1|prerequisites=a prerequisite}}
  • Target: newcomer
  • Difficulty: normal
  • Prerequisites:
a prerequisite
{{Header/Tutorial|target=0|difficulty=2|prerequisites=** prerequisite 1 ** prerequisite 2}}
  • Target: newcomer
  • Difficulty: hard
  • Prerequisites:
    • prerequisite 1
    • prerequisite 2