「模组:Content Patcher」修訂間的差異

出自Stardew Valley Wiki
跳至導覽 跳至搜尋
行 63: 行 63:
  
 
===Create example mod===
 
===Create example mod===
First let's get our basic content pack up and running:
+
首先让我们安装并运行我们的基本内容:
 
<ol>
 
<ol>
<li>Install [https://smapi.io/ SMAPI] and {{nexus mod|1915|Content Patcher}}.</li>
+
<li> 安装 [https://smapi.io/ SMAPI] {{nexus mod|1915|Content Patcher}}.</li>
<li>Unpack the game's <tt>Content</tt> folder so you can see what each asset contains (see [[Modding:Editing XNB files#Unpack game files]]).</li>
+
<li> 解压游戏的<tt>Content</tt> 文件夹,这样您就可以看到每个资产包含的内容(参见[[Modding:Editing XNB files#Unpack game files]] )。</li>
<li>[[Modding:Content packs#Create a content pack|Create a SMAPI content pack]].</li>
+
<li>[[ 修改:内容包# 创建内容包| 创建 SMAPI 内容包]] </li>
<li>Create a <tt>content.json</tt> file in the same folder with this content:
+
<li> 使用以下内容在同一文件夹中创建一个 <tt>content.json</tt> 文件:
 
{{#tag:syntaxhighlight|
 
{{#tag:syntaxhighlight|
 
{
 
{
行 79: 行 79:
 
</ol>
 
</ol>
  
If you did everything correctly so far, you should see the new mod under "Loaded X content packs" in the SMAPI console. (If not, review the above steps or [[Modding:Community|ask for help]].)
+
如果到目前为止你做的一切都正确,你应该在 SMAPI 控制台的“加载的 X 内容包”下看到新的 mod 。 (如果没有,请查看上述步骤或 [[Modding:Community| 寻求帮助]] 。)
  
 
===内容格式===
 
===内容格式===

於 2021年8月8日 (日) 06:10 的修訂

目錄

Robin building.png
“我這裡還有很多事情需要處理。”
— 羅賓

不完整的翻譯

本文或部分尚未完全翻譯成中文。 歡迎您通過編輯幫助其建設。
最後編輯ChenNiuniu於2021-08-08 06:10:14.

想為遊戲創建內容包模組嗎?教程就在這裡。有關如何使用模組,請參閱 模組:使用指南/入門

快速開始

此頁面是對創建 Content Patcher 的內容包的簡要介紹。如果你不需要介紹,請參閱 完整的技術資料

基本概念

什麼是 Content Patcher ?

Content Patcher是一種 SMAPI 模組,可更改遊戲資源(圖像、對話、數據和地圖),而無需替換遊戲文件或編寫代碼。可以通過創建包含幾個 JSON 文件(基本上是文本)的內容包(基本上是文件夾)來使用它。只需編輯 JSON 文件就可以:

  • 替換一個圖像文件
  • 製作季節性的變化
  • 根據天氣、日期、與其他 NPC 的關係等進行更改
  • 進行非常具體的更改(例如,在完成喬家超市獻祭之後,在下雪的冬天的周末,咖啡價格會更高)
  • 以及更多

資源 Assets

一個 asset 本質上是遊戲中的 Content 文件夾,具有唯一的「資源名稱」。 資產名稱從不包含 Content路徑、語言或文件擴展名(可以使用令牌來定位特定的語言)。例如:

文件 資源名稱
Content/Portraits/Abigail.xnb Portraits/Abigail
Content/Maps/spring_beach.xnb
Content/Maps/spring_beach.es-ES.xnb
Content/Maps/spring_beach.fr-FR.xnb
Maps/spring_beach

一個資源可能包含多個子畫面或數據條目。例如:Portraits/Abigail

Modding - creating an XNB mod - example portraits.png

因此,如果想更改阿比蓋爾的肖像,則可以使用 Content Patcher 加載或編輯 Portraits/Abigail.

Load 和 Edit

可以通過兩種概念上的方式來更改資源:

  • Load|加載 Asset的初始版本。 每個Asset只能同時被一個模組加載。 這主要用於完全替換模組(例如完全改變 NPC 肖像的模組),或提供 Content 文件夾中不存在的文件。
  • Edit|編輯 加載後的Asset。 可以對同一資產應用任意數量的編輯。

例如,假設遊戲需要阿比蓋爾的肖像。 這是應用更改的方式:

                                           ┌────────────┐
                                           │ 编辑Asset │
                         ┌────────────┐    ├────────────┤
获得肖像/阿比盖尔 ──>│ 载入Aeest  │───>│编辑Asset │──> 肖像Aeest
                         └────────────┘    ├────────────┤
                                           │ 编辑Asset │
                                           └────────────┘

這分為四種主要操作類型(LoadEditDataEditImageEditMap),在 內容修補程序自述文件中的更多詳細信息(見下文)。

開始

了解Json

You'll notice a lot of files with .json at the end of the name when creating mods for Stardew Valley. That means they're formatted as JSON, which is just a way of writing text that's readable to code. If you haven't used JSON before, reading An Introduction to JSON first will be very helpful to understand what the files are doing.

Create example mod

首先讓我們安裝並運行我們的基本內容:

  1. 安裝 SMAPIContent Patcher.
  2. 解壓遊戲的Content文件夾,這樣您就可以看到每個資產包含的內容(參見Modding:Editing XNB files#Unpack game files)。
  3. 創建 SMAPI 內容包
  4. 使用以下內容在同一文件夾中創建一個 content.json 文件:
    {
       "Format": "2.0.0",
       "Changes": [
       ]
    }
    
  5. Launch the game.

如果到目前為止你做的一切都正確,你應該在 SMAPI 控制台的「加載的 X 內容包」下看到新的 mod。 (如果沒有,請查看上述步驟或 尋求幫助。)

內容格式

您在上面創建的 content.json 文件告訴 Content Patcher 要更改什麼。 這有兩個主要領域:

  • Format:格式版本。 您應該始終使用最新版本(當前為 1.19.0)來啟用最新功能並避免過時行為。
  • Changes:您要進行的更改。 每個條目稱為「補丁」,並描述要執行的特定操作:替換此文件、將此圖像複製到文件中等。您可以列出任意數量的補丁。

您可以在 Changes 字段中列出任意數量的補丁,每個補丁都由 {} 包圍。 有關更多信息,請參閱下一節,但這裡有一個快速示例:

{
   "Format": "2.0.0",
   "Changes": [
      {
         "Action": "Load",
         "Target": "Animals/Dinosaur",
         "FromFile": "assets/dinosaur.png"
      },

      {
         "Action": "EditImage",
         "Target": "Maps/springobjects",
         "FromFile": "assets/fish-object.png"
      },
   ]
}

(還有其他字段,如 ConfigSchemaDynamicTokens 用於更高級的用法;這些都包含在完整的自述文件中。)

Next steps

You've created a Content Patcher pack!

For help making it do something, see...

Examples

(We'll have a guided tutorial here soon.)

Change horse/pet icons

For edits to replace the look of horses and/or pets (cats and dogs), you can add these to your content.json in order to also replace the little head icon in the inventory menu:

For horses:

//horse head in inventory
{
   "Action": "EditImage",
   "Target": "LooseSprites/Cursors",
   "FromFile": "yourfile.png",
   "FromArea": { insert values here }, 
   "ToArea": { "X": 192, "Y": 192, "Width": 16, "Height": 16 }
}

For dogs:

//dog head in inventory

"ToArea": { "X": 208, "Y": 208, "Width": 16, "Height": 16 }, //Dog 1

"ToArea": { "X": 224, "Y": 208, "Width": 16, "Height": 16 }, //Dog 2

"ToArea": { "X": 240, "Y": 208, "Width": 16, "Height": 16 }, //Dog 3

For cats:

//cat head in inventory

"ToArea": { "X": 160, "Y": 208, "Width": 16, "Height": 16 }, //Cat 1 

"ToArea": { "X": 176, "Y": 208, "Width": 16, "Height": 16 }, //Cat 2 

"ToArea": { "X": 192, "Y": 208, "Width": 16, "Height": 16 }, //Cat 3