The modding API for Stardew Valley.
Go to file
Zoryn de3f161a49 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	Release/StardewModdingAPI.exe
#	StardewModdingAPI/Program.cs
#	StardewModdingAPI/StardewModdingAPI.csproj

#	StardewModdingAPI/obj/x86/Debug/StardewModdingAPI.csproj.FileListAbsolute.txt
#	TrainerMod/bin/Debug/TrainerMod.dll
#	TrainerMod/obj/Debug/TrainerMod.dll
2016-03-03 14:04:29 -05:00
Release updates to change working location 2016-03-03 14:01:32 -05:00
StardewModdingAPI Merge remote-tracking branch 'origin/master' 2016-03-03 14:04:29 -05:00
TrainerMod Merge remote-tracking branch 'origin/master' 2016-03-03 14:04:29 -05:00
.gitignore updates to change working location 2016-03-03 14:01:32 -05:00
BobberBar Private Fields.txt expose some private fields for modding 2016-02-28 22:16:32 -05:00
Game1 Static Fields.txt expose some private fields for modding 2016-02-28 22:16:32 -05:00
LICENSE Initial commit 2016-02-28 06:44:19 -05:00
README.md readme 2016-03-02 16:36:55 -05:00
StardewModdingAPI.sln updates to change working location 2016-03-03 14:01:32 -05:00
StardewModdingAPI.v12.suo Merge remote-tracking branch 'origin/master' 2016-03-03 14:04:29 -05:00
StardewModdingAPI.vssscc no message 2016-02-28 06:55:35 -05:00
Vanilla Items List.txt trying to get custom content working - do NOT try to implement cc yet 2016-03-01 01:35:52 -05:00

README.md

SMAPI

A Modding API For Stardew Valley See: https://github.com/Zoryn4163/SMAPI-Mods

NOTICE: THIS PROJECT IS STILL IN ALPHA

Mod directories: %appdata%\StardewValley\Mods\ and .\Mods\ <- That means next to StardewModdingApi.exe in the Mods folder!

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

You can create a mod by making a direct reference to the ModdingApi.exe

From there, you need to inherit from StardewModdingAPI.Mod

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.

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.

TestMod.cs:

    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
    {
        public class TestMod : Mod
        {
            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);
            }
        }
    }

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;
            }
        }
    }