「模组:制作一个XNB模组」修訂間的差異

出自Stardew Valley Wiki
跳至導覽 跳至搜尋
第24行: 第24行:
 
SMAPI is a modding API that lets you change the game using code. SMAPI mods are more powerful, easier to install and remove, and allow multiple mods to change the same content. On the other hand, SMAPI requires you to write code which some modders aren't comfortable with. If you have programming experience, [[Modding:Creating a SMAPI mod|creating a SMAPI mod]] is recommended instead if feasible.
 
SMAPI is a modding API that lets you change the game using code. SMAPI mods are more powerful, easier to install and remove, and allow multiple mods to change the same content. On the other hand, SMAPI requires you to write code which some modders aren't comfortable with. If you have programming experience, [[Modding:Creating a SMAPI mod|creating a SMAPI mod]] is recommended instead if feasible.
  
 有关这两种mod的更多信息,请看:[[使用模组 玩家常见问题]]。
+
 有关这两种mod的更多信息,请看:[[使用模组: 玩家常见问题]]。
  
 
===在哪里可以获得帮助?===
 
===在哪里可以获得帮助?===
第78行: 第78行:
  
 
===地图===
 
===地图===
 请见:[[使用模组 地图]]
+
 请见:[[使用模组: 地图]]
  
 
[[Category:使用模组]]
 
[[Category:使用模组]]
 
[[en:Modding:Creating an XNB mod]]
 
[[en:Modding:Creating an XNB mod]]

於 2018年10月21日 (日) 19:35 的修訂

目錄

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

不完整的翻譯

本文或部分尚未完全翻譯成中文。 歡迎您通過編輯幫助其建設。
最後編輯Margotbean於2018-10-21 19:35:02.

本頁介紹如何創建一個替換遊戲原文件的MOD,以便更改遊戲數據,圖像和地圖。

介紹

XNB模組的工作原理

遊戲以.xnb的壓縮格式文件把數據存儲在Content文件夾中。例如,在對話框裏顯示的阿比蓋爾的頭像來自Content\Portraits\Abigail.xnb這個文件。每個.xnb包含兩個文件: 數據文件(如圖像)和元數據文件(有關數據文件的信息)。例如,這是Content\Portraits\Abigail.xnb裏面的內容:

Abigail.xnb
   Abigail.png
   Abigail.yaml

在上面的例子中:

  • Abigail.png 這個文件里包含阿比蓋爾的頭像。如果你想修改她在遊戲中的頭像,需要編輯的就是這個文件:
    Modding - creating an XNB mod - example portraits.png
  • Abigail.yaml 這個文件里包含關於 Abigail.png 的元數據(文件類型之類的),通常情況下不用改動它。

XNB模組代替了一些遊戲原本的XNB文件,可以讓你更改圖像(頭像,NPC行走圖或建築物外形),數據(作物信息或對話),或地圖(包括地圖行為,如傳送或小遊戲)。 XNB模組也可以添加全新的內容(如新的NPC)。

XNB vs SMAPI mods

SMAPI is a modding API that lets you change the game using code. SMAPI mods are more powerful, easier to install and remove, and allow multiple mods to change the same content. On the other hand, SMAPI requires you to write code which some modders aren't comfortable with. If you have programming experience, creating a SMAPI mod is recommended instead if feasible.

有關這兩種mod的更多信息,請看:使用模組:玩家常見問題

在哪裏可以獲得幫助?

The Stardew Valley modding community is very welcoming. Feel free come chat on Discord or post in the forums.

入門

First-time setup

Before you start, you should install these:

on Windows
on Linux/Mac

You should also back up your game's Content folder, so you can recover the original files if you make a mistake.

Unpack & pack game files

You can't edit an .xnb file itself, you need to edit the file that's inside it. Pulling out that inner file is called unpacking, and putting it back is called packing. Here's how to do it:

  1. Download XNB Extract (see #First-time setup).
  2. Unpack the file for editing:
    1. Find the file you want to edit in the Contents folder.
    2. Copy it into XNB Extract's Packed folder.
    3. Double-click UnpackFiles.bat (Windows) or UnpackFiles.sh (Linux/Mac).
  3. Edit the unpacked file (see below).
  4. Repack the file for the game:
    1. Double-click PackFiles.bat (Windows) or PackFiles.sh (Linux/Mac).
    2. Move the repacked .xnb file back to the original location.

Making changes

Spritesheets, tilesheets, or portraits

An example tilesheet, which consists of a grid of tiles like this: Modding - creating an XNB mod - example tile 1.png

Definitions:

  • A spritesheet is a PNG file containing small images in a regular grid pattern. Each square in the spritesheet's grid pattern is called a sprite. For example, each in-game item has a sprite in Content\Maps\spring_objects.xnb.
  • A tilesheet is a synonym for spritesheet when used for map tiles. In a tilesheet, each square is called a tile and is 16×16 pixels.
  • A portrait is a sprite from the Content\Characters\*.xnb spritesheets.

Spritesheets are easy to edit:

  1. Unpack the file you want to change.
  2. Open the unpacked .png file in an image editor (see #Getting started).
  3. Make changes directly to the image.
  4. Repack the file and copy it back to the original location.

That's it! You can launch the game to see your changes.

地圖

請見:使用模組:地圖