Before reading this, I want you to know that I used VBA and GML a bit and barely used C# before... I will try my best but I might not understand your answers very well. My current goal is to make a new custom mines(dungeon) for the mod I'm planning. To do so, I have to 1. modify StardewValley.exe's Class & Function (Mineshaft Class, performAction Function, etc.) Or 2. practically clone the codes and customize it and I wanna ask 1. Are there no way to fix the code in StardewValley.exe using modding tools? 2. How do you get the input of Key/MouseClick/Gamepad by using StardewModdingAPI, not StardewValley.exe? using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using StardewModdingAPI; using StardewValley; using System; using System.Collections.Generic; using System.Linq; using System.Collections.Specialized; using System.Globalization; using System.Text; using System.Xml.Serialization; using xTile.Dimensions; using xTile.ObjectModel; using xTile.Tiles; namespace ElemetalWarfare { public class Class1 : Mod { public override void Entry(params object[] objects) { StardewModdingAPI.Events.GameEvents.UpdateTick += GameEvents_UpdateTick; } private void GameEvents_UpdateTick(object sender, EventArgs e) { if (Game1.pressActionButton(Keyboard.GetState(), Mouse.GetState(), GamePad.GetState(PlayerIndex.One))) { } } } } This is the code I'm working on temporarily.... I really need some advices, and using only xnb modification is also an option.... Please give me advices! *sob*
You use events. Use something like this for the Entry method: Code: public override void Entry(params object[] objects) { ControlEvents.MouseChanged += Event_MouseChanged; ControlEvents.ControllerButtonPressed += Event_ControllerButtonPressed; } and then the events themselves look something like this: Code: static void Event_ControllerButtonPressed(object sender, EventArgsControllerButtonPressed e) { if (!Game1.hasLoadedGame) return; if (e.ButtonPressed == Buttons.A) { //whatever you want to execute on A button execution goes here } } also Code: static void Event_MouseChanged(object sender, EventArgsMouseStateChanged e) { if (!Game1.hasLoadedGame) return; if (e.NewState.RightButton == ButtonState.Pressed && e.PriorState.RightButton != ButtonState.Pressed) { //whatever you want to execute when the RightButton on mouse is pressed goes here } }
Awesome! Thanks! Now I can get started and make some customized mines! .... I think lol Oh yeah by the way, how does the SMAPI process work overall? Does it run All of Stardew Valley stuffs run first then the SMAPI? Or is it the other way around? Or do they get mixed up somehow...? I wonder if I can check boolean about StardewValley Functions without directly using it at my mod...
It was brought to my attention that I didn't give you the code for keypress, here you go: Code: static void Event_KeyPressed(object sender, EventArgsKeyPressed e) { if (!Game1.hasLoadedGame) return; if (e.KeyPressed.ToString().Equals("C")) { //whatever you want to execute when the C key is pressed goes here } }
if you can figure this out mind letting me view the code? was wanting to do something similar. got a whole dungeon mapped out and wanting to populate it.
I thank u all for such kind replies! To Entoarox : OK... That doesn't sound so good, but thanks a lot for the info! To Jinxiewinxie : I truely thank you! To BlankSlater : I'm gonna be honest, I think it would take some time and it could be faster to find it yourself.... However, I still found some clues by using ILSpy and StardewValley.Mineshaft function seems to be the key. I suggest u take a look at that. In the meantime, I'll just make a simple xnb mod or two, then try to find a way about the custom mines....