This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
4rpl:commands:specialsyntax [2021/04/05 19:10] – typo Karsten75 | 4rpl:commands:specialsyntax [2025/02/14 14:57] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 3: | Line 3: | ||
====== Special Variable Syntax ====== | ====== Special Variable Syntax ====== | ||
- | 4rpl supports special syntax for referencing global variables, vectors, lists, and tables. | + | 4RPL supports special syntax for referencing global variables, vectors, lists, and tables. |
---- | ---- | ||
Line 10: | Line 10: | ||
=== Description === | === Description === | ||
- | All of the variable commands can also be used followed by a * symbol in order to access __global__ variables | + | All of the [[4rpl: |
instead. Global variables do not belong to one single script, reading or writing to a global variable will | instead. Global variables do not belong to one single script, reading or writing to a global variable will | ||
modify the same exact value from any script. | modify the same exact value from any script. | ||
+ | |||
+ | Global variables **belong to a map** and can be accessed from within different CPACK' | ||
Global variables may have the same names as local variables, there is no interference between them. | Global variables may have the same names as local variables, there is no interference between them. | ||
Line 36: | Line 38: | ||
< | < | ||
+ | ---- | ||
===== Vectors ===== | ===== Vectors ===== | ||
=== Description === | === Description === | ||
Vectors contain up to 4 fields. | Vectors contain up to 4 fields. | ||
- | These fields can be referenced with a suffix that infers | + | These fields can be referenced with a suffix that implies |
- | * .x .y .z .w (coordiaate) | + | * .x .y .z .w (coordinates) |
- | * .r .g .b .a (color) | + | * .r .g .b .a (color) |
* .0 .1 .2 .3 (index) | * .0 .1 .2 .3 (index) | ||
Line 58: | Line 61: | ||
V3(255 0 0) ->red | V3(255 0 0) ->red | ||
</ | </ | ||
+ | |||
+ | A brief note on color values: | ||
+ | |||
+ | Color is represented by 4 values, each of the first 3 the intensity of one of the primary colors (Red, Green and Blue) and the 4th value the Alpha channel. Alpha values indicate transparency or opacity. All of these values are floating-point values ranging from 0 to 1, with higher values truncated to 1. | ||
+ | |||
+ | Example: | ||
+ | ? | ||
+ | : is white. | ||
+ | ? V4(1 0 0 1) | ||
+ | : is red. | ||
+ | ? V4(0 1 0 1) | ||
+ | : is green. | ||
+ | ? V4(0 0 1 1) | ||
+ | : is blue. | ||
+ | | ||
+ | Combining different values result in any other intermediate color. | ||
+ | |||
+ | Changing the 4th field to a lesser value would increase the transparency, | ||
---- | ---- | ||
< | < | ||
+ | ---- | ||
===== Lists ===== | ===== Lists ===== | ||
+ | |||
+ | < | ||
Lists are collections of data. They are similar to arrays but they do not have a fixed length. | Lists are collections of data. They are similar to arrays but they do not have a fixed length. | ||
Line 79: | Line 102: | ||
effectively setting element number " | effectively setting element number " | ||
If **variable** is not a list, a warning will be printed to the console. | If **variable** is not a list, a warning will be printed to the console. | ||
+ | |||
+ | See also: [[4rpl: | ||
=== Example === | === Example === | ||
Line 88: | Line 113: | ||
</ | </ | ||
- | ---- | + | |
< | < | ||
+ | ---- | ||
===== Tables ===== | ===== Tables ===== | ||
+ | |||
+ | < | ||
Tables are collection of named data. They are sometimes called dictionaries in other languages. | Tables are collection of named data. They are sometimes called dictionaries in other languages. | ||
Line 119: | Line 147: | ||
</ | </ | ||
- | It is possible to iterate over the elements in a table by coercing the table into a list. The following shows two equivalent methods to extract data from a table. | + | ==== Coerce table to list ==== |
+ | It is possible to iterate over the elements in a table by coercing the table into a list. The following shows two equivalent methods to extract data from a table. | ||
=== Example === | === Example === | ||
Line 130: | Line 159: | ||
Table -> | Table -> | ||
- | # method | + | # method |
Do (GetTablecount(< | Do (GetTablecount(< | ||
Line 138: | Line 167: | ||
Loop | Loop | ||
- | # method | + | # method |
GetTableKeys(< | GetTableKeys(< |