Login

Fancade Wiki

add a technical detail

... ...
@@ -19,23 +19,25 @@ Fancade has a hard script limit. After a certain number of scripts in the editor
19 19
* As you can see in the first picture the script consumes about 5% script limit. The second picture then shows that 2 instances of the same script still consumes about 5% of the script limit rather than 10% of it.
20 20
21 21
## Technical Details
22
22 23
The introduction of advanced inspect allowed for more robust testing, which helped in discovering some key insights regarding the elusive script limit. Among those, Andrew Clark's discoveries were crucial for our current understanding of it.
23 24
24 25
### Current Understanding
25 26
26
The limit is 4096. The value doesn't matter as much as how you decide to use them. There are three things that consume the script limit.
27
The limit is 4096. The value doesn't matter as much as how you decide to use them. There are four things that consume the script limit:
27 28
28
* [Script Blocks](https://www.fancade.com/wiki/Script/Script%20Limit.md#script-blocks)
29
* [Wire Splits](https://www.fancade.com/wiki/Script/Script%20Limit.md#wire-splits)
30
* [Pointer Dereferencing](https://www.fancade.com/wiki/Script/Script%20Limit.md#pointer-dereferencing)
29
* [[Script blocks|#Script Blocks]]
30
* [[Wire splits|#Wire Splits]]
31
* [[Pointer dereferencing|#Pointer Dereferencing]]
32
* [[Inside custom scripts|#Inside Custom Scripts]]
31 33
32
#### Script Blocks
34
#### Script blocks
33 35
34 36
Every script block counts as 1 script towards the total limit. It does not matter which script block it is, as long as it is an inbuilt script block, it adds 1 to the counter. The attached image has 4 script blocks, thus the script consumption is 4/4096 or roughly 0.1%.
35 37
36 38
[[/uploads/Screenshot_20210618-113130_Fancade.png]]
37 39
38
#### Wire Splits
40
#### Wire splits
39 41
40 42
A wire split counts as 1 script towards the limit. Thus the script in image A adds 4 scripts (3 script blocks + 1 wire split) to the counter.
41 43
... ...
@@ -50,7 +52,7 @@ The same applies in case of joining. The script in image C counts as 4 scripts,
50 52
![C - Wire Splitting](https://cdn.discordapp.com/attachments/852037487987392529/855423621433393172/Screenshot_20210618-113611_Fancade.png)
51 53
![D - Wire Splitting](https://cdn.discordapp.com/attachments/852037487987392529/855423621639569408/Screenshot_20210618-113747_Fancade.png)
52 54
53
#### Pointer Dereferencing
55
#### Pointer dereferencing
54 56
55 57
This section will be easier to understand if you are somewhat familiar with the concept of pointers. If you are not, you can think of them as an address. Specifically, a memory address, that points to a variable.
56 58
When a pointer is dereferenced, i.e. converted to value, it counts as 1 script. In image E, the Get Variable block outputs a pointer, which is then dereferenced to a value for the Negate block. Thus the script adds 3 scripts (2 script blocks + 1 pointer dereference) to the counter.
... ...
@@ -68,6 +70,18 @@ Known script blocks that accept a pointer as input are the Variable inputs of th
68 70
69 71
![Pointer in](https://media.discordapp.net/attachments/852037487987392529/855655587852451840/Screenshot_20210619-091908_Fancade.png)
70 72
73
#### Inside custom scripts
74
75
When a custom script block has built-in script blocks inside it, the first instance of that block counts the number of script blocks in it + 1. Further instances only consume 1 additional script limit. For example, this would count as 5 scripts (4 script blocks inside + 1 instance). Adding two more would count as 7 scripts (4 script blocks on the first instance + 3 instances).
76
77
[[/uploads/Screenshot_2023-04-09_14-55-27.png]]
78
79
[[/uploads/Screenshot_2023-04-09_14-56-30.png]]
80
81
For every input and output port given to the script block, the first instance counts it as 1 more script. Rules for wire splitting still apply to these. To give an example, take a look at this vector interpolation found in Fanscripts by [[Sounak9434|the-questers#sounak9434]]. This consumes 9 script blocks in total (3 script blocks inside + 4 IO ports + 1 wire split at top input port + 1 instance of the custom block):
82
83
[[/uploads/Screenshot_2023-04-09_14-58-42.png]]
84
71 85
## Tips
72 86
73 87
Here are some general tips to conserve the limit as much as possible:
... ...
@@ -75,4 +89,5 @@ Here are some general tips to conserve the limit as much as possible:
75 89
* Use wire splits whenever possible.
76 90
* Do not use variables unless absolutely needed.
77 91
* If a pointer is dereferenced at least three times, dereference it before the split.
92
* You may find it useful to pack scripts that repeat throughout the script into a script.
78 93
* Comments do not count towards any limits. Use them as much as possible.
Fancade Wiki