Skip to content

Commit bf3c664

Browse files
Beautify Text
1 parent 0475ba5 commit bf3c664

File tree

4 files changed

+48
-28
lines changed

4 files changed

+48
-28
lines changed

docs/guides/development/.pages

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
arrange:
22
- developing_schema.md
33
- developing_plugins.md
4+
- plugin_example.md
45
- factions.md

docs/guides/development/developing_plugins.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ There are 2 ways to create a plugin in NutScript:
2020

2121
In your plugin/```sh_plugin.lua``` file, include the following:
2222

23-
```lua
23+
```lua linenums="1"
2424
PLUGIN.name = "Plugin Name"
2525
PLUGIN.author = "You, the Creator"
2626
PLUGIN.desc = "A simple plugin that does something."
@@ -31,15 +31,15 @@ Here you'll need to set your plugin's name, the author, and a short description
3131
## **Hooking**
3232

3333
Normally, to hook a function, you'll need to use the following syntax:
34-
```lua
34+
```lua linenums="1"
3535
hook.Add("Think", "myUniqueFunction", function()
3636
-- Do stuff
3737
end)
3838
```
3939

4040
However, NutScript has a special syntax for hooking functions within plugins.
4141

42-
```lua
42+
```lua linenums="1"
4343
function PLUGIN:Think()
4444
-- Do stuff
4545
end
@@ -54,7 +54,9 @@ Advantages of using PLUGIN:
5454
1. It gives the hooked code priority when executed. Meaning that code added via PLUGIN will run before most code added by addons.
5555

5656
2. It allows you to use code defined by PLUGIN to be run elsewhere in the gamemode.
57-
- For example, if you have a plugin ```permadeath.lua``` that defines a function called ```PLUGIN:PlayerDeath(client, inflictor, attacker)```, and another plugin called ```medical```, you can have a function in the ```medical``` plugin call the ```permadeath``` PlayerDeath hook without running any other code that has been hooked to PlayerDeath, via ```nut.plugin.list.permadeath:PlayerDeath(client, inflictor, attacker)```.
57+
58+
!!! example
59+
If you have a plugin ```permadeath.lua``` that defines a function called ```PLUGIN:PlayerDeath(client, inflictor, attacker)```, and another plugin called ```medical```, you can have a function in the ```medical``` plugin call the ```permadeath``` PlayerDeath hook without running any other code that has been hooked to PlayerDeath, via ```nut.plugin.list.permadeath:PlayerDeath(client, inflictor, attacker)```.
5860

5961
3. It allows to store variables specific to the plugin.
6062
- For example
@@ -74,6 +76,7 @@ Advantages of using PLUGIN:
7476
is a table that is available (within the respective realm) to all files/scopes within the plugin, as well as accessible from other plugins (```nut.plugin.list.permadeath.curEnts```).
7577
## **Example**
7678

77-
An example of a plugin creation can be found [here](../development%20examples/Plugin%20Example.md).
79+
An example of a plugin creation can be found [here](plugin_example.md).
7880

79-
_**It is recommended that you use plugins as puzzle pieces that fit into your gamemode. Creating plugins not only makes it easier to develop and enhance sections of your gamemode, your schema will remain organized as it gets larger.**_
81+
!!! tip
82+
It is recommended that you use plugins as puzzle pieces that fit into your gamemode. Creating plugins not only makes it easier to develop and enhance sections of your gamemode, your schema will remain organized as it gets larger.

docs/guides/development/developing_schema.md

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Make sure that you have the [Nutscript framework](https://github.com/NutScript/NutScript) already installed in the gamemodes folder (rename it to ```nutscript```).
66
In the same gamemodes plugin, place/create your schema folder, and name it as the name of your schema (hl2rp/cityrp/scprp)
7-
![Example](https://i.imgur.com/bKgG8L0.png)
7+
![Example](/assets/develop_schema_img.png)
88

99
## **The Main Schema Folder**
1010

@@ -16,7 +16,9 @@ Within the Schema folder, you must have 3 additional folders:
1616

1717
and one .txt file named identically to your schema name (that is, if your schema is called hl2rp, the txt must also be called hl2rp.txt)
1818

19-
_**As a Rule of Thumb, you should not modify the gamemode folder at any point. Please look at [pre-existing schemas](installation/Getting_Started.md#Schemas) and copy the gamemode folder from there.**_
19+
!!! warning
20+
21+
_**As a Rule of Thumb, you should not modify the gamemode folder at any point. Please look at [pre-existing schemas](installation/Getting_Started.md#Schemas) and copy the gamemode folder from there.**_
2022

2123
* The ```plugins``` folder is used to install additional plugins to the schema.
2224

@@ -30,17 +32,19 @@ Within the ```schema``` folder, you must have 2 crucial folders: ```items``` and
3032

3133
The ```factions``` folder is used to create new factions playable on your gamemode. Each faction is represented by their individual file.
3234

33-
For example, if you want to have 3 factions called "Citizen", "Police" and "Insurgents", you would have 3 files within the factions folder
3435

35-
```
36-
sh_citizen.lua
37-
sh_police.lua
38-
sh_insurgents.lua
39-
```
36+
!!! example
37+
38+
For example, if you want to have 3 factions called "Citizen", "Police" and "Insurgents", you would have 3 files within the factions folder
39+
```
40+
sh_citizen.lua
41+
sh_police.lua
42+
sh_insurgents.lua
43+
```
4044

4145
Each file must contain the following code:
4246

43-
```lua
47+
```lua linenums="1"
4448
FACTION.name = "Custom Faction" -- the name of your faction as it appears in-game
4549
FACTION.desc = "Custom faction for only some people to use." -- the faction's description, as seen in the character creation screen
4650
FACTION.color = Color(255, 0, 0) -- the faction's color, as it appears in the scoreboard
@@ -61,7 +65,9 @@ FACTION.models = { -- default models available to the faction. The larger the li
6165
FACTION_CUSTOM = FACTION.index -- mandatory, this allows the faction to be indexed in code elsewhere. Replace FACTION_CUSTOM with FACTION_#### where #### is a unique string for your faction.
6266
```
6367

64-
[More information and options available for factions is available here.](development/Factions.md)
68+
!!! note
69+
70+
[More information and options available for factions is available here.](factions.md)
6571

6672
## **The Items Folder**
6773

@@ -73,9 +79,9 @@ There are 2 methods to adding items to your schema: single file items or via a b
7379

7480
You can add an item as a single file by creating one in the ```items``` folder directly. For example, if you want to create a potato item, you would create a new file called ```sh_potato.lua```
7581

76-
Inside the file, you must have this code
82+
Inside the file, you must have this code:
7783

78-
```lua
84+
```lua linenums="1"
7985
ITEM.name = "A Potato" -- item name
8086
ITEM.desc = "Boil em, Mash em, Stick em in a stew." -- item description
8187
ITEM.price = 0 -- the default price, used by vendors and business tabs, for instance
@@ -86,9 +92,9 @@ ITEM.uniqueID = "potato" -- optional field, used for ease of reference in code
8692
ITEM.health = 10
8793
```
8894

89-
If you want your items to have functionality, you may add functions via ```ITEM.functions.<name>```. For example
95+
If you want your items to have functionality, you may add functions via ```ITEM.functions.<name>```. For example:
9096

91-
```lua
97+
```lua linenums="1"
9298
ITEM.functions.use = {
9399
name = "Consume", --Name of the function, if this doesn't exist it'll use "use"
94100
tip = "Consume the item.", --Tip when hovering over the function
@@ -113,13 +119,17 @@ base
113119
food
114120
```
115121

116-
Inside the base folder, create a lua file called the same as the target base folder (for instance if I am creating a food item base, I would create a file called ```sh_food.lua```)
122+
Inside the base folder, create a lua file called the same as the target base folder
123+
124+
!!! example
125+
126+
For instance, if I am creating a food item base, I would create a file called ```sh_food.lua```
117127

118128
Inside this new file goes the default information of the item. Items defined within the target base folder will inherit all the values and functions from this base file.
119129

120130
Let's create a food base
121131

122-
```lua
132+
```lua linenums="1"
123133
ITEM.name = "Food Base"
124134
ITEM.model = "models/Gibs/HGIBS.mdl"
125135
ITEM.desc = "Tasty food, or tasy drink."
@@ -149,7 +159,7 @@ Now, in the food folder, we can create as many different food items as we please
149159

150160
In the food folder, I will create a milk item. Call it ```sh_milk.lua```
151161

152-
```lua
162+
```lua linenums="1"
153163
ITEM.name = "Milk"
154164
ITEM.model = "models/Gibs/HGIBS.mdl"
155165
ITEM.desc = "Full fat cow's milk."
@@ -167,7 +177,7 @@ If you want multiple bases, create individual files in the base folder, and a ne
167177

168178
The sh_schema.lua file is a crucial part of the schema. Upon creating it, enter the following code:
169179

170-
```lua
180+
```lua linenums="1"
171181
SCHEMA.name = "Cool Schema" -- the Name of your Schema, as it appears in-game
172182
SCHEMA.author = "You" -- the Author of the schema
173183
SCHEMA.desc = "A schema for the people to learn from." -- A brief description of what the gamemode is about
@@ -183,10 +193,14 @@ nut.util.include("sh_commands.lua") -- this allows code within the sh_commands.l
183193
nut.util.includeDir("hooks") -- this allows all files within the hooks folder in the schema folder to be readable by the schema
184194
```
185195

186-
**Keep in mind that if you try to use functions or variables defined in these external files before they are included in the schema, they will not be available.**
196+
!!! warning
197+
198+
Keep in mind that if you try to use functions or variables defined in these external files before they are included in the schema, they will not be available.
199+
200+
!!! note
187201

188-
Keep in mind that if you want to add folders that are default to nutscript, such as ```classes, meta``` or ```libs```, it is not necessary to include them.
202+
Keep in mind that if you want to add folders that are default to nutscript, such as ```classes, meta``` or ```libs```, it is not necessary to include them.
189203

190204
## **Developing Plugins**
191205

192-
If you wish to create your own plugins, in order to keep the schema modular and organized, head over to [Developing Plugins](Developing%20Plugins.md).
206+
If you wish to create your own plugins, in order to keep the schema modular and organized, head over to [Developing Plugins](developing_plugins.md).

docs/guides/installation/getting_started.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ There are currently 3 versions of the NutScript framework available:
1313
3. [NutScript 1.0](https://github.com/Chessnut/NutScript/tree/1.0)
1414
- Legacy, original version of NutScript. It is not recommended to use this version.
1515

16-
There also exists the [NutScript 1.1-beta](https://github.com/rebel1324/NutScript/tree/1.1-beta) version, however, it is simply Version 1.2 in early stages of development. As such, any plugin that is made for 1.1-beta is fully compatible with 1.2 (but not 1.1 or 1.0).
16+
17+
??? note "NutScript 1.2 vs NutScript 1.1-beta"
18+
There also exists the [NutScript 1.1-beta](https://github.com/rebel1324/NutScript/tree/1.1-beta) version, however, it is simply Version 1.2 in early stages of development. As such, any plugin that is made for 1.1-beta is fully compatible with 1.2 (but not 1.1 or 1.0).
1719

1820
### Schemas
1921

0 commit comments

Comments
 (0)