mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
143 lines
34 KiB
HTML
143 lines
34 KiB
HTML
<!DOCTYPE html> <html lang="en-US"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <title>SSLC - sfall</title> <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"> <link rel="stylesheet" href="/assets/css/just-the-docs-default.css"> <script type="text/javascript" src="/assets/js/vendor/lunr.min.js"></script> <script type="text/javascript" src="/assets/js/just-the-docs.js"></script> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- Begin Jekyll SEO tag v2.3.0 --> <title>SSLC | sfall</title> <meta property="og:title" content="SSLC" /> <meta property="og:locale" content="en_US" /> <meta name="description" content="Sfall documentation" /> <meta property="og:description" content="Sfall documentation" /> <link rel="canonical" href="/sslc/" /> <meta property="og:url" content="/sslc/" /> <meta property="og:site_name" content="sfall" /> <script type="application/ld+json"> {"@type":"WebPage","image":null,"url":"/sslc/","publisher":null,"author":null,"headline":"SSLC","dateModified":null,"datePublished":null,"sameAs":null,"description":"Sfall documentation","mainEntityOfPage":null,"name":null,"@context":"http://schema.org"}</script> <!-- End Jekyll SEO tag --> <link rel="apple-touch-icon" sizes="180x180" href="/assets/favicon/apple-touch-icon.png"> <link rel="icon" type="image/png" sizes="32x32" href="/assets/favicon/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="16x16" href="/assets/favicon/favicon-16x16.png"> <link rel="manifest" href="/assets/favicon/site.webmanifest"> <link rel="mask-icon" href="/assets/favicon/safari-pinned-tab.svg" color="#5bbad5"> <meta name="msapplication-TileColor" content="#da532c"> <meta name="msapplication-config" content="/assets/favicon/browserconfig.xml"> <meta name="theme-color" content="#ffffff"> </head> <body> <svg xmlns="http://www.w3.org/2000/svg" style="display: none;"> <symbol id="svg-link" viewBox="0 0 24 24"> <title>Link</title> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"> <path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path> </svg> </symbol> <symbol id="svg-search" viewBox="0 0 24 24"> <title>Search</title> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"> <circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line> </svg> </symbol> <symbol id="svg-menu" viewBox="0 0 24 24"> <title>Menu</title> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-menu"> <line x1="3" y1="12" x2="21" y2="12"></line><line x1="3" y1="6" x2="21" y2="6"></line><line x1="3" y1="18" x2="21" y2="18"></line> </svg> </symbol> <symbol id="svg-arrow-right" viewBox="0 0 24 24"> <title>Expand</title> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-right"> <polyline points="9 18 15 12 9 6"></polyline> </svg> </symbol> <symbol id="svg-doc" viewBox="0 0 24 24"> <title>Document</title> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-file"> <path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"></path><polyline points="13 2 13 9 20 9"></polyline> </svg> </symbol> </svg> <div class="side-bar"> <div class="site-header"> <a href="/" class="site-title lh-tight"> sfall </a> <a href="#" id="menu-button" class="site-button"> <svg viewBox="0 0 24 24" class="icon"><use xlink:href="#svg-menu"></use></svg> </a> </div> <nav role="navigation" aria-label="Main" id="site-nav" class="site-nav"> <ul class="nav-list"><li class="nav-list-item"><a href="/" class="nav-list-link">Home</a></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="/arrays/" class="nav-list-link">Arrays</a><ul class="nav-list "><li class="nav-list-item "><a href="/array-functions/" class="nav-list-link">Array functions</a></li><li class="nav-list-item "><a href="/lists/" class="nav-list-link">Lists</a></li></ul></li><li class="nav-list-item"><a href="/best-practices/" class="nav-list-link">Best practices</a></li><li class="nav-list-item"><a href="/data-types/" class="nav-list-link">Data types</a></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="/global-scripts/" class="nav-list-link">Global scripts</a><ul class="nav-list "><li class="nav-list-item "><a href="/global-script-functions/" class="nav-list-link">Global script functions</a></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="/hooks/" class="nav-list-link">Hooks</a><ul class="nav-list "><li class="nav-list-item "><a href="/hook-functions/" class="nav-list-link">Hook functions</a></li><li class="nav-list-item "><a href="/hook-types/" class="nav-list-link">Hook types</a></li></ul></li><li class="nav-list-item active"><a href="/sslc/" class="nav-list-link active">SSLC</a></li><li class="nav-list-item"><a href="/optimization/" class="nav-list-link">Optimization</a></li><li class="nav-list-item"><a href="/animations/" class="nav-list-link">Animations</a></li><li class="nav-list-item"><a href="/art-and-appearance/" class="nav-list-link">Art and appearance</a></li><li class="nav-list-item"><a href="/audio/" class="nav-list-link">Audio</a></li><li class="nav-list-item"><a href="/car/" class="nav-list-link">Car</a></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="/combat/" class="nav-list-link">Combat</a><ul class="nav-list "><li class="nav-list-item "><a href="/knockback/" class="nav-list-link">Knockback</a></li><li class="nav-list-item "><a href="/weapons-and-ammo/" class="nav-list-link">Weapons and ammo</a></li></ul></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="/direct-memory-access/" class="nav-list-link">Direct memory access</a><ul class="nav-list "><li class="nav-list-item "><a href="/call_offset_vx/" class="nav-list-link">call_offset_vX</a></li><li class="nav-list-item "><a href="/read_xxx/" class="nav-list-link">read_xxx</a></li><li class="nav-list-item "><a href="/write_xxx/" class="nav-list-link">write_xxx</a></li></ul></li><li class="nav-list-item"><a href="/explosions/" class="nav-list-link">Explosions</a></li><li class="nav-list-item"><a href="/global-variables/" class="nav-list-link">Global variables</a></li><li class="nav-list-item"><a href="/graphics/" class="nav-list-link">Graphics</a></li><li class="nav-list-item"><a href="/ini-settings/" class="nav-list-link">INI settings</a></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="/interface/" class="nav-list-link">Interface</a><ul class="nav-list "><li class="nav-list-item "><a href="/cursor/" class="nav-list-link">Cursor</a></li><li class="nav-list-item "><a href="/inventory/" class="nav-list-link">Inventory</a></li><li class="nav-list-item "><a href="/main-interface/" class="nav-list-link">Main interface</a></li><li class="nav-list-item "><a href="/outline/" class="nav-list-link">Outline</a></li><li class="nav-list-item "><a href="/pip-boy/" class="nav-list-link">Pip-Boy</a></li><li class="nav-list-item "><a href="/tags/" class="nav-list-link">Tags</a></li><li class="nav-list-item "><a href="/windows-and-images/" class="nav-list-link">Windows and images</a></li></ul></li><li class="nav-list-item"><a href="/keyboard-and-mouse/" class="nav-list-link">Keyboard and mouse</a></li><li class="nav-list-item"><a href="/locks/" class="nav-list-link">Locks</a></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="/maps-and-encounters/" class="nav-list-link">Maps and encounters</a><ul class="nav-list "><li class="nav-list-item "><a href="/rest/" class="nav-list-link">Rest</a></li><li class="nav-list-item "><a href="/worldmap/" class="nav-list-link">Worldmap</a></li></ul></li><li class="nav-list-item"><a href="/objects-and-scripts/" class="nav-list-link">Objects and scripts</a></li><li class="nav-list-item"><a href="/other/" class="nav-list-link">Other</a></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="/perks-and-traits/" class="nav-list-link">Perks and traits</a><ul class="nav-list "><li class="nav-list-item "><a href="/npc-perks/" class="nav-list-link">NPC perks</a></li></ul></li><li class="nav-list-item"><a href="/sfall-funcx-macros/" class="nav-list-link">Sfall funcX macros</a></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="/sfall/" class="nav-list-link">Sfall</a><ul class="nav-list "><li class="nav-list-item "><a href="/funcx/" class="nav-list-link">funcX</a></li><li class="nav-list-item "><a href="/version/" class="nav-list-link">Version</a></li></ul></li><li class="nav-list-item"><a href="/skills/" class="nav-list-link">Skills</a></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="/stats/" class="nav-list-link">Stats</a><ul class="nav-list "><li class="nav-list-item "><a href="/alter-min-max/" class="nav-list-link">Alter min/max</a></li></ul></li><li class="nav-list-item"><a href="/tiles-and-paths/" class="nav-list-link">Tiles and paths</a></li><li class="nav-list-item"><a href="#" class="nav-list-expander"><svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg></a><a href="/variables/" class="nav-list-link">Variables</a><ul class="nav-list "><li class="nav-list-item "><a href="/math/" class="nav-list-link">Math</a></li><li class="nav-list-item "><a href="/strings/" class="nav-list-link">Strings</a></li></ul></li><li class="nav-list-item"><a href="/virtual-file-system/" class="nav-list-link">Virtual file system</a></li></ul> </nav> <footer class="site-footer"> This site uses <a href="https://github.com/pmarsceill/just-the-docs">Just the Docs</a>, a documentation theme for Jekyll. </footer> </div> <div class="main" id="top"> <div id="main-header" class="main-header"> <div class="search"> <div class="search-input-wrap"> <input type="text" id="search-input" class="search-input" tabindex="0" placeholder="Search sfall" aria-label="Search sfall" autocomplete="off"> <label for="search-input" class="search-label"><svg viewBox="0 0 24 24" class="search-icon"><use xlink:href="#svg-search"></use></svg></label> </div> <div id="search-results" class="search-results"></div> </div> <nav aria-label="Auxiliary" class="aux-nav"> <ul class="aux-nav-list"> <li class="aux-nav-list-item"> <a href="https://nma-fallout.com/threads/fo2-engine-tweaks-sfall.178390/" class="site-button" > Forum </a> </li> <li class="aux-nav-list-item"> <a href="https://github.com/phobos2077/sfall/" class="site-button" > GitHub </a> </li> </ul> </nav> </div> <div id="main-content-wrap" class="main-content-wrap"> <div id="main-content" class="main-content" role="main"> <h1 class="no_toc" id="sslc"> <a href="#sslc" class="anchor-heading" aria-labelledby="sslc"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> SSLC </h1> <ul id="markdown-toc"> <li><a href="#command-line-options" id="markdown-toc-command-line-options">Command line options</a></li> <li><a href="#additional-supported-syntax" id="markdown-toc-additional-supported-syntax">Additional supported syntax</a></li> <li><a href="#int2ssl-note" id="markdown-toc-int2ssl-note">int2ssl note</a></li> <li><a href="#fixes" id="markdown-toc-fixes">Fixes</a></li> <li><a href="#backward-compatibility" id="markdown-toc-backward-compatibility">Backward compatibility</a></li> </ul> <p>This is a modified copy of sslc, that has a few bugfixes from the original, that will recognise and compile the additional scripting functions provided by sfall, that can also understand some additional syntax, and that has an integrated preprocessor and optimizer.</p> <p>Unlike the original script compiler, this has not been compiled as a dos program. When using this in place of the original compile.exe but still using p.bat, you need to either get rid of the dos4gw.exe reference from p.bat or replace the original dos4gw.exe with the one in this archive.</p> <p>If you use fallout script editor, you can extract <code class="highlighter-rouge">compile.exe</code> and <code class="highlighter-rouge">dos4gw.exe</code> to its <code class="highlighter-rouge">\binary</code> folder, or extract them somewhere else and change your preferences in FSE to point there. FSE doesn’t seem to be able to tell when errors occur when using this compiler though, so I’d recommend either using sfall’s script editor instead or compiling by hand if possible.</p> <p>When compiling global or hook scripts for sfall 3.4 or below, you <em>must</em> include the line <code class="highlighter-rouge">procedure start;</code> before any <code class="highlighter-rouge">#include</code>s that define procedures to avoid a few weird problems. (this is no longer required starting from 3.5)</p> <p>This version of compiler was designed primarily for new sfall functions, but it can safely (and is recommended) to be used with non-sfall scripts as well, as long as you don’t use any of the arrays syntax and any sfall scripting functions.</p> <p>The original unmodified sslc source is over here: <a href="http://www.teamx.ru/eng/files/srcs/index.shtml">http://www.teamx.ru/eng/files/srcs/index.shtml</a>.</p> <h2 id="command-line-options"> <a href="#command-line-options" class="anchor-heading" aria-labelledby="command-line-options"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Command line options </h2> <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>-q don't wait for input on error
|
||
-n no warnings
|
||
-b backward compatibility mode
|
||
-l no logo
|
||
-p preprocess source
|
||
-O optimize code (full, see optimization.txt)
|
||
-O<N> set specific level of optimization (0 - off, 1 - basic, 2 - full, 3 - experimental)
|
||
-d print debug messages
|
||
-D output an abstract syntax tree of the program
|
||
-o set output path (follows the input file name)
|
||
-s enable short-circuit evaluation for all AND, OR operators
|
||
-m<macro[=val]> define a macro named "macro" for conditional compilation
|
||
-I<path> specify an additional directory to search for include files
|
||
</code></pre></div></div> <p>The original command line option <code class="highlighter-rouge">-w</code> to turn on warnings no longer has an effect, since warnings are now on by default</p> <h2 id="additional-supported-syntax"> <a href="#additional-supported-syntax" class="anchor-heading" aria-labelledby="additional-supported-syntax"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Additional supported syntax </h2> <p>Syntax which requires sfall for compiled scripts to be interpreted, is marked by asterix (*).</p> <ul> <li> <p>Optional arguments in user-defined procedures. You can only use constants for default values. It basically puts those constants in place of omitted arguments.</p> <ul> <li>new: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>procedure test(variable x, variable y := 0, variable z := -1) begin
|
||
...
|
||
end
|
||
...
|
||
call test("value");
|
||
</code></pre></div> </div> </li> <li>old: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>procedure test(variable x, variable y, variable z) begin
|
||
...
|
||
end
|
||
...
|
||
call test("value", 0, -1);
|
||
</code></pre></div> </div> </li> </ul> </li> <li> <p>New logical operators <code class="highlighter-rouge">AndAlso</code>, <code class="highlighter-rouge">OrElse</code> for short-circuit evaluation of logical expressions. Using these operators allow the right part of logical expressions not to be evaluated (executed, computed) if the result is already known. This can improve the performance of running scripts.</p> <p>Example: <code class="highlighter-rouge">if (obj andAlso obj_pid(obj) == PID_STIMPAK) then ...</code></p> <p>If <code class="highlighter-rouge">obj</code> is <code class="highlighter-rouge">null</code>, the second condition will not be checked and your script won’t fail with “obj is null” error in debug.log</p> <p>This also has an effect that a value of last computed argument is returned as a result of whole expressions, instead of always 0 (<code class="highlighter-rouge">false</code>) or 1 (<code class="highlighter-rouge">true</code>):</p> <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>obj := false;
|
||
display_msg(obj orElse "something"); // will print "something"
|
||
</code></pre></div> </div> <p>You can also use the <code class="highlighter-rouge">-s</code> option to enable short-circuit evaluation for all the <code class="highlighter-rouge">AND</code>, <code class="highlighter-rouge">OR</code> operators in the script.</p> <p>NOTE: Be aware that it may break some old scripts because operators behavior is changed slightly.</p> </li> <li>Conditional expressions (Python-inspired), also known as ternary operator: <ul> <li>new: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>X := value1 if condition else value2
|
||
</code></pre></div> </div> </li> <li>old: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>if (condition) then
|
||
X := value1;
|
||
else
|
||
X := value2;
|
||
</code></pre></div> </div> </li> </ul> </li> <li>To assign values, you can use the alternative assignment operator from C/Java instead of Pascal syntax. <ul> <li>new: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>x = 5;
|
||
</code></pre></div> </div> </li> <li>old: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>x := 5;
|
||
</code></pre></div> </div> </li> </ul> </li> <li>Multiple variable declaration: Multiple variables can be declared on one line, seperated by commas. This is an alterative to the ugly begin/end block, or the bulky single variable per line style.</li> <li>new: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>variable a, b, c;
|
||
</code></pre></div> </div> </li> <li>old: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>variable begin a; b; c; end
|
||
</code></pre></div> </div> </li> <li>Variable initialization with expressions: You can now initialize local variables with complex expressions instead of constants. <ul> <li>new: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>variable tile := tile_num(dude_obj);
|
||
</code></pre></div> </div> </li> <li>old: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>variable tile;
|
||
tile := tile_num(dude_obj);
|
||
</code></pre></div> </div> <p>NOTE: if your expression starts with a constant (eg. <code class="highlighter-rouge">2+2</code>), enclose it in parentheses, otherwise compiler will be confused and give you errors.</p> </li> </ul> </li> <li>Hexadecimal numerical constants: Simply prefix a number with <code class="highlighter-rouge">0x</code> to create a hexadecimal. The numbers <code class="highlighter-rouge">0</code> to <code class="highlighter-rouge">9</code> and <code class="highlighter-rouge">a-f</code> are allowed in the number. The number may not have a decimal point. <ul> <li>new: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>a := 0x1000;
|
||
</code></pre></div> </div> </li> <li>old: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>a := 4096;
|
||
</code></pre></div> </div> </li> </ul> </li> <li>Increment/decrement operators: <code class="highlighter-rouge">++</code> and <code class="highlighter-rouge">--</code> can be used as shorthand for <code class="highlighter-rouge">+=1</code> and <code class="highlighter-rouge">-=1</code> respectively. They are mearly a syntactic shorthand to improve readability, and so their use is only allowed where <code class="highlighter-rouge">+=1</code> would normally be allowed. <ul> <li>new: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>a++;
|
||
</code></pre></div> </div> </li> <li>old: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>a += 1;
|
||
</code></pre></div> </div> </li> </ul> </li> <li><code class="highlighter-rouge">break</code> & <code class="highlighter-rouge">continue</code> statements: they work just like in most high-level languages. <code class="highlighter-rouge">break</code> jumps out of the loop. <code class="highlighter-rouge">continue</code> jumps right to the beginning of the next iteration (see <code class="highlighter-rouge">for</code> and <code class="highlighter-rouge">foreach</code> sections for additional details). <ul> <li>new: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>while (i < N) begin
|
||
// ...
|
||
if (/* some condition */) then break;
|
||
// ...
|
||
end
|
||
</code></pre></div> </div> </li> <li>old: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>while (i < N and not(breakFlag)) begin
|
||
// ...
|
||
if (/* condition */) then breakFlag := true;
|
||
// ...
|
||
end
|
||
</code></pre></div> </div> </li> <li>new: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>for (i := 0; i < N; i++) begin
|
||
// ...
|
||
if (/* condition */) then begin
|
||
// action
|
||
continue;
|
||
end
|
||
// else actions
|
||
end
|
||
</code></pre></div> </div> </li> <li>old: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>for (i := 0; i < N; i++) begin
|
||
// ...
|
||
if (/* condition */) then begin
|
||
// action
|
||
end else begin
|
||
// else actions
|
||
end
|
||
end
|
||
</code></pre></div> </div> </li> </ul> </li> <li><code class="highlighter-rouge">for</code> loops: Another piece of syntactic shorthand, to shorten <code class="highlighter-rouge">while</code> loops in many cases. Parentheses around the loop statements are recommended but not required (when not using parentheses, a semicolon is required after the 3rd loop statement). <ul> <li>new: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>for (i := 0; i < 5; i++) begin
|
||
display_msg("i = "+i);
|
||
end
|
||
</code></pre></div> </div> </li> <li>old: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>i := 0;
|
||
while (i < 5) do begin
|
||
display_msg("i = "+i);
|
||
i++;
|
||
end
|
||
</code></pre></div> </div> <p>NOTE: <code class="highlighter-rouge">continue</code> statement in a <code class="highlighter-rouge">for</code> loop will recognize increment statement (third statement in parentheses) and will execute it before jumping back to the beginning of loop. This way you will not get an endless loop.</p> </li> </ul> </li> <li><code class="highlighter-rouge">switch</code> statements: A shorthand way of writing big <code class="highlighter-rouge">if then else if...</code> blocks <ul> <li>new: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>switch get_attack_type begin
|
||
case ATKTYPE_PUNCH: display_msg("punch");
|
||
case ATKTYPE_KICK: display_msg("kick");
|
||
default: display_msg("something else");
|
||
end
|
||
</code></pre></div> </div> </li> <li>old: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>variable tmp;
|
||
tmp := get_attack_type;
|
||
if tmp == ATKTYPE_PUNCH then begin
|
||
display_msg("punch");
|
||
end else if tmp == ATKTYPE_KICK then begin
|
||
display_msg("kick");
|
||
end else begin
|
||
display_msg("something else");
|
||
end
|
||
</code></pre></div> </div> </li> </ul> </li> <li>empty statements in blocks are allowed: This is just a convenience to save scripters a bit of memory. Some of the macros in the fallout headers include their own semicolons while others do not. With the original compiler you had to remember which was which, and if you got it wrong the script would not compile. Now it’s always safe to include your own semicolon, even if the macro already had its own. For example, this would not compile with the original sslc, but will with the sfall edition: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>#define my_macro diplay_msg("foo");
|
||
|
||
procedure start begin
|
||
my_macro;
|
||
end
|
||
</code></pre></div> </div> </li> <li>Procedure stringify operator <code class="highlighter-rouge">@</code>: designed to make callback-procedures a better option and allow for basic functional programming. Basically it replaces procedure names preceeded by <code class="highlighter-rouge">@</code> by a string constant. Not many people know that since vanilla Fallout you can call procedures by “calling a variable” containing it’s name as a string value. There was a couple of problems using this: <ul> <li>optimizer wasn’t aware that you are referencing a procedure, and could remove it, if you don’t call it explicitly (can be solved by adding making procedure “critical”)</li> <li>you couldn’t see all references of a procedure from a Script Editor</li> <li>it was completely not obvious that you could do such a thing, it was a confusing syntax</li> <li>old: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>callbackVar := "Node000";
|
||
callbackVar();
|
||
</code></pre></div> </div> </li> <li>new: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>callbackVar := @Node000;
|
||
callbackVar();
|
||
</code></pre></div> </div> </li> </ul> </li> <li>*arrays: In vanilla fallout arrays had to be constructed by reserving a block of global/map variables. Since sfall 2.7, specific array targeted functions have been available, but they are fairly messy and long winded to use. The compiler provides additional syntactic shorthand for accessing and setting array variables, as well as for array creation. When declaring an array variable, put a constant integer in []’s to give the number of elements in the array. (before sfall 3.4 you had to specify size in bytes for array elements, now it’s not required, see “arrays.txt” for more information) <ul> <li>new: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>procedure bingle begin
|
||
variable a[2];
|
||
a[0] := 5;
|
||
a[a[0] - 4] := a[0] + 4;
|
||
display_msg("a[0]=" + a[0] + ", a[1]=" + a[1]);
|
||
end
|
||
</code></pre></div> </div> </li> <li>old: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>procedure bingle begin
|
||
variable a;
|
||
a := temp_array(2, 4);
|
||
set_array(a, 0, 5);
|
||
set_array(a, get_array(a, 0) - 4, get_array(a, 0) + 4);
|
||
display_msg("a[0]=" + get_array(a, 0) + ", a[1]=" + get_array(a, 1));
|
||
end
|
||
</code></pre></div> </div> </li> </ul> </li> <li>*array expressions: sometimes you need to construct an array of elements and you will probably want to do it in just one expression. This is now possible: <ul> <li>new: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>list := ["A", "B", "C", "D"];
|
||
</code></pre></div> </div> </li> <li>old: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>list := temp_array(4, 2);
|
||
list[0] := "A";
|
||
list[1] := "B";
|
||
list[2] := "C";
|
||
list[3] := "D";
|
||
</code></pre></div> </div> <p>Syntax specific for associative arrays is also available. (see “arrays.txt” for full introduction to this type of arrays).</p> </li> </ul> </li> <li>*map array expressions: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>map := {5: "five", 10: "ten", 15: "fifteen", 20: "twelve"};
|
||
</code></pre></div> </div> </li> <li> <ul> <li>“dot” syntax to access elements of associative arrays. “dot” syntax allows to work with arrays like objects: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>trap.radius := 3;
|
||
trap.tile := tile_num(dude_obj);
|
||
</code></pre></div> </div> <p>You can chain dot and bracket syntax to access elements of multi-dimensional arrays:</p> <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>collectionList[5].objectList[5].name += " foo";
|
||
</code></pre></div> </div> </li> </ul> <p>NOTE: when using incremental operators like <code class="highlighter-rouge">+=</code>, <code class="highlighter-rouge">*=</code>, <code class="highlighter-rouge">++</code>, <code class="highlighter-rouge">--</code> compiler will use additional temp variable to get an array at penultimate level in order to avoid making the same chain of “get_array” calls twice.</p> </li> <li> <ul> <li><code class="highlighter-rouge">foreach</code> loops: A shorthand method of looping over all elements in an array. Syntax is <code class="highlighter-rouge">foreach (<symbol> in <expression>)</code>.</li> <li>new: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>procedure bingle begin
|
||
variable critter;
|
||
foreach (critter in list_as_array(LIST_CRITTERS)) begin
|
||
display_msg(""+critter);
|
||
end
|
||
end
|
||
</code></pre></div> </div> </li> <li>old: <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>procedure bingle begin
|
||
variable begin critter; array; len; count; end
|
||
array := list_as_array(LIST_CRITTERS);
|
||
len := len_array(array);
|
||
count := 0;
|
||
while count < len do begin
|
||
critter := array[count];
|
||
display_msg("" + critter);
|
||
end
|
||
end
|
||
</code></pre></div> </div> <p>If you want an index array element (or key for “maps”) at each iteration, use syntax: <code class="highlighter-rouge">foreach (<symbol>: <symbol> in <expression>)</code></p> <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>foreach (pid: price in itemPriceMap) begin
|
||
if (itemPid == pid) then
|
||
itemPrice := price;
|
||
end
|
||
</code></pre></div> </div> <p>If you want to add additional condition for continuing the loop, use syntax: <code class="highlighter-rouge">foreach (<symbol> in <expression> while <expression>)</code>. In this case loop will iterate over elements of an array until last element or until “while” expression is true (whatever comes first).</p> </li> </ul> <p>NOTE: just like <code class="highlighter-rouge">for</code> loop, “continue” statement will respect increments of a hidden counter variable, so you can safely use it inside <code class="highlighter-rouge">foreach</code>.</p> </li> </ul> <h2 id="int2ssl-note"> <a href="#int2ssl-note" class="anchor-heading" aria-labelledby="int2ssl-note"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> int2ssl note </h2> <p>int2ssl by Anchorite (TeamX) is included in sfall modderspack package. It was updated to support all additional opcodes of sfall, along with some syntax features. You can use it to decompile any sfall or non-sfall script.</p> <h2 id="fixes"> <a href="#fixes" class="anchor-heading" aria-labelledby="fixes"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Fixes </h2> <ul> <li><code class="highlighter-rouge">playmoviealpharect</code> was using the token for <code class="highlighter-rouge">playmoviealpha</code>, breaking both functions in the process.</li> <li><code class="highlighter-rouge">addbuttonflag</code> had an entry in the token table, and could be parsed, but was missing an entry in the emit list. This resulted in the compiler accepting it as a valid function, but not outputting any code for it into the compiled script.</li> <li>The function <code class="highlighter-rouge">tokenize</code> was missing an entry in the token table, and so would not be recognised by the compiler.</li> <li>Fixed the check for the <code class="highlighter-rouge">call "foo"</code> syntax so that non-string constants will no longer be accepted.</li> </ul> <h2 id="backward-compatibility"> <a href="#backward-compatibility" class="anchor-heading" aria-labelledby="backward-compatibility"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Backward compatibility </h2> <p>There are several changes in this version of sslc which may result in problems for previously working scripts. A new command line option <code class="highlighter-rouge">-b</code> is available, which will turn off all new fixes and features which have the possibility of causing a previously compiling script to change its behaviour. (And only those features; anything which would not compile under the old sslc is not affected.) This includes the following:</p> <ul> <li>Since <code class="highlighter-rouge">for</code>, <code class="highlighter-rouge">foreach</code>, <code class="highlighter-rouge">break</code>, <code class="highlighter-rouge">continue</code>, <code class="highlighter-rouge">in</code> and <code class="highlighter-rouge">tokenize</code> are now hardcoded names, existing scripts that use any of them as a variable or procedure name will no longer compile.</li> <li>Missing a semicolon after a variable declaration is now a hard error. (Originally sslc would check for the semicolon, but would not complain if it was missing.)</li> <li>The function <code class="highlighter-rouge">addbuttonflag</code> used to be recognised by the compiler, but would not emit any code into the int file.</li> <li>The function <code class="highlighter-rouge">playmoviealpharect</code> compiled as <code class="highlighter-rouge">playmoviealpha</code>.</li> </ul> </div> </div> <div class="search-overlay"></div> </div> </body> </html>
|