Skip to content

Commit 249f110

Browse files
Add description of macros and symlinks. (#559)
* Added section to macros guide describing symlinks. Wording? * Applied sean's patch. * Windows instructions * rm -fn --------- Co-authored-by: Sean Mann <sean@comcode.org>
1 parent eafca01 commit 249f110

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

docs/guides/new_players/macros.mdx

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,68 @@ To delete an existing macro, type `/macro =` with nothing after the `=`.
4848
>>/bal =
4949
Macro deleted.
5050
```
51+
52+
## Macro storage on disk
53+
54+
### What's a macro file?
55+
56+
Macros in hackmud are stored in a file per user, which is located in the same place as `shell.txt`.
57+
58+
> Run ((%C#dir%)) and go two folders up. Or navigate to:
59+
>
60+
> > Windows - `C:\Users\USERNAME\AppData\Roaming\hackmud`\
61+
> > macOS - `~/.config/hackmud`\
62+
> > Linux - Either `~/.config/hackmud` or the game folder.
63+
64+
The naming scheme is `username.macros`, and are plain text files.
65+
66+
### Workaround: Sharing macros between users
67+
68+
Because macros are scoped to users by default, when you switch to another user, you can't use the first user's macros.
69+
70+
One of the ways you can solve this is with the concept of a symlink: https://en.wikipedia.org/wiki/Symbolic_link
71+
72+
By adding a symlink to a source file for macros, each user would be editing and reading from the same file, allowing macros to be shared between users.
73+
74+
:::warning
75+
When mucking with files always back them up before accidentally doing destructive actions.
76+
:::
77+
78+
#### How to set up a symlink on Windows
79+
80+
Windows 10 and later have access to `mklink`: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mklink
81+
82+
Here's an example of mapping / copying macros from user_a's macros to user_b's macros.
83+
84+
:::note
85+
Running mklink requires a windows command prompt which has been started with administrator permissions.
86+
:::
87+
88+
```
89+
USAGE:
90+
mklink abs_path_to_new_link_file file_path_to_link_to
91+
92+
COMMAND:
93+
mklink "C:\Users\southr6\AppData\Roaming\hackmud\user_b.macros" "C:\Users\southr6\AppData\Roaming\hackmud\user_a.macros"
94+
```
95+
96+
#### How to set up a symlink on macOS & linux
97+
98+
To make a symlink these unix-based platforms, we're going to use the `ln` command.
99+
100+
:::note
101+
Syntax may differ depending on your OS, check `man ln` for usage differences.
102+
Also note, the parameters are in different orders in windows and unix.
103+
:::
104+
105+
We want to run `ln` with the `-s` options, with the source file being the path to the file containing the macros, and the target file being the path to the `username.macros` in the previously mentioned directory.
106+
107+
For example on macOS, my ln usage and command looked like this:
108+
109+
```
110+
USAGE:
111+
ln [options] source_file new_link_file
112+
113+
COMMAND:
114+
ln -s ~/Developer/hackmud/southr6/workshop/macros.txt ~/.config/hackmud/southr6.macros
115+
```

0 commit comments

Comments
 (0)