SMAPI/README.md

117 lines
3.8 KiB
Markdown
Raw Normal View History

2016-02-28 19:59:46 +08:00
# SMAPI
A Modding API For Stardew Valley
2016-02-29 13:24:41 +08:00
See: https://github.com/Zoryn4163/SMAPI-Mods
2016-02-28 19:59:46 +08:00
2016-03-03 05:36:26 +08:00
NOTICE: THIS PROJECT IS STILL IN ALPHA
2016-03-03 05:36:55 +08:00
2016-03-03 05:36:26 +08:00
Mod directories: %appdata%\StardewValley\Mods\ and .\Mods\ <- That means next to StardewModdingApi.exe in the Mods folder!
2016-03-03 05:36:55 +08:00
2016-03-03 05:36:26 +08:00
To install a mod, put a DLL in one of those directories. If you are not on the latest version, do not post any errors, issues, etc.
NOTICE: THIS PART AND ONWARD REQUIRE VISUAL STUDIOS AND KNOWLEDGE OF C# PROGRAMMING
2016-02-29 05:27:32 +08:00
You can create a mod by making a direct reference to the ModdingApi.exe
2016-02-29 09:28:46 +08:00
2016-02-29 05:27:32 +08:00
From there, you need to inherit from StardewModdingAPI.Mod
2016-02-29 09:28:46 +08:00
2016-02-29 09:26:36 +08:00
The first class that inherits from that class will be loaded into the game at runtime, and once the game fully initializes the mod, the method Entry() will be called once.
2016-02-29 09:28:46 +08:00
2016-02-29 09:29:43 +08:00
It is recommended to subscribe to an event (from Events.cs) to be able to interface with the game rather than directly make changes from the Entry() method.
2016-02-28 19:59:46 +08:00
2016-02-29 09:29:43 +08:00
TestMod.cs:
2016-02-29 09:30:24 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework.Input;
using StardewModdingAPI;
namespace StardewTestMod
2016-02-28 19:59:46 +08:00
{
2016-02-29 09:30:24 +08:00
public class TestMod : Mod
2016-02-29 09:29:43 +08:00
{
2016-02-29 09:30:24 +08:00
public override string Name
{
get { return "Test Mod"; }
}
public override string Authour
{
get { return "Zoryn Aaron"; }
}
public override string Version
{
get { return "0.0.1Test"; }
}
public override string Description
{
get { return "A Test Mod"; }
}
public override void Entry()
{
Console.WriteLine("Test Mod Has Loaded");
Program.LogError("Test Mod can call to Program.cs in the API");
Program.LogColour(ConsoleColor.Magenta, "Test Mod is just a tiny DLL file in AppData/Roaming/StardewValley/Mods");
//Subscribe to an event from the modding API
Events.KeyPressed += Events_KeyPressed;
}
void Events_KeyPressed(Keys key)
{
Console.WriteLine("TestMod sees that the following key was pressed: " + key);
}
2016-02-29 09:29:43 +08:00
}
2016-02-29 12:15:38 +08:00
}
Break Fishing (WARNING: SOFTLOCKS YOUR GAME):
public override void Entry()
{
Events.UpdateTick += Events_UpdateTick;
Events.Initialize += Events_Initialize;
}
private FieldInfo cmg;
private bool gotGame;
private SBobberBar sb;
void Events_Initialize()
{
cmg = SGame.StaticFields.First(x => x.Name == "activeClickableMenu");
}
void Events_UpdateTick()
{
if (cmg != null && cmg.GetValue(null) != null)
{
if (cmg.GetValue(null).GetType() == typeof(BobberBar))
{
if (!gotGame)
{
gotGame = true;
BobberBar b = (BobberBar)cmg.GetValue(null);
sb = SBobberBar.ConstructFromBaseClass(b);
}
else
{
sb.bobberPosition = Extensions.Random.Next(0, 750);
sb.treasure = true;
sb.distanceFromCatching = 0.5f;
}
}
else
{
gotGame = false;
sb = null;
}
}
2016-02-29 09:29:43 +08:00
}