Lou Montana/Sandbox – User

From Bohemia Interactive Community
Jump to navigation Jump to search
m (tiny update)
m (Future Template:Header/Tutorial template)
(33 intermediate revisions by 2 users 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|}}}
 
| Target: {{#switch:{{{target}}}
[[:Category: Scripting Topics]]
  |0= newcomer
== Best practices ==
  |1= beginner
 
  |2= moderate
=== Make it readable ===
  |3= advanced
 
  |4= expert
{{Informative | See [[Code Optimisation#Make it readable|Make it readable]] for the short version!}}
  |#default= -wrong target defined-
* Some general coding tips from [https://www.topcoder.com/blog/coding-best-practices/ here]: standards, line lengths, etc
}}
** Variable names should indicate what they store / are used for.
| -no target defined-}}
;Example:
* {{#if:{{{difficulty|}}}
<code>{{cc|Instead of}}
| Difficulty: {{#switch:{{{difficulty}}}
[[private]] _cd = 360;
  |0= easy {{Colorball|green}}
{{cc|do}}
  |1= normal {{Colorball|orange}}
[[private]] _countDown = 360;</code>
  |2= hard {{Colorball|red}}
 
  |#default= -wrong difficulty defined-
** Format, indentation, no one-line, spacing, line returns
}}
** 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)
| -no difficulty defined-}}
* Use comments frequently to explain ''not'' what the code does, but ''why'' it is done this way.
{{#if:{{{prerequisites|}}}
 
|
=== Make reusable functions ===
* Prerequisites:<br>
 
{{{prerequisites}}}
* Don't duplicate, make functions
}}
* Don't make macros to replace SQF code
}}</includeonly><noinclude>{{Doc/Template
 
|descr= Tutorial header.
=== Variables ===
|param1= target
 
|descr1= number in range 0..4: newcomer - beginner - moderate - advanced - expert
* Prefix your public variables and [[setVariable]] with your tag
|param2= difficulty
* PRIVATE (or params) your variables
|descr2= number in range 0..2: easy - normal - hard
* Use #define SOME_CONST for constant values instead of variables
|param3= prerequisites
 
|descr3= (Optional) free text for prerequisite tutorials/knowledge. make a (sub-)list with <nowiki>**</nowiki> and new lines
=== Code location ===
|example1= <nowiki>{{Header/Tutorial}}</nowiki>
 
|result1= {{User:Lou_Montana/Sandbox}}
* '''Nothing''' in init box ''but'' [[local]] commands for this specific unit - '''all''' the init boxes are run client-side on client connection
|example2= <nowiki>{{Header/Tutorial|target=0}}</nowiki>
* {{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.
|result2= {{User:Lou_Montana/Sandbox|target=0}}
 
|example3= <nowiki>{{Header/Tutorial|target=0|difficulty=0}}</nowiki>
 
|result3= {{User:Lou_Montana/Sandbox|target=0|difficulty=0}}
== Final words ==
|example4= <nowiki>{{Header/Tutorial|target=0|difficulty=1|prerequisites=a prerequisite}}</nowiki>
 
|result4= {{User:Lou_Montana/Sandbox|target=0|difficulty=1|prerequisites=a prerequisite}}
* Learn from others' scripts but don't steal code and pretend it's yours — be a decent human being.
|example5= <span style="white-space: pre"><nowiki>{{Header/Tutorial|target=0|difficulty=2|prerequisites=** prerequisite 1
* Don't try to obfuscate your code: it is considered rude, especially since you learnt from others.
** prerequisite 2}}</nowiki></span>
* Have fun!
|result5= {{User:Lou_Montana/Sandbox|target=0|difficulty=2|prerequisites=** prerequisite 1
** prerequisite 2}}
}}</noinclude>

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