You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: mods/dependencies.md
+19-1Lines changed: 19 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ description: How to install dependencies to Geode mods
6
6
7
7
Geode provides utilities for mods to depend on other mods, to make sharing code easy.
8
8
9
-
Note that Geode **only manages dependencies that are mods**. Normal C++ dependencies, like a JSON parsing library, ZIP library, or some networking utilities, **should just be installed like they are in any other C++ project**. Use CPM, Git submodules, copy the code to your project, whatever you prefer. If the library is dynamic, include the `.dll` with your mod through the `files` key in `resources`.
9
+
Note that Geode **only manages dependencies that are mods**. Normal C++ dependencies, like a JSON parsing library, ZIP library, or some networking utilities, **should just be installed like they are in any other C++ project**. Use CPM, Git submodules, copy the code to your project, whatever you prefer. If the library is dynamic, include the `.dll` with your mod through the `files` key in `resources`.
10
10
11
11
However, sometimes you want to depend on code that can't just be used as a normal library; for example, **custom keybinds**. Geode does not provide any custom keybinds utilities out-of-the-box, so you need to use a library. However, it would not make much sense if every mod bundled their own incompatible systems for dealing with custom keybinds. Instead, there should be one mod that just adds the functionality, and then other mods can depend on that mod and call its functions to add keybinds.
12
12
@@ -160,6 +160,9 @@ Two versions of the macro are available:
160
160
#pragma once
161
161
162
162
#include<Geode/loader/Dispatch.hpp>
163
+
#ifdef MY_MOD_ID
164
+
#undef MY_MOD_ID
165
+
#endif
163
166
// You must **manually** declare the mod id, as macros like GEODE_MOD_ID will not
164
167
// behave correctly to other mods using your api.
165
168
#defineMY_MOD_ID "dev.my-api"
@@ -168,6 +171,13 @@ namespace api {
168
171
// Important: The function must be declared inline, and return a geode::Result,
169
172
// as it can fail if the api is not available.
170
173
inline geode::Result<int> addNumbers(int a, int b) GEODE_EVENT_EXPORT(&addNumbers, (a, b));
174
+
175
+
// Alternatively, use the `_NORES` variant of the macro, which will return a default value
176
+
// if the api isn't available. Ex: this will return 0 if the mod is unavailable
177
+
inline int factorial(int x) GEODE_EVENT_EXPORT_NORES(&factorial, (x));
0 commit comments