Vars sets variables which can later be referenced by split.
You can add a "vars" attribute to any event, to set variables when that event begins.
"text": {
"addTest": {
"parts": [{"text": "Talking to me will set a to 1 and b to 2"}],
"vars": {
"a": 1,
"b": 2
}
},
}
You can modify variables with the following syntax:
"text": {
"addTest": {
"parts": [{"text": "Talking to me will set a to the result of (1, +2, *3, -4, /5). This does not use PEMDAS/BIDMAS."}],
"vars": {
"a": "1.add(2).mul(3).sub(4).div(5)"
}
},
}
Name |
Syntax | description | Example | Result | Notes |
---|---|---|---|---|---|
add | x.add(y) | adds y to x | 0.add(1) | 1 | |
sub | x.sub(y) | subtracts y from x | 1.sub(2) | -1 | |
mul | x.mul(y) | multiplies y and x | 2.mul(3) | 6 | |
div | x.div(y) | divides x by y | 3.div(4) | 0.75 | |
floor | x.floor() | rounds x down | 3.div(4).floor() | 0 | You cannot use a float literal in modifier syntax, so this is usually used to convert a float from a division to an integer. |
ceil | x.ceil() | rounds x up | 3.div(4).ceil() | 2 | You cannot use a float literal in modifier syntax, so this is usually used to convert a float from a division to an integer. |
min | x.min(y, z) | smallest value of y and z | 0.min(1, 10) | 1 | |
max | x.max(y, z) | largest value of y and z | 0.max(1, 10) | 10 | |
rand | 0.rand(y, z) | random number between y and z (inclusive) | 0.rand(1, 100) | e.g. 42 | |
equals | x.equals(y) | Returns 1 if str equals x. Otherwise, Returns 0. | 2.mul(2).equals(4) | 1 |
Name |
Syntax | description | Example | Result | Notes |
---|---|---|---|---|---|
lower | str.lower() | converts a String to lower case | SANGAN.lower | sangan | |
upper | str.upper() | converts a String to UPPER CASE | sangan.upper() | SANGAN | |
proper | str.proper() | converts a String to Proper Case | hi there.proper() | Hi There | |
snake | str.snake() | converts a String to snake_case | hi there.snake() | hi_there | |
deSnake | str.desnake() | converts a snake_case_string to regular case | hi_there.desnake() | hi there | |
substring | str.substring(x,y) | Removes part of a String, from position x to position y. | Sangan.substring(0,3) | San | You can instead use x.substr(y,z) |
append | str.append(x) | Puts x at the end of str | San.append(gan) | Sangan | You can instead use str.concat(x) |
prepend | str.prepend(x) | Puts x at the start of str | San.prepend(gan) | ganSan | |
toChar | str.toChar() | Returns the utf8 character values of str. | Sangan.toChar() | 839711010397110 | |
equals | str.equals(x) | Returns 1 if str equals x. Otherwise, Returns 0. | Sangan.lower().equals(sangan) | 1 |
Name |
Syntax | description | Example | Result | Notes |
---|---|---|---|---|---|
isCard |
cardname.isCard() | Returns 1 if cardName equals x. Otherwise, Returns 0. | Sangan.isCard() | 1 | Case-sensitive; sangan.iscard() = 0. Cards not in the campaign do not exist and will return 0. |
isCardInsensitive |
cardname.isCardInsensitive() | Returns 1 if cardName equals x. Otherwise, Returns 0. | sangan.isCardInsensitive() | 1 | The same as isCard, but case-insensitive. |
getStat |
x.getStat(cardname, cardstat) | Returns the cardstat of cardname | 0.getStat(sangan, atk) | 1000 | Cardname is not Case-sensitive. Stat is always lowercase. Cards/stats not in the campaign do not exist and will return 0. |
You can dynamically reference a variable with <<thisSyntax>>
"someEvent": { Let's say that the variable "playerImage" is set to "yugi"
"image": "<<playerImage>>.webp" This will be read as "yugi.webp"
}
You can also use this with the above modifiers:
"text": {
"addTest": {
"parts": [{"text": "Sets totalAnimals to the sum of cats+dogs"}],
"vars": {
"totalAnimals": "0.add(<<cats>>).add(<<dogs>>)"
}
},
}
You can use this event to fiddle with some events.json settings.
The settings are only modified for the campaign's save file, not the actual settings.json.
Use this for things like a character select.
"vars": {
"becomeMika": [
{"Duelingbook_Name" : "Mika" },
{"Duelingbook_Avatar" : "windUpRat.webp"},
{"deckBuilderImage" : "coolImage.webp"},
{"minimumMaindeckSize": "40"},
{"Lives" : "3"},
{"Progress" : "1"}Progress refers to the "row" of the map you're on: This will set you back to the start of the current map.
]
}