antstubell Posted September 24, 2019 Author Share Posted September 24, 2019 Just a quick follow-up on STATES. Where can I find a list of them and explanations of when to use them? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted September 25, 2019 Share Posted September 25, 2019 There is the "empty state" that is where all non-state scripts have their code. Beyond that there is no list of STATES (other than perhaps those that comprise the United States :P ). You can use any string label for a state that you want. As far as when to use them, they are usually used when wanting to alter the behavior of something under certain conditions or for a limited time. That said, there is a "state method" for writing MCM scripts. While these contain specific events for the MCM, they too can use any string label for the name. Link to comment Share on other sites More sharing options...
maxarturo Posted September 25, 2019 Share Posted September 25, 2019 (edited) As IsharaMeradin said, you can give whatever name you want to a "STATE". For what i can see you don't fully understand how "States" works. Here is an example/crash course on "States". * This Is just an example emphasizing on " STATES ", i'll not define each condition/state of each build/constraction that this kind of script needs, example : If & when & what MENU to show for each building condition/situation should - should not fire, you'll understand it when you study it. * Remember that the " WHEN " a State's ENTER - EXIT is called is critical for the script to run smoothly/correctly, one bad call and it will mess up everything. ................................................................................................................................ Let's say you have an empty room where you will give the player two options to build. (activating the necessary ACTIVATOR).A build ROOMB build FORGEand you want this constructions to be done/executed in three different Sequences/Stages. 1st sequence = build ROOM (beds & wardrobes) or FORGE (Blacksmith forge & Smelter)2nd sequence = build Room's furnitures (chairs, tables... etc) or Forge furniture (chairs, tables... etc)3rd sequence = build Room's decoration or Forge decoration + extra containers Auto State WaitingEvent OnActivate(ObjectReference akActivator) if (akActivator == Game.GetPlayer()) GoToState("Busy") when the activator is in this STATE "BUSY" you won't be able to activate it after you EXIT the MENU Int iButton = MyBuildMenu.Show() Your FIRST MENU If BUTTON A = build ROOM Do your stuff, like check for the required Materials BuildRoom() > Now we jump to the FUNCTION that builds beds & wardrobes GoToState("sequence2") > After the BuildRoom() FUNCTION has finish it will go to this STATE ElseIf BUTTON B = build FORGE Do your stuff, like check for the required Materials BuildForge() > Now we jump to the FUNCTION that builds Blacksmith forge & Smelter GoToState("sequence2") > After the BuildRoom() FUNCTION has finish it will go to this STATE Else If you didn't have the required Materials it will go to a STATE that can be re-activated and show your FIRST MENU GoToState("Waiting") EndifEndifEndEventENDSTATE Now the NEXT TIME or everytime you will activate this, after it has finish with the buildingof your FIRST MENU and has jump to SEQUENCE2, it will only run the bellow State sequence2Event OnActivate(ObjectReference akActivator) if (akActivator == Game.GetPlayer()) GoToState("Busy") when the activator is in this STATE " BUSY " you won't be able to activate it after you EXIT this MENU Int iButton = MyBuildFurnitureMenu.Show() Your SECOND MENU If BUTTON A = build ROOM'S Furniture Do your stuff, like check for the required Materials BuildROOMFurnitue() > Now we jump to the FUNCTION that builds chairs, tables... etc GoToState("sequence3") > After the BuildROOMFurnitue() FUNCTION has finish it will go to this STATE ElseIf BUTTON B = build FORGE"S Furniture Do your stuff, like check for the required Materials BuildFORGEFurnitue() > Now we jump to the FUNCTION that builds chairs, tables... etc GoToState("sequence3") > After the BuildFORGEFurnitue() FUNCTION has finish it will go to this STATE Else If you didn't have the required Materials it will go to a STATE that can be re-activated and show your SECOND MENU GoToState("sequence2") EndifEndifEndEventENDSTATE Now the NEXT TIME or everytime you will activate this, after it has finish with the buildingof your SECOND MENU and has jump to SEQUENCE3, it will only run the bellow State sequence3Event OnActivate(ObjectReference akActivator) if (akActivator == Game.GetPlayer()) GoToState("Busy") when the activator is in this STATE you won't be able to activate it after you EXIT this MENU Int iButton = MyBuildDecorationMenu.Show() Your THIRD MENU If BUTTON A = build ROOM'S Decoration Do your stuff, like check for the required Materials BuildROOMDecoration() > Now we jump to the FUNCTION that builds decoration GoToState("BuildReady") > After the BuildROOMDecoration() FUNCTION has finish it will go to this STATE ElseIf BUTTON B = build FORGE"S Decoration Do your stuff, like check for the required Materials BuildFORGEDecoration() > Now we jump to the FUNCTION that builds decoration + extra containers GoToState("BuildReady") > After the BuildFORGEDecoration() FUNCTION has finish it will go to this STATE Else If you didn't have the required Materials it will go to a STATE that can be re-activated and show your THIRD MENU GoToState("sequence3") EndifEndifEndEventENDSTATE Now the NEXT TIME or everytime you will activate this, after it has finish with the buildingof your THIRD MENU and has jump to BuildReady, it will only run the bellow State BuildReadyEvent OnActivate(ObjectReference akActivator) if (akActivator == Game.GetPlayer()) Here you can Disable/Delete the ACTIVATOR, Or do whatever you like, example : Put an option that whenever player activates it will give an option/Menu to change ROOM for FORGE and vise versa The only requirement is imaginationEndEventENDSTATE State BusyEvent OnActivate(ObjectReference akActivator) As long as this is EMPTY, every time you try to ACTIVATE it, and after you have EXITED the MENU / SEQUENCE that this STATE has been called, it will do NOTHING and will keep doing the FUNCTION you had chosen from that MENU - SEQUENCE. You can also put a NOTIFICATION that will pop up every time you try to ACTIVATE it, Like a message saying : " Leave alone i'm working right now ! " EndEventEndState I hope this clarify things for you, and that i didn't make things more complicated..Have a happy modding !. Edit: Too many typos... Edited September 25, 2019 by maxarturo Link to comment Share on other sites More sharing options...
antstubell Posted September 25, 2019 Author Share Posted September 25, 2019 Not confusing me, let's say I'm getting there. Great example above which I will follow in future scripting.Thanks guys. Link to comment Share on other sites More sharing options...
maxarturo Posted September 26, 2019 Share Posted September 26, 2019 :thumbsup: Link to comment Share on other sites More sharing options...
Recommended Posts