GlitchScript
Batch Structure
- Batches are separated by forward slashes (/).
- A batch can include Main Functions, Consequence Functions, and IF Statements.
- Consequence Functions and IF Statements can co-exist in the same batch.
Valid Batch Examples
- /TIMING:WinDuel/
- /IF(VALUE_1<VALUE_2):mpdmg(Self,-7):IF(VALUE_1>VALUE_2):mpdmg(Self,7)/
- /mpdmg(Self,-7)/
- /IF(VALUE_1<VALUE_2):VALUE_1:math(VALUE_1+10)/
- /setdata(Self,2,10)/VALUE_0:getdata(Self,2)/buf(Self,Enhancement,VALUE_0,0,0)/
Invalid Batch Example
- /TIMING:WinDuel:mpdmg(Self,-7)/
- /VALUE_1:55:LOOP:EveryAlly/
- /LOOP:EveryAlly:TIMING:WinDuel/
 (MAIN functions need to be alone in their own batches)
Execution Order
- Batches are executed in the order they appear.
Main Functions
TIMING Function
Sets the timing for effect activation. Only the last timing in the list will apply if multiple timings are defined.
Example
LUA Function
Allows a .lua file to be loaded from the modular_lua folder. Note: Two .lua file names should not be named the same, otherwise it will cause this function to break.
LUAMAIN Function
Specifies which .lua function that Modular should call. This allows the same .lua script to be used for multiple timing's. For example: "Modular/TIMING:RoundStart/LUA:passiveRoundStart/LUAMAIN:test_main" would call test_main() in passiveRoundStart.lua. If you wish to pass parameters, do it like so: "LUAMAIN:myfunction(5,true,hello)". These values will turn into .lua values, going in the order in which they are passed. ("5" becomes 5, "true" becomes true, and "hello" stays as "hello")
LOOP Function
This is performance intensive. Only use it if absolutely necessary.
LOOP iterates the script over a list of units, overriding the Target argument as the current iteration's target. See Multi-Target for all possible arguments.
When using the LOOP function in a .lua file, instead of using Target, use MainTarget, as Target is an inline modular feature, however, MainTarget does basically the same thing, and is compatible with both .lua and inline modular scripts.
Example
RESETWHENUSE Function
Used for passives, on odd timings like WinDuel or BeforeAttack. Resets the scale, final, base, clash, dmg, and dmgmult adders for that particular Modular Script when a skill is used. Prevents such power increases from sticking around when using more than 1 Skill per turn.
Example
CLEARVALUES Function
Sets all VALUEs to 0 every time the script is enacted. (Note: By Default, VALUES arent cleared when the script is activated twice, while that doesn't cause too many issues usually since they'd typically get overwritten by next declaration of the value, this can be useful in some situations)
Skill Timings
| Timing | Corresponding Locale | Notes | 
|---|---|---|
| RoundStart | [Turn Start] | Runs if the skill is in the bottom 2 slots of the dashboard | 
| StartBattle | [Combat Start] | |
| EndBattle | [Turn End] | |
| WhenUse | [On Use] | |
| BeforeAttack | [Before Attack] | |
| BeforeUse | [Before Use] | |
| DuelClash | Clash Count | Triggers On Each Individual Clash in a Duel (Clash) | 
| DuelClashAfter | Clash Count | Triggers On Each Individual Clash in a Duel (Clash) (Difference between this and DuelClashare unknown) | 
| StartDuel | [Clash Start] | |
| WinDuel | [Clash Win] | |
| DefeatDuel | [Clash Lose] | |
| EndSkill | [After Attack] | Bugged | 
| OnSucceedAttack(var_1,var_2) | No Conditions: [On Hit], Crit Condition: [On Crit], NoCrit Condition: Only if not a critical hit | |
| BeforeSA(var_1,var_2) | Not In Vanilla | Triggers right before the hit connects | 
| OnSucceedEvade | [On Evade] | |
| OnDefeatEvade | [Failed Evade] | |
| OnDiscard | "if this Skill is Discarded" at the end of the line | |
| BeforeBehaviour | [Before Use] | |
| OnStartBehaviour | [On Use] | |
| OnEndBehaviour | [After Attack] | |
| EnemyKill | [On Kill] | |
| StartVisualSkillUse | Not In Vanilla | Triggers on the visual start of a Skill being used. (Used mainly for the sound consequence, with things like VFX, and dialogue lines) | 
| StartVisualCoinToss | Not In Vanilla | Triggers on the visual start of a Coin being tossed. (Mainly used for the sound consequence, with things like voice lines) | 
| OnCoinToss | When a coin is tossed | activates each time a coin is tossed, similar to how bleed works | 
| FakePower | Prediction Phase | (Used for prediction, only for base(), final(), and clash(). Don't use any other consequences) | 
Coin Timings
- OnSucceedAttack(var_1,var_2)
- Arguments:- var_1:- Head|- Tail|- None(Only on heads, only on tails, or no condition.)
- var_2:- Crit|- None|- NoCrit(Only on crit, or only when not a crit)
 
- note: Can be Shortened to- OSA
- BeforeSA(var_1, var_2)
- Arguments:- var_1:- Head|- None|- Tail(Heads/Tails trigger)
- var_2:- Crit|- None|- NoCrit(Only on crit, or only when not a crit)
 
- note: Can be Shortened to- BSA
- OnCoinToss
- ChangeMotion
Passive Timings
| Timing | Corresponding Locale | Notes | 
|---|---|---|
| RoundStart | [Turn Start] | |
| AfterSlots | [Turn Start] | A special RoundStart timing that triggers after Slots are formed. Used for skillslotreplace() | 
| StartBattle | [Combat Start] | |
| EndBattle | [Turn End] | |
| WhenUse | [On Use] | |
| BeforeAttack | [Before Attack] | |
| DuelClash | Clash Count | Triggers On Each Individual Clash in a Duel (Clash) | 
| StartDuel | [Clash Start] | |
| WinDuel | [Clash Win] | |
| DefeatDuel | [Clash Lose] | |
| EndSkill | [After Attack] | Bugged | 
| OnSucceedAttack(var_1,var_2) | No Conditions: [On Hit], Crit Condition: [On Crit], NoCrit Condition: Only if not a critical hit | |
| BeforeSA(var_1,var_2) | Not In Vanilla | Triggers right before the hit connects | 
| OnDiscard | "if this Skill is Discarded" at the end of the line | |
| OnStartBehaviour | [On Use] | |
| OnEndBehaviour | [After Attack] | |
| EnemyKill | [On Kill] | |
| FakePower | Prediction Phase | (Used for prediction, only for base(), final(), and clash(). Don't use any other consequences) | 
| WhenHit(var_1, var_2) | [Before Getting Hit] | ('Target' becomes the unit BEING HIT, 'Self' becomes the unit who USED THE ATTACK) | 
| BeforeWhenHit(var_1, var_2   ) | [Before Getting Hit] | ('Target' becomes the unit BEING HIT, 'Self' becomes the unit who USED THE ATTACK) | 
| BeforeDefense | Not In Vanilla | Triggers before a defense skill is used | 
| OnDie | Not In Vanilla | Triggers when This Unit dies. ("Target" becomes the dead unit unless LOOP is involved) | 
| OnOtherDie | Not In Vanilla | Triggers when another Unit dies. ("Target" becomes the dead unit unless LOOP is involved) | 
| OnBreak | Not In Vanilla | Triggers when This Unit gets staggered. ("Target" becomes the dead unit unless LOOP is involved) | 
| OnOtherBreak | Not In Vanilla | Triggers when another Unit gets staggered. ("Target" becomes the dead unit unless LOOP is involved) | 
| EnemyEndSkill | Not In Vanilla | Triggers when the enemy's skill used on you Ends | 
| Immortal | Not In Vanilla | They trigger when the unit gets dropped to 0 HP. DURING THAT SCRIPT, if you use setimmortal(1), the unit about to be killed will remain alive and its HP will be set to 1. | 
| ImmortalOther | Not In Vanilla | They trigger when the unit gets dropped to 0 HP. DURING THAT SCRIPT, if you use setimmortal(1), the unit about to be killed will remain alive and its HP will be set to 1. Target is the victim. | 
| OnCoinToss | When a coin is tossed | activates each time a coin is tossed, similar to how bleed works | 
| StartBattleSkill/can be shortened toSBS | Combat start, activates once for every skill chained | activates on combat start multiple times, the amount of times being dictated by the amount of chained skills, example: Modular/TIMING:SBS/VALUE_0:skilldeftype/IF(OR,VALUE_0=1,VALUE_0=2,VALUE_0=3):buf(Self,Protection,1,0,0)= For every Guard, Evade, or Counter chained, gain 1 prot | 
| SpecialAction | Most Complete Certainly NOT In Vanilla | (Unique Timing triggered when you ctrl+LMB the portrait of the Unit on the dashboard, this is experimental) | 
| IgnorePanic | On Panic | Mainly used with ignorepanic consequence | 
| IgnoreBreak | On Stagger | Mainly used with ignorebreak consequence | 
WhenHit(var_1, var_2)
- Arguments:- var_1:- Head|- None|- Tail(Heads/Tails trigger)
- var_2:- Crit|- None|- NoCrit(Only on crit, or only when not a crit)
 
- note: Can be Shortened to- WH
- BeforeWhenHit(var_1, var_2)
- Arguments:- var_1:- Head|- None|- Tail(Heads/Tails trigger)
- var_2:- Crit|- None|- NoCrit(Only on crit, or only when not a crit)
 
- note: Can be Shortened to- BWH
E.G.O. Passive Support
Do note that all passive timings work on E.G.O. Passives as well
Support Passive Support
Support Passives act out like regular passives except every unit alive has said passive, its sort of like LOOP: but instead of target as the unit the loop is going through its self (which matches the idea its a normal passive that every unit has)
Some timings like OnOtherDie have some odd semantics where self is the killer and target is the dead guy
Reliable
RoundStart, AfterSlots, StartBattle, EndBattle,
WhenUse, BeforeAttack, StartDuel, WinDuel,
DefeatDuel, EndSkill, OnDiscard,
OnStartBehaviour, OnEndBehaviour
Unreliable
BeforeDefense, OnDie, OnOtherDie, OnBreak,
OnOtherBreak, Immortal, ImmortalOther,
DuelClash, OnSucceedAttack, BeforeSA,
WhenHit, BeforeWhenHit, EnemyKill,
EnemyEndSkill, OnCoinToss, FakePower,
StartBattleSkill
Not Supported
SpecialAction 
Value Assignment
You can set any VALUE (from VALUE_0 to VALUE_9) to any integer. Values beyond VALUE_9 are not allowed.
Examples
- /VALUE_0:5/→- VALUE_0 = 5
- /VALUE_1:-5/→- VALUE_1 = -5
- /VALUE_2:mpcheck(Self)/→ Result depends on SP value
- /VALUE_3:math(VALUE_0*VALUE_0)/→- VALUE_3 = 25(- 5*5)
Math Symbols (Integers Only)
| Symbol | Operation | Example | 
|---|---|---|
| + | Add | VALUE_0 + VALUE_1 | 
| - | Subtract | VALUE_0 - VALUE_1 | 
| * | Multiply | VALUE_0 * VALUE_1 | 
| % | Divide | VALUE_0 % VALUE_1 | 
| ! | Min value between two numbers | 15!10 → 10 | 
| ¡ | Max value between two numbers | 1¡3 → 3 | 
| ? | Modulo | VALUE_0 ? VALUE_1 | 
In-Consequence Math:
Prefixing a consequence's integer input with m turns it into a math equation. - turns the input negative.
VALUE_0:15/healhp(Self,10) → Heal 10 HP
VALUE_0:15/healhp(Self,-10) → Lose 10 HP
VALUE_0:15/healhp(Self,VALUE_0) → Heal 15 HP
VALUE_0:15/healhp(Self,-VALUE_0) → Lose 15 HP
VALUE_0:15/healhp(Self,VALUE_0*2) → Invalid
VALUE_0:15/healhp(Self,mVALUE_0*2) → Heal 30 HP
VALUE_0:15/healhp(Self,m-VALUE_0*2) → Invalid math
VALUE_0:15/healhp(Self,-mVALUE_0*2) → Lose 30 HP
Target Arguments
- Single-Target- Self
- SelfCore(If the target is an abnormality PART, get the core instead)
- Target(Functionally the same as MainTarget unless you're using LOOP)
- TargetCore(If the target is an abnormality PART, get the core instead)
- MainTarget
- id#####(Fill ##### with a unit ID or a VALUE_X)
- inst#####(Fill ##### with a unique instance ID or a VALUE_X)
- adjLeft(Adjacent unit to the left)
- adjRight(Adjacent unit to the right)
 
- Multi-Target- Self
- SelfCore(If the target is an abnormality PART, get the core instead)
- Target(Functionally the same as MainTarget unless you're using LOOP)
- TargetCore(If the target is an abnormality PART, get the core instead)
- MainTarget
- EveryTarget
- SubTarget
- id#####(Fill ##### with a unit ID or a VALUE_X)
- inst#####(Fill ##### with a unique instance ID or a VALUE_X)
- adjLeft(Adjacent unit to the left)
- adjRight(Adjacent unit to the right)
- All(Every fielded unit)
 
Custom Targeting:
- Starter Sorting Tag (Mutually exclusive, must go first)- Slowest
- Fastest
- HighestHPRatio
- LowestHPRatio
- HighestHP
- LowestHP
- HighestMaxHP
- LowestMaxHP
- HighestMP
- LowestMP
 
- Sorting Tag (Mutually exclusive)- Random
- Deploy
- Reversedeploy
 
- Team Tags (Mutually exclusive)- Ally (Removes all enemies from list)
- Enemy (Removes all allies from list)
 
- Exclusion Tags (Mutually exclusive)- AbnoOnly
- NoAbnos
 
- Exclusion Tags (Mutually exclusive)- NoCores
- NoParts
 
- Inclusion Tags- Assist (Includes Assistants to the list, otherwise excluded)
 
- Exclusion Tags (Can be stacked)- ExceptSelf (Removes Self from list)
- ExceptTarget (Removes Target from list, if it exists)
 
- Amount Tag (Multi-Target only)- Any number from 1 to 999 (VALUE_X can be used)
 
- Ending Bufcheck Tag (Must be at the end, only ONE can be used)- $Keyword (example: $Enhancement)
 
Value Acquisition Functions
Retrieve specific values for calculations. These functions return integers.
hpcheck(var_1, var_2)
Gets HP value based on the arguments.
- Arguments:- var_1: See Single-Target
- var_2:- normal|- %|- max- normal: Remaining HP
- %: Percentage of remaining HP (rounded down, e.g., 349/350 = 99)
- max: Max HP value
- missing: Missing HP value
- missing%: Missing HP percentage
 
 
mpcheck(var_1)
Gets SP value based on the argument.
- Arguments:- var_1: See Single-Target
 
bufcheck(var_1, var_2, var_3)
Returns an integer based on the buff mode.
- Arguments:- var_1: See Single-Target
- var_2: Buff keyword (e.g.,- Enhancement,- Agility)
- var_3:- stack|- turn|- +|- *|- consumed- stack: Potency (0 if no buff)
- turn: Remaining turns (0 if no buff)
- +: Potency + Turns
- *: Potency * Turns
- consumed: Amount of the buff consumed throughout the encounter (0 if the buff doesn't track the amount consumed/isn't consumable)
 
 
getdmg
Returns the damage. Only usable with OnSucceedAttack and WhenHit
round
Returns the round.
wave
Returns the wave.
activations
Returns the amount of times this script has been triggered before. First time = 0.
unitstate(var_1)
Returns:
-1 if the unit doesn't exist
0 if the unit is dead
1 if the unit is alive
2 if the unit is staggered
- Arguments:- var_1: See Single-Target
 
getid(var_1)
Returns the unitID of the target.
- Arguments:- var_1: See Single-Target
 
getcharacterid(var_1)
Returns the characterID of the target (Sinners only)
- Arguments:- var_1: See Single-Target
 
instid(var_1)
Returns the unique instance ID of the target.
- Arguments:- var_1: See Single-Target
 
speedcheck(var_1,opt_2)
Returns the speed of the target.
- Arguments:- var_1: See Single-Target
- opt_2:- VALUE_#| any integer (checks a specific slot index's speed)
 
getpattern(var_1)
Returns the pattern index (integer) of the target.
- Arguments:- var_1: See Single-Target
 
getdata(var_1,var_2)
Gets encounter-persistent data from the target.
- Arguments:- var_1: See Single-Target
- var_2:- VALUE_#| any integer (The Data ID)
 
deadallies(var_1)
Gets number of target's dead allies.
- Arguments:- var_1: See Single-Target
 
random(var_1,var_2)
Returns a random integer between min and max
- Arguments:- var_1:- VALUE_#| any integer (Minimum value inclusive)
- var_2:- VALUE_#| any integer (Maximum value inclusive)
 
getshield(var_1)
Returns the amount of shield on target.
- Arguments:- var_1: See Single-Target
 
areallied(var_1,var_2)
Returns 1 if both units are allied. Returns 0 if they are enemies.
- Arguments:- var_1: See Single-Target
- var_2: See Single-Target
 
getskillid
No Arguments. Returns the ID of the skill being used. Does not work on TIMINGs that have no Skills being used.
getcoincount(var_1,var_2)
Gets the coin count of the skill. Returns -1 if var_1 not found.
- Arguments:- var_1:- Self|- Target("Target" is only available when there is a clash)
- var_2:- cur|- og(Current coin count and Original coin count respectively)
 
allcoinstate(var_1,var_2)
Returns the state of the coins. Returns -1 if var_1 not found.
- Arguments:- var_1:- Self|- Target("Target" is only available when there is a clash)
- var_2:- full|- headcount|- tailcount(Selecting "full" will return 0 if mixed, 1 if all Heads, 2 if all Tails)
 
resonance(var_1)
Returns the resonance of the given type
- Arguments:- var_1:- highres(Returns the highest resonance of any type)
- highperfect(Returns the highest absolute resonance of any type)
- ?????|- perfect?????(Specifies highest type of resonance. If prefixed with "perfect", only returns the highest absolute resonance of that type)
 Examples:
 - /VALUE_0:resonance(perfectAZURE),- /VALUE_0:resonance(INDIGO),- /VALUE_0:resonance(highperfect)
 
 
resource(var_1,opt_2)
Returns the amount of sin resources.
- var_1:- CRIMSON|- SCARLET|- AMBER|- SHAMROCK|- AZURE|- INDIGO|- VIOLET
- opt_2:- Enemy(Add this optional argument to affect the enemy team)
haskey(var_1, var_2, var_3~X)
Returns 1 if the selected unit has the keyword, 0 if not
- Arguments:- var_1: See Single-Target
- var_2: AND | OR (AND means it needs to have every keyword added to return 1, OR means it needs just one keyword to return 1)
- var_3~X: Any string that could be a unitKeyword or association in the json data of a unit. More than 1 can be added, separated by commas.
 
skillbase(var_1)
Returns skill base power.
- Arguments:- var_1:- Self|- Target
 
skillatkweight(var_1)
Returns attack weight.
- Arguments:- var_1:- Self|- Target
 
onescale(var_1,var_2)
Returns one coin's Coin Power.
- Arguments:- var_1:- Self|- Target
- var_2:- VALUE_#| any integer (Coin Index, starts at 0. If the index is out of range, checks the last coin instead.)
 
skillatklevel(var_1,var_2)
Returns skill's offense level.
- Arguments:- var_1:- Self|- Target
- var_2:- VALUE_#| any integer (Coin Index, starts at 0. If the index is out of range, checks the last coin instead.)
 
getskilllevel(var_1)
Returns the unit's offense level + skill offense level
- Arguments:- var_1- Self|- Target
 
skillatk(var_1)
Returns skill atk type, 0 = Slash, 1 = Pierce, 2 = Blunt, 3 = None
- Arguments:- var_1:- Self|- Target
 
skillattribute(var_1)
Returns skill sin, Wrath = 0, Lust = 1, Sloth = 2, Gluttony =3, Gloom = 4, Pride = 5, Envy = 6, White = 7, Black = 8, Red = 9, Pale = 10, Neutral = 11.
- Arguments:- var_1:- Self|- Target
 
skilldeftype(var_1)
Returns Defense Type, None = 0, Guard = 1, Evade = 2, Counter = 3, Attack = 4, Non_Action = 5. (Non_action is only used once and by the panic skill)
- Arguments:- var_1:- Self|- Target
 
skillrank(var_1)
Returns the tier of the target's skill
- Arguments:- var_1:- Self|- Target
 
skillegotype(var_1)
Returns Ego Type, Skill = 0, Awaken = 1, Corrosion = 2, Corrosion Unstable = 3, Corrosion Stable = 4, Upgrade = 5, 6 = None.
- Arguments:- var_1:- Self|- Target
 
amountattacks(var_1)
returns how many skills are attacking the specified unit
- Arguments:
- var_1; See Single-Target
coinisbroken()
if the coin this script is on is broken return 1, otherwise return 0
skillslotcount(var_1)
Returns the number of slots of the target
- Arguments:
- var_1: See Single-Target
isfocused()
Returns 1 if the battle is a Focused Encounter, 0 if it is a Regular Encounter
getdmgtaken(var_1,var_2)
Returns the amount of damage taken by the target
- Arguments:- var_1: See Single-Target
- var_2 option:- prev(Returns the amount of damage taken last turn)
- var_2 option:- current(Returns the amount of damage taken this turn)
 
getbuffcount(var_1,var_2)
Returns the amount of buffs on the target (e.g if the target has Bleed and Rupture on them, return), specify either negative or positive.
- Arguments:- var_1: See Single-Target
- var_2 option:- neg(Returns the amount of positive buffs on self)
- var_2 option:- pos(Returns the amount of negative buffs on self)
 
unitcount(var_1)
Returns the amount of units based off Target, (Example: unitcount(NoParts99) would return the amount of enemies alive.)
- Arguments:- var_1: See Single-Target
 
breakcount(var_1)
Returns the amount of stagger bars on the target
- Arguments:- var_1: See Single-Target
 
breakvalue(var_1)
Returns the point of the target's stagger bar
- Arguments:- var_1: See Single-Target
- var_2: Stagger index (eg: 0 = first stagger bar)
 
timeget(var_1,opt_2)
IM GOING TO KILL MYSELF WHY DOES THIS EXIST
Returns the time according to the parameter.
- Arguments:- var_1 option:- dayofweek(Returns 0-6, starting from sunday at 0 and saturday at 6, depending on what day of the week it is)
- var_1 option:- dayofmonth(Returns 1-31, depending on what day of the month it is)
- var_1 option:- dayofyear(Returns 1-366, depending on what day of the year it is)
- var_1 option:- hours(Returns 0-23, depending on what hour of the day it is)
- var_1 option:- minutes(Returns 0-59, depending on what minute of the hour it is)
- var_1 option:- seconds(Return 0-59, depending on what second of the minute it is)
- var_1 option:- milliseconds(Returns 0-999, depending on what millisecond of the second it is, if you use this unironically i hope you die.)
- var_1 option:- ticks(Returns ??-??, what the fuck is a limbus company tick why would you ever use this just why please god answer my pleas)
- var_1 option:- month(Returns 1-12, depending on what month of the year it is)
- var_1 option:- year(Returns 1-9999, depending on what year it is right now)
- var_1 option:- isleapyear(If the year inputted via- opt_2is a leap year, returns 1, otherwise returns 0)
- opt_2:- VALUE_X| any integer (the year, needed for isleapyear)
 
getstat(var_1,var_2)
Returns certain stats of the specified unit based on the parameters
- Arguments:- var_1: See Single-Target
- var_2 option:- deployment(Returns the deployment order of the selected unit)
- var_2 option:- deadAllyCount(Returns the number of dead allies this unit has)
- var_2 option:- res????(Returns the resistance of the unit in the hundreds example if the unit had 1.5x on a resistance it would return 150, input the name of the atk or sin resistances. EG: resSLASH, resCRIMSON)
- var_2 option:- panicType(Returns the panic type id of the selected unit)
- var_2 option:- isRetreated(returns 1 if the unit is retreated)
- var_2 option:- speedMin|- speedMax|- speedMinOG|- speedMaxOG(Checks speed ranges, both current and original)
- var_2 option:- hasMp(Returns 1 if the unit has SP. returns 0 if not)
- var_2 option:- deflevel(Returns Defense Level of the unit)
 
coinrerolled
Returns 1 if a coin has been rerolled; otherwise, returns 0
stageextraslot(var_1,opt_2)
Gets the stage extra slot
getbloodfeast(var_1)
Returns bloodfeast based on the variable given
- Arguments:- var_1 option:- available(Returns currently available bloodfeast)
- var_1 option:- spent(Returns shared consumed bloodfeast)
 
getlevel(var_1)
Returns the unit's level
- Arguments:- var_1: See Single-Target
 
isunbreakable(var_1)
Returns if a Coin is unbreakable (Only usable with timing's that use Coins)
- Arguments:- var_1: Self | Target (1 if unbreakable, 0 if not)
 
isusableinduel(var_1)
Returns if a Coin is usable in a duel (Only usable with timing's that use Coins)
- Arguments:- var_1: Self | Target (1 if uncracked, 0 if cracked)
 
sameunit(var_1, var_2)
Returns 1 if the 2 inputs result in the same unit, otherwise returns 0
- Arguments:- var_1: See Single-Target
- var_2: See Single-Target
 
skillcanduel(var_1)
Returns 1 if the Skill can Duel, 0 if not.
- Arguments:- var_1: See Single-Target
 
skillteamkill(var_1)
Returns 1 if the Skill can kill allies, 0 if not.
- Arguments:- var_1: See Single-Target
 
skillfixedtarget(var_1)
Returns 1 if the Skill has a fixed target, 0 if not.
- Arguments:- var_1: See Single-Target
 
gethpdmg
Returns the amount of damage that this unit has taken
Consequence Functions
These functions define the effects that occur based on conditions or values.
log(var_1, var_2)
Prints a line in the Bepinex Log with the provided VALUE
- Arguments:- var_1: Any string (spaces will be automatically deleted; try not to use special characters)
- opt_1:- VALUE_#| any integer
 
bonusdmg(var_1, var_2, var_3, var_4)
Deals bonus damage.
- Arguments:- var_1: See Multi-Target
- var_2:- VALUE_#| any integer
- var_3:- -1(true damage) |- 0(slash) |- 1(pierce) |- 2(blunt)
- var_4:- -1(true damage) |- 0~6(sin types)
 
note: here's a list of the numbers corresponding to every sin type:
- Wrath: 0
- Lust: 1
- Sloth: 2
- Gluttony: 3
- Gloom: 4
- Pride: 5
- Envy: 6
- White: 7
- Black: 8
mpdmg(var_1, var_2)
Applies SP damage or heals SP.
- Arguments:- var_1: See Multi-Target
- var_2:- VALUE_#| any integer
 
buf(var_1, var_2, var_3, var_4, var_5, opt_6)
Inflicts buffs by keyword, potency, and count. Negative values consume the buff.
- Arguments:- var_1: See Multi-Target
- var_2: Buff keyword (e.g.,- Enhancement,- Agility)
- var_3:- VALUE_#| any integer (potency/stack)
- var_4:- VALUE_#| any integer (turn/count)
- var_5:- VALUE_#| any integer (active round, 0 is this turn, 1 is next turn, this function has an exclusive "2" option to apply the buff this turn AND next turn)
- opt_6:- use(Adding it and setting it to "use" will attempt to "consume" the buf instead of removing it. Mostly used for the 7 main bufs and things like Gegagorr's Fuel.)
 
shield(var_1,var_2,opt_3)
Applies Shield.
- Arguments:- var_1: See Multi-Target
- var_2:- VALUE_#| any integer
- opt_3:- perm(Adding this optional variable makes the shield not decay after the round ends)
 
healhp(var_1, var_2)
Heals HP to the Targets by the specified value, putting in a negative Value makes it take away HP similar to Bleed (True Damage that doesn't cause staggers)
- Arguments:- var_1: See Multi-Target
- var_2:- VALUE_#| any integer (Add a % to the end to heal by percentage of max HP of the target. Example: "20%", "VALUE_0%")
 
explosion(var_1, var_2)
Tremor Burst.
- Arguments:- var_1: See Multi-Target
- var_2:- VALUE_#| any integer (The amount of times it triggers Tremor Burst)
 
breakdmg(var_1, var_2, opt_3)
Raises or Lowers the first stagger bar.
- Arguments:- var_1: See Multi-Target
- var_2:- VALUE_#| any integer (Positive values deal stagger damage, negative values "heal" stagger)
- opt_3:- VALUE_#| any integer (The amount of times it triggers)
 
break(var_1, opt_2)
Staggers the target immediately
- Arguments:- var_1: See Multi-Target
- opt_2:- natural|- force|- both(Type of Stagger)
 
breakrecover(var_1)
Recovers the target from Stagger
- Arguments:- var_1: See Multi-Target
 
breakaddbar(var_1, var_2)
Adds a Stagger Threshold to the target. Setting it above the target's Max HP causes a stagger on the next hit.
- Arguments:- var_1: See Multi-Target
- var_2:- VALUE_#| any integer (Exact HP Value to add the threshold. Add '%' to have it scale with max HP. Example: '25%')
 
scale(var_1,opt_2)
Gains coin power (similar to vanilla for negative coins).
- Arguments:- var_1:- VALUE_#| any integer (Adds or subtracts coin power)
- var_1:- ADD|- SUB|- MUL(Changes the operatorType of the coins)
- opt_2: any integer (Sets the index of the coin to be affected. WIP, tests are in order. 0 means first coin, 4 means fifth coin) (NOT usable in FakePower Timing)
 
base(var_1)
Gains base skill power.
- Arguments:- var_1:- VALUE_#| any integer (Adds or subtracts power)
 
final(var_1)
Gains final power.
- Arguments:- var_1:- VALUE_#| any integer (Adds or subtracts power)
 
clash(var_1)
Gains clash power.
- Arguments:- var_1:- VALUE_#| any integer (Adds or subtracts power)
 
dmgadd(var_1)
Gains +Damage (this functions as if you are adding Final Power to a Skill Before Attack for the purposes of damage calculation
- Arguments:- var_1:- VALUE_#| any integer (Adds or subtracts)
 
dmgmult(var_1)
Gains +Damage%.
- Arguments:- var_1:- VALUE_#| any integer (Adds or subtracts)
 
pattern(var_1)
Sets the pattern index to the user (WIP).
- Arguments:- var_1:- VALUE_#| any integer (Pattern index)
 
setdata(var_1,var_2,var_3)
Sets encounter-persistent data to the target.
- Arguments:- var_1: See Multi-Target
- var_2:- VALUE_#| any integer (The Data ID. Make this unique so it does not conflict with other mods, e.g: Skill ID + 10 or similar)
- var_3:- VALUE_#| any integer (The value to be set)
 
changeskill(var_1)
Changes the skill mid-combat to another skill in this unit's arsenal.
- Arguments:- var_1:- VALUE_#| any integer (The Skill ID)
 
reusecoin(var_1,var_1...)
Reuses any number of coins (Doing this OnSucceedAttack is buggy, wait for fix)
- Arguments:- var_1:- VALUE_#| any integer (The index of the coin to be reused. You can input as many indexes as you need. -1 for coin scripts to target themselves)
 
aggro(var_1, var_2, opt_3, opt_4)
Adds Aggro to one or all slots
- Arguments:- var_1: See Multi-Target
- var_2:- VALUE_#| any integer (Aggro amount)
- opt_3:- this|- next(default: 'next') (Same turn or next turn Aggro)
- opt_4:- VALUE_#| any integer (slot application)
 Slot application:
 -2 = Used slot. If no skill is involved, or if used on someone other than Self, defaults to slot 0.
 -1 = All slots (spreads equally from left to right)
 0 or higher = slot index, 0 being the leftmost
 
skillreuse(var_1)
Reuses currently used skill against all targets given.
- Arguments:- var_1: See Multi-Target
 
skillsend(var_1, var_2, var_3, opt_4)
Sends an attack from a unit to another. The selected skill must exist in the attacker's arsenal.
NOTE: If you want your Guards and Evades to queue for the first attack received on Combat Start, set var_2 to Self
- Arguments:- var_1: See Single-Target (ATTACKER)
- var_2: See Multi-Target (VICTIM)
- var_3: Any Skill ID | S# | D# (# being the tier or index of the Skill on the attacker's arsenal. Example: S2, D1)
- opt_4: def (If your skill isn't activating for some reason, try adding this optional argument. Guards and Evades need this.)
 
skillslotreplace(var_1,var_2,var_3)
Replaces all skills in the designated Skill Slot index.
Will log an error if index is invalid. Will log an error if Self is invalid (no targeting argument is allowed)
- Arguments:- var_1:- All|- VALUE_#| any integer (Slot Index, starts at 0. 'All' affects all slots instead)
- var_2:- VALUE_#| any integer (Skill ID that will be lost) | 'All' affects every skill instead.
- var_3:- VALUE_#| any integer (Skill ID that will be given)
 
setslotadder(var_1,var_2)
Adds or removes from maxActionSlotNum (Abno only)
- Arguments:- var_1: See Multi-Target
- var_2:- VALUE_#| any integer (Amount of Slots to be given)
 
resource(var_1,var_2,opt_3)
Gives or Removes Sin Resource from a team.
- Arguments:- var_1:- CRIMSON|- SCARLET|- AMBER|- SHAMROCK|- AZURE|- INDIGO|- VIOLET
- var_2:- VALUE_#| any integer (Amount of resource generated. Can be negative to remove resource)
- opt_3:- Enemy(Add this optional argument to affect the enemy team)
 
discard(var_1,var_2)
discards skills based on parameters
- Arguments:- var_1:- DESCENDING(Highest skill available) |- ASCENDING(Lowest skill available) |- RANDOM(A random skill)
- var_2:- VALUE_#| any integer (Amount of skills to be discarded)
 
passiveadd(var_1,var_2)
adds a passive into the selected units
- Arguments:- var_1: See Multi-Target
- var_2:- VALUE_#| Passive id
 
passiveremove(var_1,var_2)
removes a passive From the selected Units
- Arguments:- var_1: See Multi-Target
- var_2:- VALUE_#| Passive id
 
endstage
ends the stage instantly
endbattle
ends that turn's battle, skips to next turn
skillcanduel(var_1)
Sets the "canDuel" Variable on the skill to true/false, best used with RoundStart Timing on a skill
- Arguments:- var_1:- True|- False
 
passivereveal(var_1,var_2)
Reveals the passive of the target
- Arguments:- var_1: See Multi-Target
- var_2: Passive ID | VALUE_X |- all
 
skillreveal(var_1,var_2)
Reveals the skill of the target
- Arguments:- var_1: See Multi-Target
- var_2: Skill ID | VALUE_X |- all
 
resistreveal(var_1,var_2)
Reveals the resistances of the target
- Arguments:- var_1: See Multi-Target
- var_2: Body Part ID | VALUE_X
- var_3: res (- CRIMSON,- HIT, etc)
- var_4:- type|- attribute(put in type if var_3 was an attack type, put in attribute if var_3 was a sin)
 
appearance(var_1,var_2)
Changes the appearance of the target
- Arguments:- var_1: See Multi-Target
- var_2: appearance ID
 
- Notes: Due to the way visuals are handled in game, this will always activate at combat start but only if the conditions are met, since the game calculates everything at combat start, e.g: if you made it that on lose duel, the appearance changes, if the game predicted a clash will be lost, it will change appearance at combat start, otherwise it won't
coincancel(var_1,var_1...)
Cancels any number of coins (similar to when you try to use a coin that needs ammo without ammo)
- Arguments:- var_1:- VALUE_#| any integer (The index of the coin to be Cancelled on X. You can input as many indexes as you need.)
 
skillslotgive(var_1)
Adds a skill slot to the unit (Works on Sinners only)
- Arguments:- var_1: See Multi-Target
 
skillslotremove(var_1,var_2)
Removes a skill slot from a unit (Works on Sinners only?)
Note: This does not remove the slot from the UI, however, the game forces it to be untargetable and it is unusable.
- Arguments:- var_1: See Multi-Target
- var_2Slot Index | (Starts from 1)
 
summonassistant(var_1,var_2,var_3)
Summons an Assistant Next turn after activation (Don't use with RoundStart timing as it breaks the game, you can use EndBattle to Achieve the same effect)
- Arguments:- var_1: Assistant ID | VALUE_X (Determines the Assistant to be Summoned)
- var_2: Assistant Level | VALUE_X (Determines the Level of the Assistant Summoned)
- var_3: Assistant Uptie | VALUE_X (Determines the Uptie of the Assistant, Assistants dont use Uptie unless you make them use it, so just default it to 1)
 
summonenemy(var_1,var_2,var_3,var_4,opt_5)
Summons an Enemy or Abnormality Next turn after activation (Don't use with RoundStart timing as it breaks the game, you can use EndBattle to Achieve the same effect)
- Arguments:- var_1: Enemy ID | VALUE_X (Determines the Enemy to be Summoned)
- var_2: Enemy Level | VALUE_X (Determines the Level of the Enemy Summoned)
- var_3: Enemy Uptie | VALUE_X (Determines the Uptie of the Enemy, Enemies dont use Uptie, so just default it to 1)
- var_4: Wave Index | VALUE_X (Determines the Wave the Enemy is summoned in)
- opt_5: enemy (Adding this Optional Parameter in Makes it specifically spawn regular encounter enemies, otherwise spawns Abnos)
 
summonunitfromqueue()
Summons the units from the subunitList
gnome(var_1)
gnome.
- Arguments:- var_1: Multi-Target
 
vibrationswitch(var_1,var_2,opt_3)
Tremor Conversion
- Arguments:- var_1: See Multi-Target
- var_2: Buff keyword (e.g.,- Enhancement,- Agility)
- opt_3:- superpos(Add this optional argument for superposition)
 
setimmortal(var_1)
Used with Immortal and ImmortalOther TIMINGs.
If used with var_1 as 1, the unit about to be killed will remain alive and its HP will be set to 1.
- Arguments:- var_1:- 1|- 0
 
changemap(var_1,var_2)
Changes the Map/Background
- Arguments:- var_1: Map Name
- var_2:- VALUE_#| any integer (Map Size)
 
battledialogline(var_1,var_2)
Makes a unit show a dialog bubble.
- Arguments:- var_1: See Multi-Target
- var_2: String (Dialog to be displayed. Use "_" instead of spaces.)
 
- Note: By using the target exclusive to this function- upperyou can make it set text to appear on the top of the screen (like in the unique cutscenes of the canto 7 or 8 where the lyrics are displayed on top of the screen like in the superbia quick time event)
- Example:- Modular/TIMING:RoundStart/battledialogline(Self,Yes_hello_<sprite_name=\"Combustion\">)
effectlabel(var_1, var_2, var_3, var_4)
This makes a VFX of choice appear around your target
- Arguments:- var_1: See Multi-Target
- var_2: String | (VFX to be played)
- var_3: 'VALUE_#' | active or not, int, Inactive if 0, Active if 1.
- var_4: String | effect layer type, one of: NONE, DIRECTION, ONCE, BACK, SKIN
 
sanchoshield(var_1, var_2)
This creates a swirling blood shield appear around your target (Note: only works for 8380_SanchoAppearance, 1079_Sancho_BerserkAppearance, might not work for 10310_Donquixote_DarkSanchoAppearance)
- Arguments:- var_1: See Multi-Target
- var_2: 0 - 1 | Inactive if 0, Active if 1.
 
retreat(var_1, var_2)
Queues a unit for retreating. All retreats happens at the end of the turn.
- Arguments:- var_1: See Multi-Target
- var_2: Buff Keyword (What appears on the unit when they retreat, like Overwatch Assignment on FullStop Heathcliff)
 
sound(var_1, var_2)
Play a given SFX, BGM, Voice line, or Announcer line.
- Arguments:- var_1: bgm | sfx | voice | announcer
- opt_2: GUID of the BGM/SFX/Voice line (I.e {8d76b7dd-1de4-463e-946f-b02a75cad4aa} or 7SV-062 for voice lines)
- opt_3: Announcer ID, voice line to be played (I.e 20, announcer_round_takebigdmg_20_1)
 
surge(var_1, var_2)
Triggers a Sinking Deluge
- Arguments:- var_1: See Multi-Target
- var_2:- VALUE_#| Amount
 
addability(var_1, var_2, var_3, var_4, var_5)
Adds a unique system ability
- Arguments:- var_1: See Multi-Target
- var_2: See The List of System Abilities
- var_3:- VALUE_#| Stack
- var_4:- VALUE_#| Turn
- var_5:- VALUE_#| activeRound
 - EXAMPLE: addability(Self,MaxSpeedAdder,2,3,1) -> Unit gains +2 max speed for 3 turns next turn
 
removeability(var_1, var_2)
Removes a unique system ability
- Arguments:- var_1: See Multi-Target
- var_2: See The List of System Abilities
 
lyrics(var_1, var_2)
Displays lyrics, like how Mili songs do for the final canto bosses.
- Arguments:- var_1: Hex code colour for the text to display (currently doesn't work, instead, put "reserved")
- var_2: Text to be shown
 
uppertext(var_1,var_2)
Displays text at the top of the screen.
- Arguments:- var_1: Hex code colour for the text to display
- var_2: Text to be shown
 
makeunbreakable(var_1,var_1...)
Makes a regular coin unbreakable
- Arguments:- var_1:- VALUE_#/- all| any integer (Index of the coin you want to make unbreakable. Index starts at 0, use -1 if this script is inside of a coin and you want to target that same coin.) / targets all coins within a skill
 
stageextraslot(var_1,opt_2)
Sets the stage extra slot to a specific value
- Arguments:- var_1:- VALUE_#| Int
- opt_2:- add(Optional "add" argument to add slot capacity instead of setting it)
 
bloodfeast(var_1,var_2,opt_3)
Changes your available bloodfeast by either adding, removing, or spending it
- Arguments:- var_1 option:- add| adds bloodfeast based on var_2
- var_1 option:- sub| removes bloodfeast based on var_2
- var_1 option:- use| spends bloodfeast based on var_2, REQUIRES A TARGET WITH OPT_3
- var_2:- VALUE_#| any integer, the amount of bloodfeast you want to add/remove/spend
- opt_3: See Multi-Target | only used when spending bloodfeast with var_1
 
critchance(var_1)
Adds a chance to deal a Critical Hit
- Arguments:- var_1:- VALUE_#| Any integer, the % chance to deal a Critical Hit (i.e 15 -> 15% chance)
 
assistdefense(var_1,var_2,var_3)
Defends a unit based on the parameters. (Note: The defender Skill must have the Skill ability "SupportiveDefense", must be in the unit's defense skill list, and the unit defending must have the a buff with the ability "SupportProtect" (Mao Faust assist defense)
- Arguments:- var_1: Defender | See Multi-Target
- var_2: Defended | See Multi-Target
- var_3: Skill ID to be used by the Defender
 
ignorepanic(var_1)
Used with the IgnorePanic timing (But can be used on other timings)
If used with var_1 as 1, the affected unit's panic state will be completely disabled.
- Arguments:- var_1:- 1|- 0
 
ignorebreak(var_1)
Used with the IgnoreBreak timing (But can be used on other timings)
If used with var_1 as 1, the affected unit's Stagger state will be completely disabled.
- Arguments:- var_1:- 1|- 0
 
changemotion(var_1,var_2)
Changes a Skill's "SkillMotion" based on the parameters.
- Arguments:- var_1: Motion Type | (i.e S1, S2, S3, S4, etc.)
- var_2: Motion Index | (i.e, 0, 1, 2)
 
changeaffinity(var_1)
Best used with the OnStartBehaviour timing (But can be used on other timings?)
Changes the Sin Affinity of a Skill on usage of said Skill.
- Arguments:- var_1: Sin Affinity | (i.e AZURE, AMBER, BLACK, WHITE, etc.)
 
Buff Supporting Functions
- Buff Scripts Currently don't support every modular function
This is the list of timings it currently supports:
- RoundStart
- WhenUse
- StartDuel
- WinDuel
- DefeatDuel
- OnStartBehaviour
- EndBattle
- OnSucceedAttack
- WhenHit
- OnCoinToss
- OnBurst
- StartBattle
- StartDuel
- OnDiscard
- EndSkill
- OnEndBehaviour
- WhenGained
Exclusive Buff Script Acquisition Functions
stack()
Exclusive to Scripts in Buffs, returns the stack of the buff
turn()
Exclusive to Scripts in Buffs, returns the count of the buff
Exclusive Buff Script Consequence Functions
stack(var_1)
Exclusive to Scripts in Buffs, Adds the Specified Amount to the Stack of the buff, removes if negative
- Arguments:
- var_1: Amount | VALUE_X
turn(var_1)
Exclusive to Scripts in Buffs, Adds the Specified Amount to the Count of the buff, removes if negative
- Arguments:
- var_1: Amount | VALUE_X
Condition Functions
IF Statements
Defines conditional effects.
- Format: /IF(condition):effect/|/IFNOT(condition):effect/
 Can compare<,>, and=
CONTINUEIF
If False, stops the execution of the rest of the script. if LOOP is involved, skip to the next iteration of the loop instead.
- Format: /CONTINUEIF(condition)/
 Can compare<,>, and=
Example
You can chain IF statements separated by commas. Additionally, the first element can specify the type of comparison.
Examples:
IF(AND,VALUE>5,VALUE<10)
IF(OR,VALUE>5,VALUE<10)
IF(XOR,VALUE>5,VALUE<10)
Embedding Acquisition
You can Embed Acquisition functions into consequence functions to directly get the number, embedded acquisitions use {} instead of () and - instead of , to distinguish them and must begin with "G"
Example: "Modular/TIMING:WhenUse/bonusdmg(Target,Ghpcheck{Self-normal},-1,-1)"
STAGESCRIPT ONLY
- Batch Arguments:
- extraslot:#(Acts as if there are that many more free slots in battle)
- instantslot(Instantly fills all possible skill slots)
Example
"Modular/extraslot:4/instantslot"
This stage script makes it so up to 4 sinners gain extra slots, depending on max participant limit.
LUA SECTION
In order for a .lua file to be compatible with Modular, it must be placed into the modular_lua folder. In order for these .lua files to be loaded by a Modular script, they must be placed like so:
"Modular/TIMING:StartBattle/LUA:hello_world"
Each mod folder has their own modular_lua folder, however, no two .lua files should have the same name even if they are from different mods. It is best to prefix your .lua files with the name of your mod, and the author. (i.e wei_ShaneLitterateur)
In order to use consequence functions and accquisition functions, you'd call them the same as you normally do in Modular. The following is an example of a .lua file doing this exact same thing.
As you can see, you can use functions in .lua files, making your modular scripts 10x cleaner. The .lua files also support using normal programming language features (i.e loops, if/else statements, etc.) meaning that you can revolutionize your Modular scripts. Yipee!
There are a few unique functions specific to the .lua files.
Exclusive .lua Functions
setldata(var_1, var_2, var_3)
Sets encounter-persistent data from the target.
- Arguments:- var_1: See Single-Target
- var_2: String (The Data ID)
- var_3: Any .lua value (The value to be set)
 
getldata(var_1, var_2)
Gets encounter-persistent data from the target (Lua version)
- Arguments:- var_1: See Single-Target
- var_2: String (The Data ID)
 
clearvalues()
Clears the value of a Modular script
resetadders()
Clears the adders of a Modular script
require("XXXX")
Loads the content of another .lua file in the modular_lua folder. (i.e require("killallzenos")). Act's like normal inheritance.
selecttargets(var_1)
Takes a multi-target selector string and returns an array of selected targets. (i.e ["inst12", "inst34"]). Inst selectors are recognized by Modular, meaning you can pass them into consequence/value acquirers that accept target selectors.
- Arguments:- var_1: See Multi-Target
 
listfiles(var_1)
Lists the files of a given directory. This function does NOT list folders. This function is restricted to the "Plugins" folder and any sub-folders. This function returns a .lua array.
- Arguments:- var_1: Path of the directory (i.e "Lethe")
 
readfile(var_1)
Reads a given files contents. This function is restricted to the "Plugins" folder and any sub-folders. This function returns a .lua string.
- Arguments:- var_1: Path of the file (i.e "Lethe/modularcodesecrets.txt")
 
Math Functions (.lua only)
Refer to this website
LUAMAIN Function
LUAMAIN is a Main Function that lets you trigger a specific LUA function in a lua file
See This Part of the Documentation