Reference: The Effect Builder API - ItsVerday/LuckyAPI GitHub Wiki
Luck be a Landlord has an internal effect system which handles things such as symbols adding/boosting/destroying other symbols, or modifying themselves. Admittedly, it took a while for me to wrap my head around this system when working on the modloader. I created the Effect Builder API so that modders don't have to go through the same level of confusion. Essentially, the API allows you to build effects that symbols perform really easily, without needing to know how the game works internally. To get started, you can call the effect() function, which is available in all ModSymbol and SymbolPatcher instances. When passing the result from effect() into functions such as symbol.add_effect(), the symbol will treat it as any other effect. The effect() type has methods to specify conditions and effects. These methods can be chained.
In this reference, persistent data refers to a symbol's data which is saved in the save file. Non-persistent data is lost when the game is closed. If you aren't sure which to use, persistent is probably better.
Remember, if you ever need help with making mods, feel free to join our Discord Server and ask for help!
Conditions
Conditions are exactly that - conditions for the effect to activate. All conditions must succeed for the effect to successfully activate. If there are no conditions on the effect, then it will always activate.
.if_value_random(value_index)
Pulls a value from the symbol's value array, and uses that as a chance to succeed. For example, if the symbol has a value array of [10, 50, 2], and we call .if_value_random(1) on the effect, the effect will have a 50% chance to succeed (on top of all other conditions).
.if_value_at_least(value_index, compare)
Pulls a value from the symbol's value array, and checks if that value is at least the value of compare. If it is, the condition will succeed.
.if_value_equals(value_index, compare)
Pulls a value from the symbol's value array, and checks if that value is equal to the value of compare. If it is, the condition will succeed.
.if_final_value_less_than(compare)
If the symbol's final value is less than compare, then the condition will succeed.
.if_final_value_equals(compare)
If the symbol's final value is equal to compare, then the condition will succeed.
.if_value_bonus_less_than(compare, currency = "coin")
If the symbol's bonus value for the given currency is less than compare, then the condition will succeed.
.if_value_bonus_at_least(compare, currency = "coin")
If the symbol's bonus value for the given currency is at least the value of compare, then the condition will succeed.
.if_value_bonus_equals(compare, currency = "coin")
If the symbol's bonus value for the given currency is exactly the value of compare, then the condition will succeed.
.if_value_multiplier_less_than(compare, currency = "coin")
If the symbol's value multiplier for the given currency is less than compare, then the condition will succeed.
.if_value_multiplier_at_least(compare, currency = "coin")
If the symbol's value multiplier for the given currency is at least the value of compare, then the condition will succeed.
.if_value_multiplier_equals(compare, currency = "coin")
If the symbol's value multiplier for the given currency is exactly the value of compare, then the condition will succeed.
.if_type(symbol_type, not_previous = false)
If the symbol is of the type specified, then the condition will succeed. If not_previous is true, then the previous types of the symbol during the current spin will be ignored.
.if_group(symbol_group, not_previous = false)
If the symbol is in the group specified, then the condition will succeed. If not_previous is true, then the previous groups of the symbol during the current spin will be ignored.
.if_destroyed(compare = true, not_previous = false)
If the symbol's destroyed condition is equal to compare, then the condition will succeed. If not_previous is true, then the previous states of the symbol during the current spin will be ignored.
.if_grid_x(compare)
If the symbol's x position in the symbol grid is equal to compare, then the condition will succeed.
.if_grid_y(compare)
If the symbol's y position in the symbol grid is equal to compare, then the condition will succeed.
.if_has(property, value)
If the symbol's array with name property contains the value value, then the condition will succeed.
.if_not_has(property, value)
If the symbol's array with name property doesn't contain the value value, then the condition will succeed.
.if_property_random(property)
Has a percent chance of succeeding equal to the symbol's property with name property.
.if_property_less_than(property, compare)
If the symbol's property with name property is less than the value of compare, then the condition will succeed.
.if_property_at_least(property, compare)
If the symbol's property with name property is at least the value of compare, then the condition will succeed.
.if_property_equals(property, compare)
If the symbol's property with name property equals the value of compare, then the condition will succeed.
.if_persistent_data_random(key, default = 0)
Has a percent chance of succeeding equal to the symbol's persistent data entry with key key. If the symbol doesn't have a persistent data entry with that key, then it defaults to the value of default.
.if_persistent_data_less_than(key, compare, default = 0)
If the symbol's persistent data entry with key key is less than the value of compare then the condition will succeed. If the symbol doesn't have a persistent data entry with that key, then it defaults to the value of default.
.if_persistent_data_at_least(key, compare, default = 0)
If the symbol's persistent data entry with key key is at least the value of compare then the condition will succeed. If the symbol doesn't have a persistent data entry with that key, then it defaults to the value of default.
.if_persistent_data_equals(key, compare, default = 0)
If the symbol's persistent data entry with key key equals the value of compare then the condition will succeed. If the symbol doesn't have a persistent data entry with that key, then it defaults to the value of default.
.if_non_persistent_data_random(key, default = 0)
Has a percent chance of succeeding equal to the symbol's non-persistent data entry with key key. If the symbol doesn't have a non-persistent data entry with that key, then it defaults to the value of default.
.if_non_persistent_data_less_than(key, compare, default = 0)
If the symbol's non-persistent data entry with key key is less than the value of compare then the condition will succeed. If the symbol doesn't have a non-persistent data entry with that key, then it defaults to the value of default.
.if_non_persistent_data_at_least(key, compare, default = 0)
If the symbol's non-persistent data entry with key key is at least the value of compare then the condition will succeed. If the symbol doesn't have a non-persistent data entry with that key, then it defaults to the value of default.
.if_non_persistent_data_equals(key, compare, default = 0)
If the symbol's non-persistent data entry with key key equals the value of compare then the condition will succeed. If the symbol doesn't have a non-persistent data entry with that key, then it defaults to the value of default.
.negate()
Negates the condition directly before this. In other words, if that condition would succeed, then it actually fails, and vice-versa.
Effects
If an effect's conditions all succeed, then the effect will do something. These methods cause the effect to perform certain actions.
.add_symbol_type(symbol_type)
Adds a symbol to the player's inventory with ID symbol_type.
.add_symbol_group(symbol_group, min_rarity = "common")
Adds a symbol to the player's inventory which is in the group symbol_group. The minimum rarity specifies the minimum rarity of the added symbol.
.add_item_type(item_type)
Adds an item to the player's inventory with ID item_type.
.add_item_rarity(rarity)
Adds an item to the player's inventory of a given rarity.
.change_value_bonus(bonus, currency = "coin", overwrite = false)
Adds a number to the symbol's value bonus. The bonus is in the given currency, and overwrite determines whether the bonus will be overwritten entirely.
.change_value_multiplier(multiplier, currency = "coin", overwrite = false)
Multiplies the symbol's value by multiplier. The multiplier is in the given currency, and overwrite determines whether the bonus will be overwritten entirely.
.change_type(symbol_type)
Changes this symbol's type to symbol_type.
.change_group(group, min_rarity = "common")
Changes this symbol's type to a random symbol in the group group. The rarity is always as least as rare as min_rarity.
.set_destroyed(destroyed = true)
Changes this symbol's destroyed status to destroyed.
.set_drained(drained = true)
Changes this symbol's drained status to drained. The drained status is from the Hex of Draining.
.set_removed()
Marks this symbol as removed.
.set_value(property, value)
Sets this symbol's property named property to value.
.add_to_value(property, difference)
Adds difference to this symbol's property named property.
.multiply_value(property, multiplier)
Multiplies the symbol's property called property by multiplier.
.add_permanent_bonus(bonus)
Adds bonus to this symbol's permanent bonus.
.animate(animation, sfx_type = "default", targets = [])
Animates this symbol with the animation named animation. The targets of this animation are targets. Additionally, the SFX named sfx_type is played for this symbol.
.set_target(target)
Sets the target for this effect.
.set_persistent_data(key, value)
Sets the persistent data entry of the target with key key to value.
.add_to_persistent_data(key, value)
Adds value to the persistent data entry of the target with key key.
.multiply_persistent_data(key, value)
Multiplies the persistent data entry of the target with key key by value.
.set_non_persistent_data(key, value)
Sets the non-persistent data entry of the target with key key to value.
.add_to_non_persistent_data(key, value)
Adds value to the non-persistent data entry of the target with key key.
.multiply_non_persistent_data(key, value)
Multiplies the non-persistent data entry of the target with key key by value.