Heres part two of this tutorial series. I will go over scripting the mod menu and by the end we will have a basic mod configuration menu with buttons and sliders!. If you have any questions or spot an error, feel free to leave a comment or use the contact page.
See the first tutorial here AdFly and the video here: https://youtu.be/XW18rg94wvI AdFly
There is a completed example script at the bottom of the page, click here to view it
- First we open the quest object we made for the MCM, in the last tutorial here: here AdFly. Then open the script in editor.
- Now we are scripting the actual MCM menu. This is done within an event; onPageReset(String page) , which runs every time the page is loaded.
- Inside this event we need to declare in what order our entries will be displayed. MCM has 2 columns, you can fill them from top to bottom, so the first column fills up and then the 2nd. Or you can fill from left to right so it will fill each row from left to right, top to bottom.
- To do this we use the “SetCursorFillMode(LEFT_TO_RIGHT)” function.
- Then we can start adding actual entries using the functions found here: https://github.com/schlangster/skyui/wiki/MCM-API-Reference AdFly.
- I like to start with a heading, AddHeaderOption(“Mod Settings”).
- Then we start adding the actual buttons and sliders. We will start with toggle buttons.
- AddToggleOptionST(“ToggleMod”, “Toggle Entire Mod”, toggleMod). ID, Title and button text, Displayed Value bool.
- We need 3 of these “ToggleMod”, “resetStats” and “ForceCalc”.
- The ID is what defines this specific menu entry. The display is what the user sees and can be declared elsewhere using a variable, so if i set toggleMod = true , then the button will appear checked, if i set the variable to false, the button will appear empty. This of course applies to other options as well, an integer will display a number, a string will display its text etc..
- Next up we want some sliders to set how much each stat changes per level.
- AddSliderOptionST(“hp”, “Health”, hpF) , again the first value is the ID, 2nd is the text displayed to the user and 3rd is value of the slider, which we set to a variable. I like to append a “F” to the end of a float variable to keep track of what it is. You can also use string variables for the ID and Text Display.
- We want to repeat this for every stat, for this tutorial im only doing the 3 attributes HP, Stamina and Magicka.
- The way the new MCM works is with states, each option entry gets it’s own state, which is formatted like an event.
- So we have a toggle called ToggleMod, we write state ToggleMod and close the event with endState. Just like an event.
- Inside the state we can put 3 events; OnSelectST(), OnDefaultST() and OnHighlightST().
- First off we want to write the on select event, anything inside it is executed when the button is clicked.
- Lets update the checkbox, toggleMod = !toggleMod, this will toggle the boolean, which in turn toggles the checkbox the player sees, make sure you use the same variable you wrote when declaring the toggle in the onpagereset event.
- We then need to use SetToggleOptionValueST(ToggleMod), to force the checkbox to update. Toggling the boolean is all we need this button to do. Forcing the checkbox to update is necessary, otherwise it will only update when the entire page is reloaded.
- The 2nd event is OnHighlightST() which is triggered when this option is hovered over. Inside this event we will use the function SetInfoText(” This will turn off the mods features”) As you might have guessed this basically acts as a tooltip.
- The 3rd event OnDefault is not used for toggles.
- Repeat these steps for all of the toggles.
- Next we need to finish the slider options. We give each it’s own state, like we did for the toggles.
- First event is OnSliderOpenST(), which as you might guess, executes when the slider is clicked an opened. There are 4 essential functions we want inside it:
- SetSliderDialogStartValue(hpF) This is the numeric value the slider will display, you almost always want this to just display the same number as on the main menu, so use the same float we used in the AddSliderOption function earlier.
- SetSliderDialogDefaultValue(1) This is not associated with the default button. By default we want HP, stamina and magicka to increase by 1 per level.
- SetSliderDialogRange(-10, 10) Determines the minimum and maximum values of the slider. We want to allow players to choose to lose attributes on level up if they wish, so we allow negative numbers.
- SetSliderDialogInterval(1) The increment of the slider. every time you tap an arrow key the slider will change by this much and even pulling it with the mouse will be limited to multiples of this number. We can just leave this as 1.
- That concludes the slider open event, now we move onto the OnSliderAcceptST(Float Value) event, which is executed when the slider screen is accepted or otherwise closed.
- Inside we need two functions, hpF = value which updates the sliders displayed value to whatever the player chose.
- SetSliderOptionValueST(hpF) Which updates the displayed value to the newly updated floats value.
- Event 3 for a slider state is OnDefaultST() which is executed when the default button is clicked. inside the 2 functions are similar to the previous event.
- hpF = 1 set the float to what we want the default to be. Then SetSliderOptionValueST(hpF) which updates the slider value to match the float.
- and the final event for the sliders OnHighlightST() which functions exactly the same as it does for the toggle options and all other options for that matter.
- Repeat for all 3 sliders.
- We need to add all the variables, a Boolean for each toggle and float for each slider. bool property toggleModB Auto. float property hpF Auto.
- Then we save the script in the default creation kit editor (which most of you are probably already doing).
- Ensure it compiles without error and then we are done with scripting. save and close the script.
- Then open the properties. Set the 3 floats to default to 1 and the toggleMod bool to start ticked.
- Launch the game with this mod and skyui enabled.
- Check that the menu looks alright and the toggles toggle and the sliders slide.
- It all seems to be working for me, but I’d like some space after the headings and formatting.
- To add an empty option we just write AddEmptyOption(), Simple! I’m putting one beneath each header option and one after the 3 toggle options
- Now boot up the game and you should have a functioning menu, ready for features to be added.
- Adding the features will be covered in another tutorial, but you should be able to create your own MCM menus now. Don’t forget you can look up the syntax and other options here: https://github.com/schlangster/skyui/wiki/MCM-State-Options AdFly
Completed Example Script
Scriptname MCMScript_kx extends SKI_ConfigBase bool property toggleModB Auto bool property resetStatsB Auto bool property forceCalcB Auto float property hpF Auto float property magF Auto float property stamF Auto event OnPageReset(string page) SetCursorFillMode(LEFT_TO_Right) AddHeaderOption("Mod Settings") ;L1 AddEmptyOption();R1 AddToggleOptionST("ToggleMod", "Toggle Entire Mod", toggleModB);L2 AddToggleOptionST("ResetStats", "Reset mod altered stats", resetStatsB);R2 AddToggleOptionST("forceCalc", "Force Stat Calculation", forceCalcB);L3 AddEmptyOption();R3 AddHeaderOption("Attributes");L4 AddEmptyOption();R4 AddSliderOptionST("hp", "Health", hpF) AddSliderOptionST("mag", "Magicka", magF) AddSliderOptionST("stam", "Stamina", stamF) endEvent ;toggle states state ToggleMod event OnSelectST() toggleModB = !toggleModB SetToggleOptionValueST(toggleModB) endEvent event OnHighlightSt() SetInfoText("This turns off all mod functions. It does not reset stats.") endEvent endState state ResetStats event OnSelectST() resetStatsB = !resetStatsB SetToggleOptionValueST(resetStatsB) endEvent event OnHighlightSt() SetInfoText("This will removed this mods changes to stats once gameplay resumes") endEvent endState state forceCalc event OnSelectST() forceCalcB = !forceCalcB SetToggleOptionValueST(forceCalcB) endEvent event OnHighlightSt() SetInfoText("Restroactively updates stats according to current player level and current mod settings") endEvent endState ;slider states state hp event OnSliderOpenST() SetSliderDialogStartValue(hpF) SetSliderDialogDefaultValue(1) SetSliderDialogRange(-10,10) SetSliderDialogInterval(1) endEvent event OnSliderAcceptST(float value) hpF = value SetSliderOptionValueST(hpF) endEvent event OnHighlightSt() SetInfoText("Health change per level") endEvent endState state mag event OnSliderOpenST() SetSliderDialogStartValue(magF) SetSliderDialogDefaultValue(1) SetSliderDialogRange(-10,10) SetSliderDialogInterval(1) endEvent event OnSliderAcceptST(float value) magF = value SetSliderOptionValueST(magF) endEvent event OnHighlightSt() SetInfoText("Magicka change per level") endEvent endState state stam event OnSliderOpenST() SetSliderDialogStartValue(stamF) SetSliderDialogDefaultValue(1) SetSliderDialogRange(-10,10) SetSliderDialogInterval(1) endEvent event OnSliderAcceptSt(float value) stamF = value SetSliderOptionValueST(stamF) endEvent event OnHighlightSt() SetInfoText("Stamina change per level") endEvent endState
If you have a request or ideas for more features please leave comment or use the contact page. If you like my work remember you can support us without spending money. Details on the Support Us page.