update docs

This commit is contained in:
Evil Factory
2022-04-19 22:54:34 -03:00
parent 7a440e009b
commit 928428cabd
29 changed files with 1209 additions and 991 deletions
+3 -2
View File
@@ -67,12 +67,12 @@ local prefab = ItemPrefab.GetItemPrefab("screwdriver")
local firstPlayerCharacter = Client.ClientList[1].Character
-- Spawn on the world
Entity.Spawner.AddToSpawnQueue(prefab, firstPlayerCharacter.WorldPosition, nil, nil, function(item)
Entity.Spawner.AddItemToSpawnQueue(prefab, firstPlayerCharacter.WorldPosition, nil, nil, function(item)
print(item.Name .. " Has been spawned.")
end)
-- Spawn inside an inventory
Entity.Spawner.AddToSpawnQueue(prefab, firstPlayerCharacter.Inventory, nil, nil, function(item)
Entity.Spawner.AddItemToSpawnQueue(prefab, firstPlayerCharacter.Inventory, nil, nil, function(item)
print(item.Name .. " Has been spawned.")
end)
```
@@ -104,5 +104,6 @@ print(char.CharacterHealth.GetAffliction("burn", char.AnimController.Limbs[1]))
```
local chatMessage = ChatMessage.Create("Sender name", "text here", ChatMessageType.MessageBox, nil, nil)
chatMessage.Color = Color(255, 255, 0, 255)
Game.SendDirectChatMessage(chatMessage, ChatMessageType.MessageBox)
```
+13
View File
@@ -10,6 +10,19 @@ When creating a new Lua mod, you will need to create a new folder on the **Mods*
Now you can open **test.lua** in your favorite text editor (<a href="https://code.visualstudio.com/" target="_blank">VSCode</a> with the <a href="https://marketplace.visualstudio.com/items?itemName=sumneko.lua" target="_blank">Lua Sumneko extension</a> recommended) and type in **print("Hello, world")**, now start the server by hosting a game or running the server executable manually, you will see in your console a text appear with the text that you entered in print, you can now type in the server console `reloadlua`, this will re-execute all the Lua scripts. You can also type in `lua yourscript` to run a short lua snippet, like this `lua print('Hello, world')`, remember to remove double quotes, because Barotrauma console automatically formats those.
## Including other files
If you wish to separate your Lua scripts into multiple files, you can do it by either having multiple scripts in the Autorun folder, or having a single script that is responsible for executing the rest of your Lua scripts, for that you will need to get relative paths to your mod, here's an example of how to do it:
```lua
-- this variable will be accessible to any other script, so you can use it to get the mod's path.
MyModGlobal = {}
MyModGlobal.Path = table.pack(...)[1]
dofile(MyModGlobal.Path .. "/Lua/yourscript.lua")
```
## Learning the libraries
In the sidebar of the documentation, you can see a tab named Code, in there you can check out all the functions and fields that each class has, each one of them has a box with a color on it, where <span class="realm server"></span> means Server-Side, <span class="realm client"></span> means Client-Side and <span class="realm shared"></span> means both Server-Side and Client-Side, by clicking on them you can learn more about them. Not everything is documented here, theres stuff missing that still needs to be added, if you want to find more in-depth functions and fields in the Barotrauma classes, you should check the Barotrauma source code.
@@ -1,21 +1,30 @@
# Installing Lua For Barotrauma Manually
### Notice: Using the LuaForBarotrauma package is not required if it's installed manually, but you may use it anyway if you wish to support the mod, since players automatically download packages when joining the server.
## Adding Lua For Barotrauma to an existing server
1 - Download [latest version of LuaForBarotrauma](https://github.com/evilfactory/Barotrauma-lua-attempt/releases/tag/latest), choose the correct platform in the assets drop down.<br>
2 - Extract the zip file<br>
3 - Copy the following files inside the extracted zip:<br>
- **DedicatedServer.deps.json**
- **DedicatedServer.dll**
- **DedicatedServer.pdb**
- **0Harmony.dll**
- **MoonSharp.Interpreter.dll**
- **DedicatedServer.deps.json**
- **DedicatedServer.dll**
- **DedicatedServer.pdb**
- **0Harmony.dll**
- **MoonSharp.Interpreter.dll**
- **MonoMod.Common.dll**
- **Mono.Cecil.dll**
- **Mono.Cecil.Mdb.dll**
- **Mono.Cecil.Pdb.dll**
- **Mono.Cecil.Rocks.dll**
- file that starts with **mscordaccore_amd64_amd64_**
- **Microsoft.CodeAnalysis.CSharp.Scripting.dll**
- **Microsoft.CodeAnalysis.CSharp.dll**
- **Microsoft.CodeAnalysis.dll**
- **Microsoft.CodeAnalysis.Scripting.dll**
- **System.Collections.Immutable.dll**
- **System.Reflection.Metadata.dll**
- **System.Runtime.CompilerServices.Unsafe.dll**
- file that starts with **mscordaccoreamd64amd64_**
- and the **Lua/** folder
4 - Paste them to your existing server, and let it replace the files<br>
@@ -24,16 +33,24 @@
Same as above, but instead you need to copy/replace the following files:
- **Barotrauma.deps.json**
- **Barotrauma.dll**
- **0Harmony.dll**
- **MoonSharp.Interpreter.dll**
- **Barotrauma.deps.json**
- **Barotrauma.dll**
- **Barotrauma.pdb**
- **0Harmony.dll**
- **MoonSharp.Interpreter.dll**
- **MonoMod.Common.dll**
- **Mono.Cecil.dll**
- **Mono.Cecil.Mdb.dll**
- **Mono.Cecil.Pdb.dll**
- **Mono.Cecil.Rocks.dll**
- file that starts with **mscordaccore_amd64_amd64_**
- **Microsoft.CodeAnalysis.CSharp.Scripting.dll**
- **Microsoft.CodeAnalysis.CSharp.dll**
- **Microsoft.CodeAnalysis.dll**
- **Microsoft.CodeAnalysis.Scripting.dll**
- **System.Collections.Immutable.dll**
- **System.Reflection.Metadata.dll**
- **System.Runtime.CompilerServices.Unsafe.dll**
- file that starts with **mscordaccoreamd64amd64_**
- and the **Lua/** folder
@@ -53,7 +70,7 @@ Same as above, but instead you need to copy/replace the following files:
![](https://cdn.discordapp.com/attachments/799752463619325968/833133217300742154/unknown.png)
6 - Optional: Copy config_player.xml
6 - Optional: Copy config_player.xml from your original game so it retains your configurations.
7 - Done! Now run DedicatedServer.exe to run the modded server or run Barotrauma.exe to run the modded client.<br>
@@ -64,4 +81,4 @@ Sometimes you will get steam initialization errors, most of the time it's becaus
## Checking if everything is working
If the commands `reloadlua` or `cl_reloadlua` work, it means you successfully installed the mod.
If the commands `reloadlua` or `cl_reloadlua` work without errors, it means you successfully installed the mod.