Magnificent Ornk Swimmin' Salmon Posted January 22, 2006 Share Posted January 22, 2006 I'm working on a couple of scripts and have some questions on when, and how often, the default states are called. init_state - Is this called only the first time a town is entered, or every time a town is entered? start_state - The docs suggest this state is called every turn, but that makes no sense to me. The code that needs a home will be checking a SDF, and will either put a sign, or remove a sign (swap with a blank graphic) depending on that value. My gut says to put it in the start state, since actions in the town could cause the sign to appear/disappear, but it seems CPU intensive to do it that way if it runs that state every click. Any ideas? Link to comment Share on other sites More sharing options...
Magnificent Ornk Dikiyoba Posted January 23, 2006 Share Posted January 23, 2006 Start_state does check every turn so if the sign switch can be activated every turn, it makes sense to put it there. If it is only checking a SDF, I don't think it will slow the game down noticeably. On the other hand, you could use a special encounter that the party has to walk on before seeing the sign or after triggering the switch to check whether the terrain should be switched because then it would only be called once in a while. Of course, I think terrain switches back after leaving a town, so it would also have to go into init_state. So go back to the first hand. Dikiyoba. Edit: Double sig. Better than a double post, I guess... Link to comment Share on other sites More sharing options...
Magnificent Ornk Kelandon Posted January 23, 2006 Share Posted January 23, 2006 The INIT_STATE is called every time the party enters the town. As far as the sign, you've got two choices. You can either put it in the START_STATE — and Dikiyoba is right: a single get_flag in the START_STATE won't kill you (or even be noticeable) — or put a bunch of special encounter rectangles around the area so that the change takes place while the party is approaching the spot. Link to comment Share on other sites More sharing options...
Magnificent Ornk Swimmin' Salmon Posted January 23, 2006 Author Share Posted January 23, 2006 Start state then. I discovered the need for this because I have more than the arbitrary maximum number of signs in my town. So I decided to make a more versatile sign script and a new terrain. Hopefully it will work, and not drive me nuts. It was not encouraging to read the docs and see the following: Quote: How a terrain script is formatted A creature script has to begin with the line... *this message sponsored by the editors guild* Link to comment Share on other sites More sharing options...
Magnificent Ornk Dikiyoba Posted January 23, 2006 Share Posted January 23, 2006 That's to weed out the complete incompetents. Or maybe it's a typo. Dikiyoba. Link to comment Share on other sites More sharing options...
Unflappable Drayk John S Posted January 23, 2006 Share Posted January 23, 2006 The docs are just there to make you suffer. Ripping off someone else's code is much easier and less buggy. Link to comment Share on other sites More sharing options...
Magnificent Ornk Kelandon Posted January 24, 2006 Share Posted January 24, 2006 Quote: Originally written by Not Why:The docs are just there to make you suffer. Ripping off someone else's code is much easier and less buggy. To reinforce this: I have never written a town script (or a creature script or anything else) from scratch. I always copy from Jeff's code and then delete what I don't wont. And I wrote cutscene code that worked once. Now I literally copy and paste from old cutscenes every time I need a new cutscene. Link to comment Share on other sites More sharing options...
Magnificent Ornk Dikiyoba Posted January 24, 2006 Share Posted January 24, 2006 I borrow bits and pieces from other scripts (and my own too) whenever I need to do something in a script and then go to the docs if I can't find what I want. Then I test the completed script. It's slow but it works. Dikiyoba. Link to comment Share on other sites More sharing options...
Garrulous Glaahk Xoid Posted January 25, 2006 Share Posted January 25, 2006 Quote: Originally written by Kelandon:To reinforce this: I have never written a town script (or a creature script or anything else) from scratch. I always copy from Jeff's code and then delete what I don't wont. With other games I write pretty much everything from scratch - I don't care if I'm reinventing the wheel if I can do it better. (I'm not stupid: if someone does write code that is functionally equivalent or close to what I've already got, I'll use it.) I have written a couple of scripts from scratch, but I rarely do it anymore. I've written about a half dozen mostly from scratch. I only do either of the former when it's easier to write from scratch than to adapt someone else's work. Quote: Originally written by Not Why:The docs are just there to make you suffer. Ripping off someone else's code is much easier and less buggy. Frankly, someone with serious knowledge of Avernumscript and plenty of time needs to rewrite the documentation. It's not like Jeff is going to actually proof read the documentation he wrote. Link to comment Share on other sites More sharing options...
Magnificent Ornk Dikiyoba Posted January 25, 2006 Share Posted January 25, 2006 Even if he did, people often have trouble catching their own mistakes. Dikiyoba. Link to comment Share on other sites More sharing options...
Magnificent Ornk Swimmin' Salmon Posted January 25, 2006 Author Share Posted January 25, 2006 Frustrations abound. I've decided, based on the BUGS! thread, that create_text_bubble will not work from a terrain script. Does text_bubble_on_char work from within a terrain script?? Are there any text bubble calls that work from a terrain script? Grrr. Link to comment Share on other sites More sharing options...
Magnificent Ornk Kelandon Posted January 25, 2006 Share Posted January 25, 2006 The best way to know is to try. This is probably the first law of Avernumscript programming. Link to comment Share on other sites More sharing options...
Magnificent Ornk Swimmin' Salmon Posted January 26, 2006 Author Share Posted January 26, 2006 Well, it's done. I posted the script at The Codex . I never did find a way to get either text_bubble call to work reliably from within the script, so I used the clunky message_dialog call. Link to comment Share on other sites More sharing options...
Recommended Posts