The Neconyan handbook
Your guides Miso, Taro & Nori
Choose each guide's gender to change their artwork and pronouns. Your choices stay in this browser, separately from the app.
Variables¶
A variable is a saved value with a name, such as location containing Library.
Choose a store¶
| Store | Where the value belongs | Write and read |
|---|---|---|
| Local | This Roleplay chat | setvar and getvar |
| Global | Your account, across chats | setglobalvar and getglobalvar |
| Macro Enhanced chat variables | A separate store in this chat | setchatvar and getchatvar |
The two chat-only stores are separate. A value written with setchatvar will not appear through getvar. If a value has to survive a Deep Swipe or a reply with a selected Notebook context, use the local store: Macro Enhanced chat variables don't work in prompts built on the server.
The setter produces no text. The second line becomes The scene takes place in Library.
Writes can run more than once¶
A prompt may be evaluated during preview, preparation or a retry. An increment inside it can therefore run more than once for a single visible reply. Use an explicit action to update a story counter when exact timing matters.
In Roleplay prompts¶
Ordinary Roleplay replies build their prompts in the browser, where every store works. A few kinds of reply build theirs on the server instead: Conversation replies, Deep Swipe replacements, protected Guided corrections and replies with a selected Notebook context. These rules apply to those.
On the server, local variable writes made while preparing the prompt are saved together with the accepted reply. A failed request doesn't save them, and recovering a reply that already finished doesn't repeat them.
- Local variables can be read and written.
- Global variables can be read. Writing one stops the reply, because it can't be saved together with a chat reply. Use a local variable instead.
- Lorebook scanning can read variables but not write them. Put the write in a preset prompt or a message, not in a lorebook entry or its keys.
- The Macro Enhanced chat-variable macros, such as
setchatvarandgetchatvar, are browser-only and stop a server-built reply. See Macro Enhanced in Roleplay prompts.
Short spelling for ordinary variables¶
With newer macro support enabled, a dot reads a local variable and a dollar sign reads a global variable:
Use these prefixes for the operations below. Replace score with your variable name.
| Example | Meaning | Output |
|---|---|---|
{{.score = 3}} |
Save 3 | Nothing |
{{.score += 2}} |
Add 2, or append text for text values | Nothing |
{{.score -= 1}} |
Subtract a number | Nothing |
{{.score++}} |
Add 1 | New value |
{{.score--}} |
Subtract 1 | New value |
{{.score ?? 5}} |
Use 5 only if the variable is missing | Existing value or 5 |
{{.score ??= 5}} |
Save 5 only if missing | Existing value or 5 |
{{.score == 3}} |
Compare as text | true or false |
{{.score != 3}} |
Check different text | true or false |
{{.score > 3}} |
Compare numbers | true or false |
{{.score >= 3}} |
At least 3 | true or false |
{{.score < 3}} |
Below 3 | true or false |
{{.score <= 3}} |
At most 3 | true or false |
The fallback operators below also replace values that count as false, including 0. Their double pipes are valid within variable shorthand:
The first reads a fallback without saving it. The second saves the fallback when needed. Use ?? or ??= when a saved zero must be kept.
Named macros¶
The ordinary local and global macros are core features. The six names containing chatvar or ChatVar belong to Macro Enhanced. In slash-command scripts, use Macro Enhanced’s /me-chatvar commands to work with its separate store; similarly named built-in slash commands can use the ordinary store.
addchatvar¶
Adds to a chat variable, creating it at 0 when it does not exist yet. Adds numerically when both sides are numbers, otherwise appends as text. Writes nothing to the prompt.
Arguments and other names
- name: The chat variable to add to.
- value: The amount to add (or text to append).
- Other accepted names:
me-addchatvar.
addglobalvar¶
Adds a value to an existing global variable (numeric or string append). If the variable does not exist, it will be created.
Arguments and other names
- name: The name of the global variable to add to.
- value: The value to add to the global variable.
More examples:
addvar¶
Adds a value to an existing local variable (numeric or string append). If the variable does not exist, it will be created.
Arguments and other names
- name: The name of the local variable to add to.
- value: The value to add to the local variable.
More examples:
decglobalvar¶
Decrements a global variable by 1 and returns the new value. If the variable does not exist, it will be created.
Arguments and other names
- name: The name of the global variable to decrement.
More examples:
decvar¶
Decrements a local variable by 1 and returns the new value. If the variable does not exist, it will be created.
Arguments and other names
- name: The name of the local variable to decrement.
More examples:
deletechatvar¶
Removes a chat variable from this chat. Writes nothing to the prompt.
Arguments and other names
- name: The chat variable to remove.
- Other accepted names:
flushchatvar,me-deletechatvar.
deleteglobalvar¶
Deletes a global variable.
Arguments and other names
- name: The name of the global variable to delete.
- Other accepted names:
flushglobalvar.
More examples:
deletevar¶
Deletes a local variable.
Arguments and other names
- name: The name of the local variable to delete.
- Other accepted names:
flushvar.
More examples:
foreachChatVar¶
Repeats a block once per chat variable whose name starts with the prefix, in name order. Use it as a block with a matching {{/foreachChatVar}}.
For variables supply_food=3 and supply_water=2, the block lists food: 3 and water: 2 in name order. The loop names exist while that item is being processed.
Arguments and other names
- prefix: Only chat variables whose name starts with this are visited.
- alias: Name for the loop variables:
{{.alias}}is the name with the prefix removed,{{.alias_key}}the full name,{{.alias_value}}the value. - content: The block to repeat, between the opening tag and
{{/foreachChatVar}}. - Other accepted names:
me-foreachChatVar.
getchatvar¶
Reads a chat variable. Returns the fallback (or nothing) when it has never been set.
A fallback is returned when the variable is missing. Reading it does not save that fallback.
Arguments and other names
- name: The chat variable to read.
- fallback: Optional. Returned when the variable is not set. Default: empty text.
- Other accepted names:
me-getchatvar.
More examples:
getglobalvar¶
Gets the value of a global variable.
Arguments and other names
- name: The name of the global variable to get.
More examples:
getvar¶
Gets the value of a local variable.
Arguments and other names
- name: The name of the local variable to get.
More examples:
haschatvar¶
True when the chat variable has been set in this chat. Composes with {{if}}.
Arguments and other names
- name: The chat variable to look for.
- Other accepted names:
chatvarexists,me-haschatvar.
hasglobalvar¶
Checks if a global variable exists.
Arguments and other names
- name: The name of the global variable to check.
- Other accepted names:
globalvarexists.
More examples:
hasvar¶
Checks if a local variable exists.
Arguments and other names
- name: The name of the local variable to check.
- Other accepted names:
varexists.
More examples:
incglobalvar¶
Increments a global variable by 1 and returns the new value. If the variable does not exist, it will be created.
Arguments and other names
- name: The name of the global variable to increment.
More examples:
incvar¶
Increments a local variable by 1 and returns the new value. If the variable does not exist, it will be created.
Arguments and other names
- name: The name of the local variable to increment.
More examples:
setchatvar¶
Saves a value in Macro Enhanced’s chat-only variable store. Produces no prompt text. This store is separate from the ordinary local variables.
Arguments and other names
- name: The chat variable to write.
- value: The value to store.
- Other accepted names:
me-setchatvar.
setglobalvar¶
Sets a global variable to the given value.
Arguments and other names
- name: The name of the global variable to set.
- value: The value to set the global variable to.
More examples:
setvar¶
Sets a local variable to the given value.