aboutsummaryrefslogtreecommitdiff
path: root/tutorials/tut010_first_addon.md
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2017-11-26 21:07:54 -0500
committerAlexander Pickering <alexandermpickering@gmail.com>2017-11-26 21:07:54 -0500
commit83af51534bf16bf048aea1cd3b74a0308ed9dd71 (patch)
treeff82f3e6dd841633b1355b73181bcae607ee1138 /tutorials/tut010_first_addon.md
parent25e4d04a331a6a0b9d897d4f721757730771ff97 (diff)
downloadartery-83af51534bf16bf048aea1cd3b74a0308ed9dd71.tar.gz
artery-83af51534bf16bf048aea1cd3b74a0308ed9dd71.tar.bz2
artery-83af51534bf16bf048aea1cd3b74a0308ed9dd71.zip
Started work on writing tutorials
Wrote tutorials for * Setup * Addon structure * Inventories * Items
Diffstat (limited to 'tutorials/tut010_first_addon.md')
-rw-r--r--tutorials/tut010_first_addon.md31
1 files changed, 31 insertions, 0 deletions
diff --git a/tutorials/tut010_first_addon.md b/tutorials/tut010_first_addon.md
new file mode 100644
index 0000000..d4f8cb1
--- /dev/null
+++ b/tutorials/tut010_first_addon.md
@@ -0,0 +1,31 @@
+# Tut 0x010
+
+## Baby's first addon
+
+A quick primer on addons for Garry's Mod, and Artery.
+
+You may have seen on the gmod wiki, instructions on running lua code. One way is to place files in your `garrysmod/lua/autorun` directory, and they will be run automatically when you enter single player. This can get messy though, another way to run lua is by making a folder in `garrysmod/addons/<addon_name>/lua/autorun`, and placing your scripts in that (i.e. so that `garrysmod/addons/my_first_addon/lua/autorun/hello.lua` is a valid file). As it turns out, all folders under `garrysmod/addons/<addon_name>` get reflected! This means that if you have a file `garrysmod/addons/data/pac3/my_pac.txt` it will appear in the pac editor as a pac you can load!
+
+This is the method used by addons for Artery. Since Garry's Mod loads addons's autorun BEFORE gamemodes, Artery uses the `data/artery/global/` folder to run scripts after the gamemode as loaded (and therefore has access to the nrequire() function, more on this later).
+
+## Lets get started
+
+Start by creating a new folder under `garrysmod/addons/` called `artery_rougelite`. We'll be using this folder for the rest of the tutorials to build a small rougelike gamemode to explore the different features artery provides.
+
+Now create another folder under the folder you just made `garrysmod/addons/artery_rougelite/data`
+
+Now another `garrysmod/addons/artery_rougelite/data/artery/`
+
+And another `garrysmod/addons/artery_rougelite/data/artery/global/`
+
+With the folder structure set up, we're ready to actually write some lua.
+
+Create a file `garrysmod/addons/artery_routelite/data/artery/global/helloworld.txt`
+
+and copy+paste the following code into it.
+
+ print("Hello, world!")
+
+Now start up garrysmod with the Artery gamemode selected. Head into flatgrass or something. Open your console, you should see "Hello, world!" printed.
+
+Next tutorial: @{tut020_nrequire.md}