Skip to content

Commit e3ebf38

Browse files
Docs Reformatting (#38)
* Document everything missing from `lsp_def/utils.lua` + misc edits * Partial `Blind:calculate` docs + other stuff I missed Actual specifics are better suited for the rewritten calculation docs. * Default mod functions update Not very good, but this page is getting rewritten anyways. It'll work for now. * forgot about `optional_features` * Slightly improves `SMODS.Booster` docs * Slight correction * W.I.P internal doc page * "The Mod Object" page + misc stuff * Add links to header elements on some pages * Update API-Documentation.md format * Move install guide, TODO home page rewrite, add missing nav on pages * Add missing util functions * Update to current wiki proper * SMODS.https header + update Internal & Utility * Apply #48 style changes
1 parent 8d4fc57 commit e3ebf38

20 files changed

+705
-339
lines changed

API-Documentation.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
11
# API Documentation
2-
## General remarks
2+
3+
- [General Remarks](#general-remarks)
4+
- [Creating an Object](#creating-an-object)
5+
- [Common Parameters](#common-parameters)
6+
- [`name`](#name)
7+
- [`loc_txt`](#loc_txt)
8+
- [`unlocked`](#unlocked)
9+
- [`discovered`](#discovered)
10+
- [`no_collection`](#no_collection)
11+
- [`config`](#config)
12+
- [`prefix_config`](#prefix_config)
13+
- [`dependencies`](#dependencies)
14+
- [`display_size`](#display_size)
15+
- [`pixel_size`](#pixel_size)
16+
- [Taking Ownership](#taking-ownership)
17+
- [API Functions](#api-functions)
18+
19+
***
20+
21+
## General Remarks
322
All Steamodded APIs are built on an Object Oriented Programming engine. As such, Steamodded objects share some common methods and parameters, described below.
4-
## Creating an object
23+
## Creating an Object
524
Create an object by calling a class, for example `SMODS.Joker`, with a single table parameter. Each class may have required fields and may provide some default values.
625

726
Your table must have a `key` field, which must be a unique string. Don't worry about collisions with other mods—your mod's prefix will always be prepended to `key`. With a few exceptions, you don't have to worry about this.
@@ -16,7 +35,7 @@ SMODS.Class {
1635
}
1736
```
1837

19-
## Common parameters
38+
## Common Parameters
2039
### `name`
2140
Used by the game to identify certain objects, but Steamodded doesn't use it at all. You can ignore it.
2241

@@ -81,7 +100,7 @@ Changes the display size of cards by scaling them by a factor relative to pixel
81100
### `pixel_size`
82101
Changes how large the sprite of this card is considered, useful for smaller sprites like Half Joker (default: `{ w = 71, h = 95 }`).
83102

84-
## Taking ownership
103+
## Taking Ownership
85104
You may need to modify vanilla objects or objects from another mod. Use the `take_ownership` function to modify an existing object; then, you can use all of Steamodded's API functions on it. Each key-value pair of the provided table overwrites the object's value, while the rest of the object is left intact. Objects you take ownership of have your mod's badge added to them, unless you suppress this with the `silent` argument.
86105
```lua
87106
SMODS.Joker:take_ownership('joker', -- object key (class prefix not required)
@@ -95,7 +114,7 @@ SMODS.Joker:take_ownership('joker', -- object key (class prefix not required)
95114
)
96115
```
97116

98-
## API functions
117+
## API Functions
99118
Each class's API functions are explained on that class's Wiki page. The following lists parameter names common to these API functions.
100119
| Identifier | Meaning |
101120
| :--------- | :--------- |

Calculate-Functions.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,15 @@ return {
3737
}
3838
```
3939
There are a range of different keys that you can return in this table.
40-
- `chips`,`mult`,`xmult`, `dollars` - scores these values *(automatically adds a message to the card that is being scored)*
40+
- `chips`,`mult`,`xchips`, `xmult`, `dollars` - scores these values *(automatically adds a message to the card that is being scored)*
4141
- `swap` - swaps current chips and mult values with each other
4242
- `level_up` - levels up the played hand by the number returned
4343
- `saved` - used during `context.end_of_round` to prevent game over
4444
- `message` - used to return a custom message
4545
- will automatically be put on the scored card unless `message_card` is also returned
4646
- colour of message background will be `G.C.FILTER` unless `colour` is returned
4747
- sound will be `generic1` unless `sound` is returned
48+
- `balance` - Balances chips and mult (akin to Plasma Deck)
4849
- `func` - return a function to be called at the correct timing *(advanced)*
4950
- `extra` - an extra table set out the same as this one *(advanced)*
5051

@@ -93,6 +94,14 @@ calculate = function(self, card, context)
9394
> (`context` is NOT constant. It could change later and cause you
9495
> to reference an unrelated value.)
9596
97+
### Additional Functions
98+
These are helper functions that can be used during calculation events.
99+
100+
- `SMODS.calculate_effect(effect, scored_card, from_edition)`
101+
- Handles triggering a table of events. Unlike the return table, this will evaluate and trigger effect when called.
102+
- `effect` - Table of effects. This is akin to the table you'd return in `calculate` functions
103+
- `scored_card` - Card or object to juice up during animations.
104+
96105
## Contexts
97106
Detailed here is a list of all contexts that are sent to calculate functions, as well as a unique identifier to use to reference them. As each context is sent to different areas, use the following logic statement to make sure you are calculating in the intended area.
98107
```lua

Home.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
# Welcome to the Steamodded wiki!
23
The place serves as an assembly of documentation and guides for Steamodded, also known as smods. It explains how to install mods, has documentation on internal game objects, and has multiple guides on how to create mods.
34

@@ -12,4 +13,4 @@ If you'd like to install and play with mods on Linux, please follow the linux tu
1213
If you'd like to install and play with mods on Mac, please follow the mac tutorial [here](https://github.com/Steamodded/smods/wiki/Installing-Steamodded-mac).
1314

1415
## I want to make new mods
15-
If you're planning to create your own mods using steamodded, please follow the tutorial [here](https://github.com/Steamodded/smods/wiki/Your-First-Mod).
16+
If you're planning to create your own mods using steamodded, please follow the tutorial [here](https://github.com/Steamodded/smods/wiki/Your-First-Mod).

Internal-Documentation.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Internal Documentation
2+
SMODS has internal functions that are used for loading mods, creating and handling GameObjects, and general backend operations. Mods may be interested in using or modifying these functions.
3+
4+
- [Injection](#injection)
5+
- [Calculation](#calculation)
6+
- [Misc.](#misc)
7+
8+
***
9+
10+
## Injection
11+
These are functions used during the injection process of mods or GameObjects.
12+
#### `SMODS.save_d_u(o)`
13+
Saves the default discovery and unlock states of an object into a separate field for later use before they are overwritten with profile data.
14+
#### `SMODS.SAVE_UNLOCKS()`
15+
Modified from base game code. Sets discovery and unlock data according to profile state after injection.
16+
#### `SMODS.process_loc_text(ref_table, ref_value, loc_txt, key)`
17+
Saves a localization entry (usually consisting of a name and a description) into the game's dictionary, with the ability to handle a multi-language format. The `loc_txt` table should either have locale indexing at the top layer or none at all. If the table holds multiple entries, `key` can be used to choose a key one layer down.
18+
- Example: `SMODS.process_loc_text(G.localization.descriptions.Joker, 'my_joker_key', loc_txt)`
19+
#### `SMODS.handle_loc_file(path)`
20+
Given a mod's path, reads any present localization files and adds entries to the dictionary.
21+
#### `SMODS.modify_key(obj, prefix, condition, key)`
22+
Modifies a string within the object to include provided `prefix`.
23+
#### `SMODS.add_prefixes(cls, obj, from_take_ownership)`
24+
Injects prefixes into the object. This includes the `key` of the object and any tables expecting keys of objects (e.x. `applied_stakes`).
25+
#### `SMODS.insert_pool(pool, center, replace)`
26+
If `replace` is true or `center` has been taken ownership of, look for an entry in `pool` with the same key and replace it. Otherwise, append `center` to the end of `pool`.
27+
#### `SMODS.remove_pool(pool, key)`
28+
Find an entry in pool with this `key` and remove it if found.
29+
#### `SMODS.create_loc_dump()`
30+
Dumps localization entries created during injection into a single file, for purposes of converting to a file-based localization system.
31+
#### `SMODS.create_mod_badges(obj, badges)`
32+
UI code for adding mod badges to an object.
33+
#### `SMODS.merge_defaults(t, defaults) -> t?`
34+
Starting with `t`, insert any key-value pairs from `defaults` that don't already exist in `t` into `t`. Modifies `t` and returns it as the result of the merge.
35+
- `nil` entries are interpreted as an empty table; `false` inputs count as a table where every possible key maps to `false`. Therefore, `t == nil` is weak and falls back to defaults, while `t == false` explicitly ignores `defaults` in its entirety. Due to this, this function may not always return a table.
36+
- This is used for controlling when keys should receive prefixes.
37+
#### `convert_save_data()`
38+
Adjusts values in save data to make the save compatible with Steamodded's way of storing deck wins by stake key instead of index.
39+
#### `SMODS.restart_game()`
40+
Restarts the game.
41+
#### `SMODS.get_optional_features()`
42+
Inserts all enabled optional features by injected mods into the `SMODS.optional_features` table.
43+
#### `SMODS.localize_box(lines, args)`
44+
Handles localizing description boxes within a localization entry.
45+
46+
## Calculation
47+
These functions are used for handling calculation events.
48+
#### `SMODS.calculate_context(context, return_table) -> table?`
49+
Main function used to calculate effects on cards for the provided `context` over a majority of CardAreas.
50+
- If `return_table` is provided, the function will not return a table and instead put all the calculation returns into
51+
- Mods can hook this function to add extra CardAreas.
52+
#### `SMODS.calculate_card_areas(_type, context, return_table, args) -> table`
53+
Calculates effects on cards for a specific group of CardAreas based on `_type`.
54+
#### `SMODS.score_card(card, context)`
55+
Scores the provided `card`.
56+
#### `SMODS.calculate_main_scoring(context, scoring_hand)`
57+
Handles the main scoring hand calculation event.
58+
- `scoring_hand` - Uses this table of cards if provided, else it looks through `context.cardarea.cards` for if any of them are inside of `context.scoring_hand`.
59+
#### `SMODS.calculate_end_of_round_effects(context)`
60+
Handles the end of round calculation event.
61+
#### `SMODS.calculate_destroying_cards(context, cards_destroyed, scoring_hand)`
62+
Handles the card destroy calculation event.
63+
- `scoring_hand` - Uses this table of cards if provided, else it looks through `context.cardarea.cards` for if any of them are inside of `context.scoring_hand`.
64+
#### `SMODS.calculate_individual_effect(effect, scored_card, key, amount, from_edition)`
65+
Used to trigger a calculation effect based on provided `key`.
66+
#### `SMODS.calculate_effect_table_key(effect_table, key, card, ret)`
67+
Triggers one key of an effect table returned from `eval_card`.
68+
#### `SMODS.trigger_effects(effects, card)`
69+
Used to calculate a table of effects generated in `G.FUNCS.evaluate_play`.
70+
#### `SMODS.get_card_areas(_type, _context) -> table`
71+
Returns a table of CardAreas based on the provided `_type` and `_context`. Can be hooked or injected into to add your own CardAreas.
72+
- Possible values of `_type`:
73+
- `"playing_cards"` - Playing card evaluation.
74+
- Default CardAreas are `G.hand`, `G.play` (if `_context` is not `"end_of_round"`), `G.deck` (if the "Deck Calculation" feature is enabled), and `G.discard` (if the "Discard Calculation" feature is enabled).
75+
- `"jokers"` - Joker evaluation.
76+
- Default CardAreas are `G.jokers`, `G.consumeables`, and `G.vouchers`.
77+
- `"individual"` - Individual object evaluation.
78+
- Unlike above, this does not return CardAreas and instead returns tables with an `object` and `scored_card` field. `object` if the object that will have the `calculate` function called on, and `scored_card` is the card/object used for animation.
79+
- Default objects are the selected Back and the selected Blind.
80+
- `_context` - Optional string to indicate extra information about the context.
81+
#### `SMODS.calculate_retriggers(card, context, _ret) -> table`
82+
Calculates the retriggers on a Joker. Requires the "Joker Retrigger" feature to be enabled.
83+
#### `SMODS.calculate_repetitions(card, context, reps)`
84+
Calculates the repetitions on a playing card.
85+
#### `SMODS.get_enhancements(card, extra_only) -> table<key, true>`
86+
Returns a table of key-bool pairs, the keys being the enhancements this card counts as having.
87+
- If the "Quantum Enhancement" feature is not enabled, this function will only return the card's current enhancement.
88+
- `extra_only` - The returned table will exclude the card's current enhancement.
89+
#### `SMODS.calculate_quantum_enhancements(card, effects, context)`
90+
Calculates quantum enhancements. Requires the "Quantum Enhancements" feature to be enabled.
91+
#### `SMODS.shatters(card) -> bool`
92+
Returns true if the card should be shattered.
93+
#### `SMODS.in_scoring(card, scoring_hand) -> bool`
94+
Returns true if the card is within the scoring hand.
95+
#### `SMODS.push_to_context_stack(context, func)`
96+
Pushes `context` into `SMODS.context_stack`.
97+
#### `SMODS.pop_from_context_stack(context, func)`
98+
Pops a `context` from `SMODS.context_stack`.
99+
#### `SMODS.get_previous_context()`
100+
Returns the second to last context from `SMODS.context_stack`
101+
102+
## Misc.
103+
These are functions used by SMODS for miscellaneous features.
104+
#### `SMODS.signed(val) -> string`
105+
Returned a signed string of `val`, prefixed with "+" if positive.
106+
#### `SMODS.signed_dollars(val) -> string`
107+
Returned a signed string of `val` as dollars, prefixed with "$" if positive and "-$" if negative.
108+
#### `SMODS.multiplicative_stacking(base, perma) -> number`
109+
Returns the result of multiplying `base` and `perma + 1`.
110+
#### `SMODS.add_to_pool(prototype_obj, args) -> bool?, table?`
111+
Helper function to check if an object can be added into a pool,
112+
- If `prototype_obj.in_pool` is defined, returns the result of `in_pool`, otherwise returns `false`.

Localization.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
# Localization
22
Steamodded offers multiple ways to load strings for in-game descriptions and other labels into the game. This page offers an overview of each option and when you should use them.
33

4-
## Localization files (recommended)
4+
- [Localization Files](#localization-files-recommended)
5+
- [Adding your descriptions](#adding-your-descriptions)
6+
- [`loc_txt`](#loc_txt)
7+
- [`mod.process.loc_text`](#modprocessloc_text)
8+
- [Text Formatting](#text-formatting)
9+
- [Localization Functions](#localization-functions)
10+
- [`loc_vars`](#loc_vars)
11+
- [`locked_loc_vars`](#locked_loc_vars)
12+
- [`generate_ui`](#generate_ui-advanced)
13+
14+
***
15+
16+
## Localization Files (recommended)
517
This method follows the ways of the base game: instead of attaching descriptions directly to each object, all localization strings for the same language are combined into one file. Each such file should be found in the location `localization/<locale>.lua` relative to your mod's root directory. `<locale>` can be the key of any language found in Balatro itself or added through [SMODS.Language](https://github.com/Steamodded/smods/wiki/SMODS.Language).
618

719
- `default`: Used as a fallback when no text was found for the selected language.
@@ -167,7 +179,7 @@ SMODS.current_mod.process_loc_text = function()
167179
end
168180
```
169181

170-
# Text formatting
182+
# Text Formatting
171183
```lua
172184
{
173185
name = 'Example name',
@@ -183,7 +195,7 @@ end
183195
}
184196
```
185197

186-
# Localization functions
198+
# Localization Functions
187199
To create dynamic descriptions, you need to create functions that define how they behave.
188200
## `loc_vars`
189201
`loc_vars` functions are a simple to use but versatile tool for any type of description.

Logging.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
11
# Logging
22

3+
- [Log Levels](#log-levels)
4+
- [Viewing Logs](#viewing-logs)
5+
- [Logging Usage](#logging-usage)
6+
- [Trace](#trace)
7+
- [Lua](#lua)
8+
- [Output](#output)
9+
- [Debug](#debug)
10+
- [Lua](#lua-1)
11+
- [Output](#output-1)
12+
- [Info](#info)
13+
- [Lua](#lua-2)
14+
- [Output](#output-2)
15+
- [Warn](#warn)
16+
- [Lua](#lua-3)
17+
- [Output](#output-3)
18+
- [Error](#error)
19+
- [Lua](#lua-4)
20+
- [Output](#output-4)
21+
- [Fatal](#fatal)
22+
- [Lua](#lua-5)
23+
- [Output](#output-5)
24+
- [Additional Notes](#additional-notes)
25+
- [Debug Console](#debug-console)
26+
- [Opening the Debug Console](#opening-the-debug-console)
27+
- [Using the Debug Console](#using-the-debug-console)
28+
- [CLI Args](#cli-args)
29+
- [Features](#features)
30+
- [Shortcuts](#shortcuts)
31+
- [Issues](#issues)
32+
33+
***
34+
35+
## Log Levels
336
Steamodded implements 6 levels of logging, each with a different purpose. The levels are as follows:
437

538
- `TRACE`: Very detailed information, typically of interest only when diagnosing problems.
@@ -26,7 +59,7 @@ There a few different methods of viewing logs, with their own pros and cons. Bel
2659
- To get logs, you need to launch the console before launching the game.
2760
- This method does not work when using `print` to log, unlike the other methods listed.
2861

29-
## Logging usage
62+
## Logging Usage
3063

3164
All logging functions follow the same pattern, with the first argument being the message, and the second argument being
3265
the logger name. This argument order is consistent across all logging functions. The logger name is optional and will
@@ -116,7 +149,7 @@ sendFatalMessage("This is a fatal message", "MyFatalLogger")
116149
2024-04-04 22:58:45 :: FATAL :: MyFatalLogger :: This is a fatal message
117150
```
118151

119-
### Additional notes
152+
### Additional Notes
120153

121154
A logger name can be any string, but it is recommended to use a descriptive name to make it easier to identify where
122155
the log message is coming from.

0 commit comments

Comments
 (0)