查看“模组:Content Patcher”的源代码
←
模组:Content Patcher
跳到导航
跳到搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看和复制此页面的源代码。
← [[模组:目录|目录]] {{翻译}} 想为游戏创建内容包模组吗?教程就在这里。'''有关如何使用模组,请参阅 [[模组:使用指南/入门]] ==快速开始== 此页面是对创建 Content Patcher 的内容包的简要介绍。如果你不需要介绍,请参阅 [https://github.com/Pathoschild/StardewMods/tree/develop/ContentPatcher#readme 完整的技术资料] ==基本概念== ===什么是 Content Patcher ?=== {{nexus mod|1915|Content Patcher}}是一种 SMAPI 模组,可更改游戏资源(图像、对话、数据和地图),而无需替换游戏文件或编写代码。可以通过创建包含几个 JSON 文件(基本上是文本)的内容包(基本上是文件夹)来使用它。只需编辑 JSON 文件就可以: * 替换一个图像文件 * 制作季节性的变化 * 根据天气、日期、与其他 NPC 的关系等进行更改 * 进行非常具体的更改(例如,在完成乔家超市献祭之后,在下雪的冬天的周末,咖啡价格会更高) * 以及更多 ===资源 Assets=== 一个 '''asset''' 本质上是游戏中的 <tt>Content</tt> 文件夹,具有唯一的“资源名称”。 资产名称从不包含 <tt>Content</tt>路径、语言或文件扩展名(可以使用令牌来定位特定的语言)。例如: {| class="wikitable" |- ! 文件 ! 资源名称 |- | <tt>Content/Portraits/Abigail.xnb</tt> | <tt>Portraits/Abigail</tt> |- | <tt>Content/Maps/spring_beach.xnb</tt><br /><tt>Content/Maps/spring_beach.es-ES.xnb</tt><br /><tt>Content/Maps/spring_beach.fr-FR.xnb</tt> | <tt>Maps/spring_beach</tt> |} 一个资源可能包含多个子画面或数据条目。例如:<tt>Portraits/Abigail</tt>: [[File:Modding - creating an XNB mod - example portraits.png]] 因此,如果想更改阿比盖尔的肖像,则可以使用 Content Patcher 加载或编辑 <tt>Portraits/Abigail</tt>. ===Load 和 Edit=== 可以通过两种概念上的方式来更改资源: * ''Load|加载'' Asset的初始版本。 每个Asset只能同时被一个模组加载。 这主要用于完全替换模组(例如完全改变 NPC 肖像的模组),或提供 <tt>Content</tt> 文件夹中不存在的文件。 * ''Edit|编辑'' 加载后的Asset。 可以对同一资产应用任意数量的编辑。 例如,假设游戏需要阿比盖尔的肖像。 这是应用更改的方式: <pre> ┌────────────┐ │ 编辑Asset │ ┌────────────┐ ├────────────┤ 获得肖像/阿比盖尔 ──>│ 载入Aeest │───>│编辑Asset │──> 肖像Aeest └────────────┘ ├────────────┤ │ 编辑Asset │ └────────────┘ </pre> 这分为四种主要操作类型(<tt>Load</tt>、<tt>EditData</tt>、<tt>EditImage</tt>、<tt>EditMap</tt>),在 内容修补程序自述文件中的更多详细信息(见下文)。 ==开始== ===了解Json=== You'll notice a lot of files with <tt>.json</tt> 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 ''[https://towardsdatascience.com/an-introduction-to-json-c9acb464f43e An Introduction to JSON]'' first will be very helpful to understand what the files are doing. ===Create example mod=== 首先让我们安装并运行我们的基本内容: <ol> <li>安装 [https://smapi.io/ SMAPI] 和 {{nexus mod|1915|Content Patcher}}.</li> <li>解压游戏的<tt>Content</tt>文件夹,这样您就可以看到每个资产包含的内容。</li> <li>修改或创建SMAPI内容包。</li> <li>使用以下内容在同一文件夹中创建一个 <tt>content.json</tt> 文件: {{#tag:syntaxhighlight| { "Format": "{{Content Patcher version}}", "Changes": [ ] }|lang=javascript}} </li> <li>Launch the game.</li> </ol> 如果到目前为止你做的一切都正确,你应该在 SMAPI 控制台的“加载的 X 内容包”下看到新的 mod。 (如果没有,请查看上述步骤或 [[Modding:Community|寻求帮助]]。) ===内容格式=== 您在上面创建的 <tt>content.json</tt> 文件告诉 Content Patcher 要更改什么。 这有两个主要领域: * <tt>Format</tt>:格式版本。 您应该始终使用最新版本(当前为 1.19.0)来启用最新功能并避免过时行为。 * <tt>Changes</tt>:您要进行的更改。 每个条目称为“补丁”,并描述要执行的特定操作:替换此文件、将此图像复制到文件中等。您可以列出任意数量的补丁。 您可以在 <tt>Changes</tt> 字段中列出任意数量的补丁,每个补丁都由 <code>{</code> 和 <code>}</code> 包围。 有关更多信息,请参阅下一节,但这里有一个快速示例: {{#tag:syntaxhighlight| { "Format": "{{Content Patcher version}}", "Changes": [ { "Action": "Load", "Target": "Animals/Dinosaur", "FromFile": "assets/dinosaur.png" }, { "Action": "EditImage", "Target": "Maps/springobjects", "FromFile": "assets/fish-object.png" }, ] }|lang=javascript}} (还有其他字段,如 <tt>ConfigSchema</tt> 和 <tt>DynamicTokens</tt> 用于更高级的用法;这些都包含在完整的自述文件中。) ==Next steps== You've created a Content Patcher pack! <!--Next we'll make it do something. This tutorial will walk you through creating Blueberries Everywhere, a mod which just turns various things into blueberries. When you're ready to continue, see the navigation at the bottom of the page to continue.--> For help making it do something, see... * [https://github.com/Pathoschild/StardewMods/tree/develop/ContentPatcher#readme Content Patcher readme] for the full reference; * [https://www.youtube.com/watch?v=uqRTgjWvDYs video intro to Content Patcher] (unofficial); * [https://docs.google.com/presentation/d/1OBIJSNOwEA2sdBzNbUiVUQni-ajABGFmL-FUanhuLvk intro to converting XNB mods] (unofficial). ==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: <syntaxhighlight lang="javascript"> //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 } } </syntaxhighlight> For dogs: <syntaxhighlight lang="javascript"> //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 </syntaxhighlight> For cats: <syntaxhighlight lang="javascript"> //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 </syntaxhighlight> <!-- {{modding guide footer |prev = |next = [[/Load|Load assets]] }} --> [[en:Modding:Content Patcher]]
该页面使用的模板:
Template:Content Patcher version
(
查看源代码
)
Template:Nexus mod
(
查看源代码
)
返回至
模组:Content Patcher
。
导航菜单
个人工具
创建账户
登录
名字空间
模组
讨论
不转换
不转换
简体
繁體
大陆简体
香港繁體
澳門繁體
大马简体
新加坡简体
台灣正體
视图
阅读
查看源代码
查看历史
更多
搜索
导航
首页
最近更改
未翻译的页面
帮助:编辑入门
随机页面
官方链接
官方网站
官方论坛
官方商品
Discord
Reddit
工具
链入页面
相关更改
上传文件
特殊页面
页面信息