|
||||||||||||||||||
Add Forum to Favorites | Send Topic To a Friend | View Forum FAQ | Track this topic |
Last Thread Next Thread ![]() |
| Fast Scripting - a pre-compiled approach |
|
![]() FrankBlack Member since: 11/11/2000 |
||||
|
|
||||
| Hey there, have some problems with the scripting article first of all i dont know what the iScriptInstruction (in CTeleport.txt) is, can u help me ? in IInstruction i have to declare the load,run,save funcs as virtuell or ? i never codet object oriented in visual basic, just visual c++ so i think when a let the func empty its virtuell ? would be nice if somebody could send me the working project greetz franky |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| Your article is very intersting and got me thinking. If I understood it correctly, the CScript class is a kind of Factory pattern. I still have a couple of questions: - somewhere you show a CScript_Open pseudocode. Is that a method of CScript (CScript::Open) declared privately because you have only one script in a file, or is it a special class because in one file you may have many different scripts stored ? - why do you need the Load method in IInstruction for data ? Can't you store the data directly inside each specialized instruction class (see example) or is it too memory intensive for some instructions ? e.g.: class CMsg_box : public IInstruction { public: CMsg_box(char* msg_text); virtual void Run(void); virtual ~CMsg_box(void); private: char* msg_text; }; In CScript::Open, you load both the opcode and the data and then create the instruction. Thanks for your answers. Red. |
||||
|
||||
![]() Tom GDNet+ Member since: 6/13/2000 From: Elkhart, IN, United States |
||||
|
|
||||
| I'm a little pissed off right now because Internet Explorer just jacked me while I was writing a reply to this topic. (Microsoft's programming team needs to be murdered.) Anyway, Ireland seems to have dropped off the face of the earth, so I'll try to answer your questions as best I can. FrankBlack: Ireland's article is ridiculously convoluted and incomplete. To be perfectly honest, I think his idea is incredibly clever, but he really should've let someone else write the tutorial for him, or at least given it to some people to review. With that said, I'll try to explain where he left off. IInstruction is an interface to every instruction class you make. You could have eight-billion commands and use the same interface for every single one of them. That's the beauty of Ireland's approach. IInstruction is an abstract class, which means it contains no executable code. This is how you make an interface. iScriptInstruction is the same as IInstruction. He must have missed that incongruity. Anonymous: CScript is its own class. It does not implement IInstruction. You use CScript as a starting point for loading a series of instructions; CScript points to the first one, and then NextInstruction does the rest of the work. Obviously, the Open procedure must be Public or you won't be able to call it from your program. (There are very few reasons to make a class procedure Private.) Instructions need to load their parameters from disk because these parameters will change from one instruction to the next. You wouldn't want to make a CTeleport instruction that always teleports the same person to the exact same spot, would you? Or a message box that always displays exactly the same message? You use parameters to give your language flexibility. Then you save them to disk and load them when you load the script. Hope this helps. ________ The two of you, who are obviously not as familiar with VB as you are C++, missed an even greater conundrum. Ireland proposes storing a Public array of children in the IInstruction class, so you can keep track of child instructions of conditionals, loops, and switches. That's fine and dandy, except for one thing: You can't declare a Public array in an object module. My only viable solution was to declare a Private array in each instruction class as needed (there are only five: If...Then, For...Next, Do...Loop, While...Wend, Select Case) and access it using Public procedures (GetChild and SetChild). I think Ireland was doing some drugs when he wrote that part of the article. I've been planning to rewrite Ireland's article and post it somewhere, but I wanted to get in touch with him first. However, since he appears to be gone forever, I may just go ahead and do it. |
||||
|
||||
![]() Mick Ireland Member since: 10/4/2001 |
||||
|
|
||||
| Hi, sorry about being away - I've had internet problems. Yeah, I've never been good at explaining things, so sorry for the hard time understanding.. Frank - VB can't have virtual methods as such, but yes you'd use virtual methods in c++ Tom - go ahead and re-write it if you like.. Just let me know where you put it though :-) Also, I didn't mean to have a public array in a VB class - that can't be done, as you said. What I was thinking was a method (or property) that accepted an index and basically just mapped it onto a private array, or even 2 or 3 different private IInstruction variables (in the case of a binary selection, where an array would be overkill). But it would behave in the same way as you'd expect a public array would. If I said to use a public array, then I was probably really tired at the time. And if you have anything else you need to ask me about, throw an email to airzone@ireland-soft.com |
||||
|
||||
![]() Mick Ireland Member since: 10/4/2001 |
||||
|
|
||||
| Oh, and BTW - Tom did a great job of answering the questions you guys asked :-) But c'mon! Drugs? Public Property Get Child( Idx As Long ) Public Property Set Child( Idx As Long, Chld As IInstruction ) In C++ you'd probably need Get and Set methods but I havn't done this in C++ at all (yet). |
||||
|
||||
![]() Tom GDNet+ Member since: 6/13/2000 From: Elkhart, IN, United States |
||||
|
|
||||
| Sorry about that, Mick. I know it's been a long time, but I stumbled across this and noticed what I jerk I was eight years ago. I want to apologize for that. I'm using this pre-compiled approach in a project even now, so I want to thank you properly for demonstrating the idea publicly. I did in fact rewrite the article, but I never published it, and it's long since gone. Hopefully this thread will clear up any confusion. Again, I'm sorry about my younger attitude. Keep up the great work. :) |
||||
|
||||
All times are ET (US)![]() |
Last Thread Next Thread ![]() |
|