Alright, You decided to embark on the adventure of learning how to use scaffolding!
I couldn't be more sorry for You!
I recommend opening the list of opcodes, You'll need it for reference.
In this tutorial I'll analyse and explain a couple of programs written in scaf.
Before that, let's lay down some fundamentals first:
- The Read Head (blue) and the Write Head (red) both initially start at position (0, 0).
- The Read Head advances automatically until it reaches an illegal position (outside the buffer).
- Current Head points to the Write Head by default.
- If You instruct the Write Head to go out of bounds, it will expand the buffer, so that it's position is always legal.
9y9+9xY.O. .D.U.D.E.
This short script does two things:
-
Positions the Write Head on the 9th line and 18 column:
- Loads
9
into the Write Head's mod. - Executes opcode
y
. - Loads
9
, then adds another9
to mod. - Executes opcode
x
.
- Loads
-
Loads 7 chars and prints them sequentially until it reaches the end of the buffer:
- Loads a char into the Write Head's mod.
- Executes opcode
.
. - Repeats that 7 times.
Output of franeklubi/scaf-visualizer:
a.b.07<
This bane of a script will never terminate.
-
First loop:
- Starts with loading and printing first
a
, thenb
. - Loads
0
(which is totally useless), then7
. - Executes opcode
<
whereby the whole buffer shifts.
- Starts with loading and printing first
-
Subsequent loops:
- Loads
b
, then againb
and prints it. The doubleb
is a prominent example of the script overwriting the previous code. - Executes opcode
<
after loading in0
, then7
.
- Loads
Output of franeklubi/scaf-visualizer: