The Great Spell

The Great Spell is an esolang in which you must create a powerful magic spell to create the effect you desire. To do this, you can create smaller spells with simpler effects to build up to your Great Spell.
Nodes of Energy:
In the Great Spell, magical energy moves around the spell in packets known as nodes. Each node can store any amount of energy. Energy is quantified into points. A node can not store a fraction of a point; however, nodes can be empty (storing 0 energy) or even vacuous (storing a negative amount of energy).
Realm Runes:
The Realm Runes create a connection to one of the many magical realms. Each realm can provide energy to power your spells. When called upon for energy, each will provide a node with a specific amount of energy, as follows:
* * (Light): The realm of Light provides a node with 2 points of energy.
* # (Shadow): The realm of Shadow provides a node with 1 point of energy.
* @ (Abyss): The realm of the Abyss provides a node with 0 points of energy.
If a node is placed into a Realm, it is rent asunder and lost forever.
Domain Runes:
The Domain Runes forge a connection with the magical elements of this realm. The domains can't create nodes, but they can store them to be retrieved later. Each Domain can store a single node; if given a second while they have one, the first is destroyed. The Realms and their Runes are as follows: Fire (%), Water ($), Air (!) and Earth (~). Attempting to take a node from a domain that doesn't have one causes an arcane explosion. When a spell starts, its Domains are empty.
Thread Runes:
The Thread Runes track the movement of energy along your spell. The thread can't create nodes, but it can store many nodes. The nodes in the thread are in a line from left to right. New nodes can either be added to the left or right and nodes can be taken from either end.
* < (Left): Either take from the left or place at the left, as appropriate.
* > (Right): Either take from the right or place at the right, as appropriate.
If a node is taken from the Thread when it is empty, an arcane explosion occurs. When the spell starts, its Thread is empty.
Command Runes:
The Command Runes form the core of your spells. Each describes a specific action to take upon one or more nodes of energy.
X and Y must be replaced with a source of nodes; one node will be taken from there. Nodes taken are erased.
R and A must be replaced with a place to put nodes; the resultant nodes will be placed there.
* XY+R (Plus): Creates a node at R with energy equal to X plus Y.
* XY-R (Minus): Creates a node at R with energy equal to X minus Y.
* X^R (Move): Create a node at R with energy equal to X.
* X&RA (Clone): Create a node at R and A with energy equal to X.
* XY= (If): Unless X and Y have the same energy, skip the next command.
Reagent Runes:
Reagent Runes connects the spell to physical objects, allowing the spell to have effects on the outside world. Nodes placed in reagents are destroyed. Not every mage has every reagent, but every mage must have a crystal ball.
* ? (Crystal Ball):
If a node is taken from the Crystal Ball, it will provide a node with an energy level chosen by the mage at that time, allowing the mage to direct the flow of the spell while it is running.
If a node is placed in the Crystal Ball, it will inform the mage as to the energy inside.
* " (Phoenix Quill):
If a node is placed in the Phoenix Quill, it write the energy level of that node at the end of the scroll the spell is written on. Each new number is written on its own line, after the final spell.
If a node is taken from the Phoenix Quill, it will erase the last line of the spell scroll and provide a node with that energy level. If the last line isn't a number, it instead erases nothing and provides a node with 0 energy.
Spell Runes:
The Spell Runes merge other runes into completed spells.
In each Spell Rune, "name" can be any set of letters. Each spell must have a unique name; if two spells have the same name, then casting either causes an arcane explosion.
* [name|%$|!]: Create a new basic spell (header).
* []: Mark the end of the spell being created.
* {name|NM|Q}: Cast a basic spell.
Each separate spell has its own set of Domain connections; however, they all share a common Thread. When a spell starts, it takes in the two nodes at N and M (from the current spell) and moves them to the new spell's Fire and Water domains. When the spell ends, it creates a new node at Q (in the original spell) equal to the node at the finished spell's Air domain; the original spell then continues from where it left off.
* (name|%$|!|~): Create a new recursive spell (header).
* (): Mark the end of the recursive spell being created.
* {name|NM|Q|L}: Cast a recursive spell.
Recursive spells take in an extra node from L (in the current spell). If that node is 0 or less, the spell fails and isn't cast; move the L node directly to Q.
Otherwise, this node is stored at the new spell's Earth Domain. When a recursive spell would end, it checks the energy in its Earth Domain. Unless that value is 0 or less, the spell starts over; if there is no node there, it is treated as 0. Only when the spell truly ends does it return its Air domain to Q.
Scribing Spells:
To write a spell, start by putting the spell's header on its own line.
Each command rune that makes up the spell goes on the lines after that.
Starting to write a new spell before you finish the previous one will cause an arcane explosion.
Casting Spells:
When you are ready to invoke your magic, cast the 'final' spell on your scroll.
The final spell must not be Recursive and is given nodes with 0 energy for N and M.
The other spells you wrote will only be cast if another spell casts them for you.
Runes that aren't enclosed within a spell are unstable and will cause an arcane explosion.
When the final spell ends, your Great Spell is over.
Example Spell:
This Grand Spell meditates on the central nature of truth.
 (loop|%$|!|~)
 #^?
 ()
 [truth|%$|!]
 ?^!
 {loop|@@|!|!}
 @^?
 []
Category:LanguagesCategory:2017Category:Deque-basedCategory:UnimplementedCategory:Thematic