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 />> 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