As I look at the two scripts, I'm not sure what you want where. I other words, when you want certain things to happen. Events are all controlled by how the script is written. The flow is basically controlled by the states. If you want this to happen then you go to that state. If you want that to happen then you go to this state.
These scripts are not understandable at all in order to combine them. I'm sorry. For anybody to combine them, we will need a lot more information and I'm not sure what even to tell what information we need.
Where did you get these scripts to begin with?
Terry