promotional bannermobile promotional banner

Console Code

Write and execute C# code from the SMAPI console.

Console Code lets you write and execute C# code from the SMAPI console.

Install

  • Install the latest version of SMAPI.
  • Unzip the mod folder into Stardew Valley/Mods.
  • Run the game using SMAPI.


Use
Short snippets
You can run code directly in the SMAPI console using the cs command. You can separate multiple expressions with ;. If the last expression returns a value, it'll be shown in the SMAPI console.

For example:

cs Game1.player.Money = 5000; Game1.player.currentLocation.Name
<br />&gt; Output: "FarmHouse"



You can't use double quotes (") directly in the console (due to the SMAPI command parser), but you can replace them with backticks (`).

Script files
You can load a block from a file in Console Code's folder. The script must not include using statements, class declarations, etc.

For example, let's say you have this sell-items.cs file in the mod folder:

foreach (var item in Game1.player.items)
<br />{
<br />    if (item == null)
<br />        continue;
<br />    Game1.player.money += item.salePrice();
<br />    Game1.player.removeItemFromInventory(item);
<br />}



You can execute it like this:

cs --script sell-items.cs



Compatibility
Compatible with Stardew Valley 1.5+ on Linux/macOS/Windows, both single-player and multiplayer.

See also

The Console Code Team

profile avatar
  • 14
    Followers
  • 69
    Projects
  • 3.7M
    Downloads

More from spacechase0View all

  • SpaceCore project image

    SpaceCore

    • 716.4K
    • Mods

    A framework mod used by some of my other mods.

    • 716.4K
    • October 19, 2025
    • Mods
  • Json Assets project image

    Json Assets

    • 628.6K
    • Mods

    Lets content packs add custom content to the game.

    • 628.6K
    • October 18, 2025
    • Mods
  • Generic Mod Config Menu project image

    Generic Mod Config Menu

    • 804.8K
    • Mods

    Adds an in-game UI to edit other mods' config options.

    • 804.8K
    • October 18, 2025
    • Mods
  • Experience Bars project image

    Experience Bars

    • 171.2K
    • Mods

    Adds experience bars for your skill levels, so you can see how far you are from leveling.

    • 171.2K
    • October 18, 2025
    • Mods
  • SpaceCore project image

    SpaceCore

    • 716.4K
    • Mods

    A framework mod used by some of my other mods.

    • 716.4K
    • October 19, 2025
    • Mods
  • Json Assets project image

    Json Assets

    • 628.6K
    • Mods

    Lets content packs add custom content to the game.

    • 628.6K
    • October 18, 2025
    • Mods
  • Generic Mod Config Menu project image

    Generic Mod Config Menu

    • 804.8K
    • Mods

    Adds an in-game UI to edit other mods' config options.

    • 804.8K
    • October 18, 2025
    • Mods
  • Experience Bars project image

    Experience Bars

    • 171.2K
    • Mods

    Adds experience bars for your skill levels, so you can see how far you are from leveling.

    • 171.2K
    • October 18, 2025
    • Mods