Calling one town state from another

Error message

  • Notice: Trying to access array offset on value of type int in element_children() (line 6595 of /var/www/pied-piper.ermarian.net/includes/common.inc).
  • Notice: Trying to access array offset on value of type int in element_children() (line 6595 of /var/www/pied-piper.ermarian.net/includes/common.inc).
  • Notice: Trying to access array offset on value of type int in element_children() (line 6595 of /var/www/pied-piper.ermarian.net/includes/common.inc).
  • Notice: Trying to access array offset on value of type int in element_children() (line 6595 of /var/www/pied-piper.ermarian.net/includes/common.inc).
  • Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /var/www/pied-piper.ermarian.net/includes/common.inc).
AuthorTopic: Calling one town state from another
Law Bringer
Member # 2984
Profile Homepage #0
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?

--------------------
Encyclopaedia ErmarianaForum ArchivesForum StatisticsRSS [Topic / Forum]
My BlogPolarisI eat novels for breakfast.
Polaris is dead, long live Polaris.
Look on my works, ye mighty, and despair.
Posts: 8752 | Registered: Wednesday, May 14 2003 07:00
...b10010b...
Member # 869
Profile Homepage #1
Why do you need to call another state? Just cut and paste the code for the dialog box into a conditional statement within the START_STATE.

--------------------
The Empire Always Loses: This Time For Sure!
Posts: 9973 | Registered: Saturday, March 30 2002 08:00
Law Bringer
Member # 2984
Profile Homepage #2
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.

[ Monday, April 09, 2007 02:45: Message edited by: Dr. Johann Georg Faust ]

--------------------
Encyclopaedia ErmarianaForum ArchivesForum StatisticsRSS [Topic / Forum]
My BlogPolarisI eat novels for breakfast.
Polaris is dead, long live Polaris.
Look on my works, ye mighty, and despair.
Posts: 8752 | Registered: Wednesday, May 14 2003 07:00
...b10010b...
Member # 869
Profile Homepage #3
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.

--------------------
The Empire Always Loses: This Time For Sure!
Posts: 9973 | Registered: Saturday, March 30 2002 08:00
Infiltrator
Member # 5576
Profile Homepage #4
In general you don't have to be too stingy with states, you have about 90 available per town, and very few towns need very many of them. The scripts are a lot easier to read and fix if they are more thoroughly broken down into separate states.

--------------------
Überraschung des Dosenöffners!
"On guard, you musty sofa!"
Posts: 627 | Registered: Monday, March 7 2005 08:00
Law Bringer
Member # 2984
Profile Homepage #5
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.

--------------------
Encyclopaedia ErmarianaForum ArchivesForum StatisticsRSS [Topic / Forum]
My BlogPolarisI eat novels for breakfast.
Polaris is dead, long live Polaris.
Look on my works, ye mighty, and despair.
Posts: 8752 | Registered: Wednesday, May 14 2003 07:00
Lifecrafter
Member # 6193
Profile Homepage #6
The limit on states is much higher than 90. I was just testing it, and got it to call state 1000. I'm not sure what the real limit is; I stopped testing when I decided that running out of states is about impossible.

[ Monday, April 09, 2007 11:03: Message edited by: The Gators Win it All....... Again ]

--------------------
Guaranteed to blow your mind.

Frostbite: Get It While It's...... Hot?
Posts: 900 | Registered: Monday, August 8 2005 07:00
Guardian
Member # 6670
Profile Homepage #7
Did you have 1000 states in total, or just a state numbered 1000?

--------------------
The One Ring Theory Assignment to RULE THEM ALL!
Posts: 1509 | Registered: Tuesday, January 10 2006 08:00
Lifecrafter
Member # 6193
Profile Homepage #8
Just a state numbered 1000, but it should work anyhow.......

OK, we're talking about BoA here, so it's quite likely it has some arbitrary limit on number of states. I don't have the patience to copy and paste 1000 states. :P

--------------------
Guaranteed to blow your mind.

Frostbite: Get It While It's...... Hot?
Posts: 900 | Registered: Monday, August 8 2005 07:00
Guardian
Member # 6670
Profile Homepage #9
Give me a moment, and I'll whip up a Perl script to do that. :)

--------------------
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.

[ Monday, April 09, 2007 14:19: Message edited by: Dintiradan ]
Posts: 1509 | Registered: Tuesday, January 10 2006 08:00
Lifecrafter
Member # 6193
Profile Homepage #10
There is a 200 node limit for each town.

--------------------
Guaranteed to blow your mind.

Frostbite: Get It While It's...... Hot?
Posts: 900 | Registered: Monday, August 8 2005 07:00
Infiltrator
Member # 5576
Profile Homepage #11
Ok, that sounds like the right number. I guessed ~90 because Jeff wrote a comment in some scripts that said, "States you write yourself should be numbered from 10-100."

--------------------
Überraschung des Dosenöffners!
"On guard, you musty sofa!"
Posts: 627 | Registered: Monday, March 7 2005 08:00
Law Bringer
Member # 2984
Profile Homepage #12
The API documentation and the actual implementation just happen to come from too barely connected parallel universes, as always. :P

--------------------
Encyclopaedia ErmarianaForum ArchivesForum StatisticsRSS [Topic / Forum]
My BlogPolarisI eat novels for breakfast.
Polaris is dead, long live Polaris.
Look on my works, ye mighty, and despair.
Posts: 8752 | Registered: Wednesday, May 14 2003 07:00