Jump to content

Stopping activation within a function


antstubell

Recommended Posts

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

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 ROOM
B build FORGE
and 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 Waiting
Event 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")
Endif
Endif
EndEvent
ENDSTATE
Now the NEXT TIME or everytime you will activate this, after it has finish with the building
of your FIRST MENU and has jump to SEQUENCE2, it will only run the bellow
State sequence2
Event 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")
Endif
Endif
EndEvent
ENDSTATE
Now the NEXT TIME or everytime you will activate this, after it has finish with the building
of your SECOND MENU and has jump to SEQUENCE3, it will only run the bellow
State sequence3
Event 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")
Endif
Endif
EndEvent
ENDSTATE
Now the NEXT TIME or everytime you will activate this, after it has finish with the building
of your THIRD MENU and has jump to BuildReady, it will only run the bellow
State BuildReady
Event 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 imagination
EndEvent
ENDSTATE
State Busy
Event 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 ! "
EndEvent
EndState

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 by maxarturo
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...