Login

Fancade Wiki

consistency

... ...
@@ -2,60 +2,75 @@ Fancade has a hard script limit. After a certain number of scripts in the editor
2 2
3 3
[[/uploads/updated_Too_many_scripts.png]]
4 4
5
# History
5
## History
6
6 7
### Advanced Inspect
8
7 9
- Script limit has been a mystery for a long time. An elusive upper limit that creators randomly hit, and are forced to scrap their ambitious project. Fancade 1.2 significantly improved the scenario by introducing Advanced Inspect blocks. Those blocks, when enabled, showed how much of the script limit has the game consumed already.
10
8 11
[[/uploads/Screenshot_20210609-094759_Fancade.png]]
9 12
10 13
### Optimized Scripting
14
11 15
- For the most ambitious of projects script limit has proven itself to be the greatest wall, leaving the very same projects abandoned, scrapped or just barely hanging on the limit unable to get new game features and mechanics. In Fancade 1.11.3 however, "Optimized Scripting" feature has been introduced, significantly reducing script limit usage and effectively giving more freedom in coding complex games. With this feature only the first instance of the custom block put into the level counts every script inside it towards the script limit, the additional instances of the block then contributes only 1 point each to the script limit.
12 16
13 17
[[/uploads/optimized-scripting-demonstration.jpg]]
14
* 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.
15 18
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.
16 20
17
# Technical Details
21
## Technical Details
18 22
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.
19 23
20
## Current Understanding
24
### Current Understanding
25
21 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.
22 27
23 28
* [Script Blocks](https://www.fancade.com/wiki/Script/Script%20Limit.md#script-blocks)
24 29
* [Wire Splits](https://www.fancade.com/wiki/Script/Script%20Limit.md#wire-splits)
25 30
* [Pointer Dereferencing](https://www.fancade.com/wiki/Script/Script%20Limit.md#pointer-dereferencing)
26 31
27
### Script Blocks
32
#### Script Blocks
33
28 34
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%.
29 35
30 36
[[/uploads/Screenshot_20210618-113130_Fancade.png]]
31 37
32
### Wire Splits
38
#### Wire Splits
39
33 40
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
34 42
![A - Wire Splitting](https://cdn.discordapp.com/attachments/852037487987392529/855423620692443156/Screenshot_20210618-113313_Fancade.png)
35 43
36 44
But wire splits are defined as "n to 1" and "1 to n". This basically means, no matter how large the split is, it will add only 1 script to the counter. The script in image B adds 10 scripts (9 script blocks + 1 wire split) to the counter.
45
37 46
![B - Wire Splitting](https://cdn.discordapp.com/attachments/852037487987392529/855423621173739530/Screenshot_20210618-113424_Fancade.png)
38 47
39 48
The same applies in case of joining. The script in image C counts as 4 scripts, whereas the script in image D counts as 10 scripts.
49
40 50
![C - Wire Splitting](https://cdn.discordapp.com/attachments/852037487987392529/855423621433393172/Screenshot_20210618-113611_Fancade.png)
41 51
![D - Wire Splitting](https://cdn.discordapp.com/attachments/852037487987392529/855423621639569408/Screenshot_20210618-113747_Fancade.png)
42 52
43
### Pointer Dereferencing
53
#### Pointer Dereferencing
54
44 55
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.
45 56
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.
57
46 58
![E - Pointer Dereferencing](https://cdn.discordapp.com/attachments/852037487987392529/855423621933301760/Screenshot_20210618-113952_Fancade.png)
47 59
48 60
This behaviour, when combined with wire splitting, results in a peculiar quirk where adding another script block can actually consume less script limit than without that block. In the following picture, case 1 adds 8 scripts (4 script blocks + 1 wire split + 3 pointer dereferences) to the counter. Almost half of them are just from dereferencing. To avoid that, in case 2 another script block is added to dereference the pointer before the split. Thus case 2 only adds 7 scripts (5 script blocks + 1 wire split + 1 pointer dereference) to the counter.
49 61
![Pointer Dereferencing](https://cdn.discordapp.com/attachments/852037487987392529/855440742431064094/Screenshot_20210618-130458_Fancade.png)
50 62
51 63
Known script blocks that output a pointer are all the Get Variable and List Element blocks.
64
52 65
![Pointer out](https://cdn.discordapp.com/attachments/852037487987392529/855444701309829170/Screenshot_20210618-192013_Fancade.png)
53 66
54 67
Known script blocks that accept a pointer as input are the Variable inputs of the List Element blocks, the Variable input of the Menu Item block and, increment and decrement block.
68
55 69
![Pointer in](https://media.discordapp.net/attachments/852037487987392529/855655587852451840/Screenshot_20210619-091908_Fancade.png)
56 70
57 71
## Tips
58
Here are some general tips to conserve the limit as much as possible.
72
73
Here are some general tips to conserve the limit as much as possible:
59 74
60 75
* Use wire splits whenever possible.
61 76
* Do not use variables unless absolutely needed.
Fancade Wiki