I'm pretty new to making a game scriptable and I'd like some advice from people who are more experienced than me. I understand the technical side of scripting quite well, and I've opened a significant part of my game engine up to the VM now.
Beyond that, I've identified a need for three types of scripts.
The first type of script is what I'm calling a behaviour script. Object which have a behaviour script attached to them call this script once per update loop and run the script in it's entirety. The script could do absolutely anything, so it's basically a substitude for hardcoded game object behaviour. I understand this.
The second type of script is what I'm callig event-driven behaviour. This includes the on- events you might get in something like flash. For example, On-Die. If an object has an on-die script attached to it, this script is run in its entirety when the object dies. I understand this too.
The third type of script is more ambiguous, and hard for me to describe, but it's one which changes program flow. It's probably best described with an example.
Let's say I have a palace with a throne room and a King sitting on the throne. As I approach the King, I want a scripted scene to begin, where the King speaks to my character, my character approaches, then changes animation sequence, replies to the king and finally the king stands up, gives me an object and says something else. Now I am back in control again.
Now I can trigger this sequence with one of my event-driven scripts, I suppose. I could have an on-trigger event which is triggered when my character stands anywhere near the throne in the throne room. At this point, my cut-scene, sequence, call it what you will begins. But I don't quite understand how program flow works at this point. I want to be able to script this scene really. I could have a separate script-type language to describe cut scenes, but I would prefer not to. I've implemented a LuaVM and it works very nicely. Why recreate the wheel? Lua is powerful and readable.
What I don't understand is quite how program flow works with a scripted cut scene like this. Some events are queued, ie they cannot happen until other events have happened. Some events happen in time with other events, ie: as the king reaches out to hand me an object, my character needs to reach out to grab it at the same time.
I'm also wondering about interactions with scripts. For example, let's say I have a tutorial world. I'm in a dungeon and the jailer is my guide. He tells me that I need to look under the bed for a key. Control returns to me. When I find the key, back to the jailer who tells me the next thing to do and how to do it. Is this a whole long sequence of triggers and new scripts? Or is there a better way of sequencing these interactions? I guess it seems to me at the moment that you could very easily end up with hundreds of very little bits of scripts and that doesn't seem very practical. So it's probably the wrong way to go about it.
I've never had to "think script" before so I guess you could consider me a bit of a noob in this regard.
Beyond that, I've identified a need for three types of scripts.
The first type of script is what I'm calling a behaviour script. Object which have a behaviour script attached to them call this script once per update loop and run the script in it's entirety. The script could do absolutely anything, so it's basically a substitude for hardcoded game object behaviour. I understand this.
The second type of script is what I'm callig event-driven behaviour. This includes the on- events you might get in something like flash. For example, On-Die. If an object has an on-die script attached to it, this script is run in its entirety when the object dies. I understand this too.
The third type of script is more ambiguous, and hard for me to describe, but it's one which changes program flow. It's probably best described with an example.
Let's say I have a palace with a throne room and a King sitting on the throne. As I approach the King, I want a scripted scene to begin, where the King speaks to my character, my character approaches, then changes animation sequence, replies to the king and finally the king stands up, gives me an object and says something else. Now I am back in control again.
Now I can trigger this sequence with one of my event-driven scripts, I suppose. I could have an on-trigger event which is triggered when my character stands anywhere near the throne in the throne room. At this point, my cut-scene, sequence, call it what you will begins. But I don't quite understand how program flow works at this point. I want to be able to script this scene really. I could have a separate script-type language to describe cut scenes, but I would prefer not to. I've implemented a LuaVM and it works very nicely. Why recreate the wheel? Lua is powerful and readable.
What I don't understand is quite how program flow works with a scripted cut scene like this. Some events are queued, ie they cannot happen until other events have happened. Some events happen in time with other events, ie: as the king reaches out to hand me an object, my character needs to reach out to grab it at the same time.
I'm also wondering about interactions with scripts. For example, let's say I have a tutorial world. I'm in a dungeon and the jailer is my guide. He tells me that I need to look under the bed for a key. Control returns to me. When I find the key, back to the jailer who tells me the next thing to do and how to do it. Is this a whole long sequence of triggers and new scripts? Or is there a better way of sequencing these interactions? I guess it seems to me at the moment that you could very easily end up with hundreds of very little bits of scripts and that doesn't seem very practical. So it's probably the wrong way to go about it.
I've never had to "think script" before so I guess you could consider me a bit of a noob in this regard.