Mod development of Famine online version - configuration code environment (2)

foreword

Recalling that when I first wrote the famine code, I still used Notepad... Later, I switched to Notepad++ with parameter highlighting, but there was no official code prompt, and the call to the API was basically a direct copy of the file. Sometimes when you type the code by hand, an error/crash will be reported inexplicably when you enter the famine. During those days, I spent most of my time restarting the game and finding code syntax errors... until one day I fumbled to use VS Code, official code prompts/jumps, global code search, code formatting, git management, and took off directly from Wuhu.

Download the VS Code and Lua plugin

VS Code
https://code.visualstudio.com/Download

After downloading and installing, click the extension on the left (Ctrl+Shift+X)
insert image description here
to enter lua, select the corresponding plug-in and install it (there are many Lua plug-ins, which can basically achieve the desired functions).
insert image description here
At the same time, Sinicization can also be installed.
insert image description here

create workspace

First, go to the Famine directory Don't Starve Together\data\databundles (wg is the online version of Famine) and unzip scripts.zip. The name cannot be scripts, so it is convenient to ignore the operation later (for example: F:_scripts). Then open VS Code, click File -> Open Folder , open the _scripts folder, if this prompt appears, click
insert image description here
Next, click File -> Add Folder to Workspace , add Don't Starve Together\mods , And others need to add a folder.

Configure the Lua plugin

Click the gear on the right side of the plug-in
insert image description here
to modify the paths of these two places (the upper one has little effect, mainly the lower one, ignore the code errors in the folder) and
insert image description here
scroll to the bottom at the same time to ensure that the code inspection is turned on
insert image description here
Optional part

  1. To reduce memory consumption, turn off Luahelper.Warn: All Enable except this grammar check, and others
    insert image description here
  2. Code formatting (Shift + Alt + F)
    tick this, Asset will not go to {
    3.
  3. Color
    If you don't like the color of this plugin, you can turn it off directly. Use the built-in color of VS Code to
    insert image description here
    open modmain under any mod, put the mouse on it to see if there is a code prompt (Ctrl+left button to jump)
    insert image description here

The above basic environment is ready, the following are advanced skills

Git and GitHub (optional)

This is for managing files. If you are not familiar with this, you can read other detailed tutorials.
However, when filling in the link, it is recommended to use ssh (fast network speed) instead of https. The format is as follows
[email protected]:UserName/XXX.git

Create a text file .gitignore to avoid uploading redundant stuff.
I am used to storing multiple mods in one warehouse, so I put the warehouse in the mods folder and ignore uploading redundant files

 # 忽略名称中开头为workshop的文件夹
workshop*/
dedicated_server_mods_setup_rail.lua
dedicated_server_mods_setup.lua
modsettings.lua

Exclude redundant files

At the same time, create a .vscode folder under the mods folder and create settings.json in it. to exclude search, file listings.

{
    "search.exclude": {
        "*workshop*" : true
    },
    "files.exclude": {
        "workshop*" : true,
        "**/.git": true,
        "*.gitignore" : true,
        "dedicated_server_mods_setup_rail.lua" : true,
        "dedicated_server_mods_setup.lua" : true,
        "modsettings.lua" : true,
        ".vscode" : true
    }
}

The effect is as follows (the one that skipped the git step should not be bright)
insert image description here

Delete redundant files in scripts

In the global search of VS Code, the following redundant files are often found, so it is best to delete them.

  • Non-lua files in languages
    insert image description here
  • speech_xxx character speech list
    insert image description here

VS Code shortcut keys

Press F1 to see the official introduction
insert image description here
The following is my commonly used VS Code shortcut key
F1: Sometimes I don’t remember the shortcut key, just press F1 to search for the following
Ctrl + P: Jump to the file
Ctrl + F: Search
Ctrl + Shift + F: Global search
Shift + Alt + ↑ or ↓: Copy and paste the current line
Alt + ↑ or ↓: Move the current line
Ctrl + Click Function: Jump to the file
insert image description here
insert image description here

Portal

→Mod development of Famine Online - making simple items (3)
←Mod development of Famine Online - preparation tools (1)

Guess you like

Origin blog.csdn.net/weixin_46068322/article/details/126087533