Jump to content

Terrain script calls


Recommended Posts

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

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

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

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

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

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

Guest
This topic is now closed to further replies.
×
×
  • Create New...