首先来说明一下,我写这个章节本身也是对学习过程的记录,主要参考了http://canimod.com/guides/creating-a-smapi-mod中的内容。也推荐大家看看。

*这些是我的开发环境*

  操作系统:

    macOS

  SDK:

       1 MonoFramework-MDK-4.6.2.16.macos10.xamarin.universal.pkg (貌似是.net平台)

   2 XamarinStudio-6.1.2.44.dmg (这个应该是IDE)

  ps:具体的版本依照实际的操作系统来定,或者安装vs。同时你也可以向上面那个英文教程学习~

*正式*

  然而在正式配置环境之前,是的,你得保证游戏正常运行。然后依次安装上面两个软件(我相信这是一个很容易的过程,谢谢)。

*创建一个项目*

  &恩,详细过程我还是直接借用过来翻译一下算了~

  1. 打开 Visual Studio 或者 MonoDevelop.
  2. 创建一个新的 solution with a library project.
    • 在 Visual Studio中, 选择 Visual C# » Class Library. (确保你选择的是 “Class Library”, 而不是 “Class Library (.NET Core)” 或者 “Class Library (Portable)”.)
    • 在 MonoDevelop中, 选择 Other » .NET » Library.
  3. 改变 the target framework to .NET 4.5 (for compatibility with Linux).
    • 在 Visual Studio中: 右键 project, 选择 Properties, 单击Application 标签, 并且将 Target framework dropdown 选成 .NET Framework 4.5.
    • 在 MonoDevelop中: 右键 project, 选择 Options, 单击 the Build » General 标签, 并且将Target framework dropdown 选成 Mono / .NET 4.5.
  4. 删除项目中的 Class1.cs 或者 MyClass.cs 文件.

  ps:按照上面步骤,我这里新建了一个solution和project名称都为firstMod的项目。需要注意后面的一些配置信息要与这里对应

*配置项目*

  项目需要引用这个包 Pathoschild.Stardew.ModBuildConfig NuGet package. 它能够自动配置你的项目,针对当前的平台,正确加载合适的依赖库。

  1.双击下图画圈的部分

  

  2.弹出了如下界面,然后在搜索框中“Pathoschild.Stardew.ModBuildConfig”,安装并等待完成。

  

3.添加一个cs文件,名称 “ModEntry”

  

  4.将如下内容复制进ModEntry.cs

 using System;
using Microsoft.Xna.Framework;
using StardewModdingAPI;
using StardewModdingAPI.Events;
using StardewValley; namespace firstMod
{
/// <summary>The mod entry point.</summary>
public class ModEntry : Mod
{
/// <summary>Initialise the mod.</summary>
/// <param name="helper">Provides methods for interacting with the mod directory, such as read/writing a config file or custom JSON files.</param>
public override void Entry(IModHelper helper)
{
ControlEvents.KeyPressed += this.ReceiveKeyPress;
} /*********
** Private methods
*********/
/// <summary>The method invoked when the player presses a keyboard button.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void ReceiveKeyPress(object sender, EventArgsKeyPressed e)
{
this.Monitor.Log($"Player pressed {e.KeyPressed}.");
}
}
}

  5.创建manifest.json文件,内容如下,存放至工程目录下,其实位置无所谓,主要是最终应该放在游戏mod的目录下

{
"Name": "firstMod",
"Author": "iamfine",
"Version": {
"MajorVersion": 1,
"MinorVersion": 0,
"PatchVersion": 0,
"Build": ""
},
"Description": "获取按键消息",
"UniqueID": "iamfine.firstMod",
"EntryDll": "firstMod.dll"
}

  6.编译整个工程后得到如下文件

  

  7.将firstMod.dll 和 manifest.json两个文件复制到游戏的Mods目录下,如下图所示。

  

  ps:安装smapi后,在macOS下,mod的目录是

/Users/huqian/Library/Application Support/Steam/steamapps/common/Stardew Valley/Contents/MacOS/Mods

  8.运行游戏后,这个mod会记录玩家在游戏界面中的按键信息,如下图。

最新文章

  1. HDU5336-XYZ and Drops-模拟
  2. uva 562
  3. Android Camera 预览图像被拉伸变形的解决方法【转】
  4. Velocity 语法示例
  5. angular.js学习
  6. linux+windows mysql导入导出sql文件
  7. 一道java基础面试题
  8. RAC Wait Event: gcs log flush sync 等待事件 转
  9. Java面试题:小白不得不懂的斐波那契数列
  10. WebApi零碎总结
  11. The.Glory.of.Innovation 创新之路2科学基石
  12. shell历史简介
  13. easyui刷新指定tab页里面的数据
  14. Eclipse - Mac Os Default JRE missing
  15. SqlServer 数据库引擎优化顾问优化数据库
  16. JS中 try...catch...finally (转)
  17. js json转对象
  18. Discuz常见大问题-如何使用图片轮播器
  19. GIS-004-Cesium版权信息隐藏
  20. /etc/services

热门文章

  1. AGC032E modulo pairing
  2. Java后台开发精选知识图谱
  3. SAE上配置Django静态文件
  4. 20191121-5 Scrum立会报告+燃尽图 01
  5. LeetCode 10. 正则表达式匹配(Regular Expression Matching)
  6. bootstrp的datetimepicker插件获取选定日期
  7. 动态绑定v-model
  8. 用Servlet返回JSON文本动态创建DataGrid
  9. Centos7.2 MQTT的学习之Mosquitto搭建&amp;集群搭建&amp;使用
  10. Git分块提交文件