Jump to content

run_town_script();


Thralni

Recommended Posts

Quote:
Originally written by Kelandon:
The call set_state_continue will do this for sure. I assume run_town_script will, but I'm not sure.
Will set_state_continue work in a scenario's START_STATE!? i thought, when using that call that it would go to a state in the scenario script, and not the town script, or is that wrong?
Link to comment
Share on other sites

It runs the state in the same script. So if you call set_state_continue(22) in town script t22Vasskolis.txt, it runs state 22 in t22Vasskolis.txt. If you call set_state_continue(24) in slithhome.txt, it runs state 24 in slithhome.txt.

 

When all else fails, read the docs. Well, except that I think that it's lying about the INIT_STATE. And possibly the DEAD_STATE. Not sure.

Quote:
void set_state(short new_state) - Changes the state of the script to new_state and immediately stops running the script. Has no effect in a dialogue script or in the states INIT_STATE, DEAD_STATE, or other predefined state types (except START_STATE).

 

void set_state_continue(short new_state) - Exactly like set_state, except that it doesn’t stop running the script.

Link to comment
Share on other sites

Well, I knew that. you see, the problem is that I have a line of code in the scenario scripts START_STATE, but it has to make something happen in the town you are presently in. So this is the siruation:

 

You set machinery on full power, ten ticks later you get a message saying you blew up the place by doing that, and the machinery (beam projectors and power sources) should stop working. However, this can only be achieved from the town script, and not the scenario script. That is the exact problem.

Link to comment
Share on other sites

It might work for you to have the scenario script set a flag. Then when the other script begins (later on) have the if...state_continue.. in that start state.

 

Otherwise, would it work to duplicate the state into each possible script which could be calling it?? I know Smoo did something similar in his latest scenario. At least the earlier versions had it, so you could check that out. It was around the island area.

 

*this message sponsored by Foss*

Link to comment
Share on other sites

The flag metho is what I'm using now. the only problem is, is that the player has to leave town to return later. To let the player know he should do this, I advise him to "leave and come back later when you are certain the wizards are not etc. etc."

 

Duplicating the state won't really work, i think. because the scenario script START_STATE is the only state that is run every turn, this is the only place this specific thing will work proparly. If I would put it in the town script, I would still have to reenter town to make it work.

 

Thanks for thr advice, though, but I'll think I'll just try the run_town_script, and if that doesn't work, I'll come back here.

Link to comment
Share on other sites

Now that I've read the description of the actual event that you are having happen, I don't understand the difficulty. The "turn on full power" state could set two flags to represent the point in time that it all stops working (present plus 10). The state_state could check if the present time is equal to the value of those flags recombined. Using an if statement to check, you then can put the terrain swaps and message right in the start state.

 

Would that work?

Link to comment
Share on other sites

The terrain can only be modified from the townscript. Not from the scenario script. the call that checks whether the ten ticks have passed is in the scenario script. if there is a call that can run a town script, thw problem is solved. If there isn't, then the party will have to reenter town. What you just suggested to do, is almost exactly what I have in the script, but as I already said: for terrain modification, unless a state is run in the townscript using set_terrain, the party hs to reenter town to make it all work.

Link to comment
Share on other sites

Whoops. I just re-read the first post again. Missed the "scenario script" bit that you said — I thought you were in a town script.

 

I should've just said yes. The call set_state_continue will only send you somewhere else within the script you're already in. Just use run_town_script and you'll be fine.

Link to comment
Share on other sites

Quote:
Originally written by Jumpin' Salmon:
Any particular reason you don't have all this stuff in the start state of the town script?
I think I already explained that twice: because only the scenario script's START_STATE is run every turn, and all the others, including the town script START_STATE, not. As I want that a particular message is displayed at a certain point in time (When flag x,y == 1 and the amount of ticks past from the moment that flag was set (which is stored in a variable: tick1) until now is tick1 + 10). this can only be done in the scenario script's START_STATE. that's why. Do you understand it now, or would you like to know more?

okay, Kelandon. Thanks. I haven't tried it out myself, as I'm bussy studying French for a test tomorrow.

Thanks to all of you who offered advice and tried to help.
Link to comment
Share on other sites

From the BoA Editor Docs:

Quote:
State 2 is automatically called by the game every turn the party is in the town. You can also write START_STATE as the number of this state.
I have never had a problem with this not occuring every turn, and is it really so critical that your message be displayed after exactly 10 turns? I have done this type of thing a number of times using the town script and it works fine.

 

One good reason to put your time checking code in the town script and not the scenario script is that it takes a bit of time to do the check, and so if you have a large number of checks, it can slow things down. So, it's better to have this happen only when you're in one town than through out the entire scenario. Besides, if the code applies to only that one portion of the scenario, it is a good idea to place it in the script that relates to that part of the scenario directly. That way the code easier to understand, maintain and alter.

Link to comment
Share on other sites

I think that Thralni is planning to make it possible to leave the town before the event actually occurs. The town's START_STATE is only run every turn while you're in town — if the party has left already, then the START_STATE won't be run. Hence he must use the scenario's START_STATE, which is the only state that is run every single turn in the scenario regardless of where the party is.

Link to comment
Share on other sites

If leaving the town is the worry, a possible compromise is to the exiting town situation is just to call the relevant node in the EXIT_STATE if the party leaves before the timer runs out.

 

Also, do not forget that combat mode allows increased mobility.

Link to comment
Share on other sites

There is not enough time (unless you are in combat mode) to go from the control room all the way to the exit of town, and I also don't really want people to do that. I want the player to witness what he did. The only thing I have to implement is the wizards running to you to kill you and restore the system (which won't work).

 

Oh really... I didn't know it can be put in the town script's START_STATE. I'll put it there then. It will make things an awful lot easier. That also means you were right, salmon. My apologies for my lack of patience.

 

But then again, if the party does leave before the timer is actually ready running, then this becomes a problem. I could also make the amount of ticks to pass 5, actually. It is not really necessary for it to be 10, but it seemed like the right amount of time for the machines to blow up.

 

Quote:
If you have all of this done by one SDF, a single get_flag check every turn doesn't slow down anything noticeably.

 

There are many right ways to do this and only a few functional wrong ways.

this is what happens now, and I don't really see an urge to change it.

 

I think I will put everything in the town script's START_STATE.

Link to comment
Share on other sites

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