Jump to content

Calling one town state from another


Aran

Recommended Posts

I had some trouble with calling a town script from dialogue.

 

Namely, I wanted the dialogue to show up and end (it was an "INN" message, meaning that the player had just rented a room), before the next message crops up (which told the player what happened during the night).

 

run_town_script() made the dialog box pop up immediately before they left talk mode, which wasn't really what I wanted.

 

So instead, I let the dialogue node set an SDF, which the town script's state 2 would constantly check.

 

This should trigger the dialog box in the next move after talk mode was left.

 

Unfortunately I don't know how to call another town script state from state 2. State 2 is the state that is called every move.

 

The docs tell me that set_state_continue will not only call that state, but also make that state the one that gets constantly repeated.

 

But I only want to call that state once, and then move back to state 2.

 

Possible?

Link to comment
Share on other sites

Whoops.

 

I think this is probably pretty easy. Just execute set_state_continue again at the end of my special state to jump back to state 2.

 

I have to stop thinking of states as functions or subroutines. They're apparently more like statement numbers jumped to with GOTO.

 

Edit: Yes, that works too, but it's quite a lengthy block of instructions and I have some kind of allergy against huge code snippets in an if - especially when it's only called once, and has a completely separate purpose.

 

Edit2: My double set_state_continue() works perfectly. Talk mode ends, I make another move, the dialog box appears, and everything is just great.

 

Since the dialog box appears only once, I can also assume that the state does not become the new START_STATE.

Link to comment
Share on other sites

Quote:
Originally written by Dr. Johann Georg Faust:
Edit: Yes, that works too, but it's quite a lengthy block of instructions and I have some kind of allergy against huge code snippets in an if - especially when it's only called once, and has a completely separate purpose.
I suppose. But it's good to economise on states where possible, on the basis that one only has a finite number to work with in any given town.
Link to comment
Share on other sites

Well, I just discovered the limits to my "jump to extra state, then jump back" policy.

 

It only works, obviously, if my state will only be triggered once. Everything else results in an endless loop, without implementing some extra logic that makes it even more confusing than the "lump it all in one state" method.

Link to comment
Share on other sites

Give me a moment, and I'll whip up a Perl script to do that. smile

 

--------------------

EDIT: Well, I just put states 150-999 into a town script with no complaint. However, they were all empty. I'm going to try something more devious: get every one to call the next one in succession, until #999 just prints out a message_dialog.

 

EDIT: Huh. I take it all back. It took nearly a half second before message_dialog("Hello World!","") was run after travelling through 950 states, but it did come up.

 

EDIT: Maybe it's dialog scripts that have the limit for the number of nodes. I remember something like that being the reason for Smoo putting all the merchants in Rats Aplenty in a separate town.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...