Simple Chat extension - making a more complex conversation

I’m still having this problem and I don’t know what’s doing it. :confused:

Try the bug command RULES. Then play the game. That will make the game tell you what rules it considers as you play. It might help you pin down what rule is resonsible for the error. (To turn it off, type RULES OFF.)

Thanks. :smiley: 0k I tried that and this is what I get when talking to someone:

All I know is that this started happening very recently and that the error always occurs just before the game replaces text using moods. For example:

Is there any way to find out what object 55 is? I tried completely quoting out all the scripted objects from the game but there are still dozens of unscripted ones it could be. I dunno if it helps, but apparently you can replicate it using this script.

The error means (most likely) that you are trying to check the mood of an object that doesn’t have that property. You need to show the code you have, otherwise it’s pretty hard to try to guess how to fix it.

It might help.
Perhaps you are doing something like this:

Instead of talking to Doctor West: run a conversation from Doctor_West_hello. Report giving text for Doctor_West_hello: if the noun is a gambler, instead say "It's a terrible shame isn't it?"
It would be easy to suppose that ‘the noun’ in the ‘report giving text for’ rule would be the same as the noun of the ‘talking to’ action (i.e. Doctor West), but it isn’t.
It isn’t because the ‘instead’ rule ends the ‘talking to’ action and *instead * starts a ‘giving text for’ action (just as it’s supposed to do).
Actually, the ‘giving text for’ action has no ‘noun’ at all. That is because it is not defined as an action applying to a thing; rather it is an action applying to a chat node (and a chat node is not an ‘object’ but just a ‘kind of value’).
So, the ‘giving text for’ action simply doesn’t have a ‘noun’; it just has a ‘chat node understood’. And asking the game whether the non-existent noun of that action has a given property will make it all confused and then blame you for it. :slight_smile:

Hmm - coincidentally, I just spent yesterday doing a re-write of the Simple Chat extension to use activities instead of actions for “Giving text”, etc, which would avoid this sort of issue. Maybe I should post it?

If it fixes the problem then it would be awesomely helpful since every character I have has replacement nodes that activate and deactivate depending on how I want them to act to a given player (It keeps things neater from my perspective). :smiley: And they have a weird habit of not activating and deactivating. Unfortunately I can’t really show you the whole script since most of it is separated into different custom extensions and it would be a massive pain to put back together and trim down to something readable. If I tried I would end up creating scripting mistakes. :confused:

I mostly use word replacement, but when I need to change a whole node in order to send the conversation in a different direction I tend to do this:

This worked fine in the past, so I dunno why it would mess up now…

It sounds like using my version might be more trouble than it’s worth, since you’ve already written a large number of chat nodes, and these would have to be at least somewhat re-written. I’ll post it here anyway (in the spoiler tag so it doesn’t take up too much space on the page).

[spoiler][code]Version 1/130212 of Activity-based Simple Chat by Shadow Wolf begins here.

Section - Chat Nodes and Activation

A chat node is a kind of thing. No-quip-chosen is a chat node.
Node-type is a kind of value. The node-types are activated, non-active, choose-once, and show-once.
A chat node has a node-type. The node-type of a chat node is usually activated.

A chat node has a text called quip. The quip of a chat node is usually “”.

To activate (chosen node - a chat node): now the chosen node is activated.
To deactivate (chosen node - a chat node): now the chosen node is non-active.

Section - Quittability

Chat quittability is a truth state that varies. Chat quittability is true.

To allow exiting on zero: now chat quittability is true.
To forbid exiting on zero: now chat quittability is false.

To decide whether exiting on zero is allowed: if chat quittability is true, decide yes; decide no.

Section - the Table of Current Choices

Table of Current Choices
result
a chat node
with 20 blank rows

The rowcount is a number which varies.

To link to (response - a chat node):
unless response is non-active or the number of blank rows in the Table of Current Choices is 0:
choose a blank row in the Table of Current Choices;
now the result entry is the response;

To reset the links:
blank out the whole of the Table of Current Choices.

Section - Finding Responses

Finding responses to something is an activity on chat nodes.
To find responses to (C - a chat node): carry out the finding responses to activity with C.

Section - Giving Text For

Giving text for something is an activity on chat nodes.
Rule for giving text for a chat node (called the current node):
if the initial appearance of the current node is not “”:
say the initial appearance of the current node;
otherwise:
say “Error - no text for [the current node]”.

Before giving text for a choose-once chat node (called the current node):
now the current node is non-active.

To give text for (C - a chat node): carry out the giving text for activity with C.

Section - Showing Links to

Prior node is a chat node that varies.

Showing the link to something is an activity on chat nodes.
Rule for showing the link to a chat node (called the current node):
if the quip of the current node is not “”:
say the quip of the current node;
otherwise:
say “Error - no quip for [the current node]”.

Before showing the link to a show-once chat node (called the current node):
now the current node is non-active.

To show the link to (C - a chat node): carry out the showing the link to activity with C;

Section - Readchoice I6 routine

Include (-
[ ReadChoice low high i;
for (::slight_smile: {
print ">> ";
KeyboardPrimitive (buffer, parse);
i = TryNumber (1);
if (i >= low && i <= high) return i;
else print "[Please answer by typing a number between ", low, " and ", high, “.]^”;
}
];
-).

To decide what number is the choice made from (low value - a number) to (high value - a number): (- ReadChoice ( {low value}, {high value} ) -).

Section - Starting a Conversation

To start a conversation with (current node - a chat node):
let previous node be no-quip-chosen;
let next node be no-quip-chosen;
while current node is not no-quip-chosen:
give text for the current node;
say “[paragraph break]”;
reset the links;
find responses to the current node;
if the Table of Current Choices is empty:
now the current node is no-quip-chosen;
otherwise:
sort the Table of Current Choices in result order; [shuffles all blank rows to the bottom]
let rowcount be the number of filled rows in the Table of Current Choices;
repeat with current row running from 1 to the rowcount:
say “[current row]) [run paragraph on]”;
choose row current row in the Table of Current Choices;
now the prior node is the current node;
show the link to the result entry;
say “[line break]”;
let choice made be 0;
if exiting on zero is allowed:
say “[italic type]([simple chat zero option])[roman type][line break]”;
now choice made is the choice made from 0 to rowcount;
otherwise:
now choice made is the choice made from 1 to rowcount;
if choice made is 0:
now next node is no-quip-chosen;
say “[line break][run paragraph on]”;
otherwise:
now next node is result in row choice made of the Table of Current Choices;
now previous node is current node;
now current node is next node.

To say simple chat zero option:
say “or 0 to say nothing[run paragraph on]”.

Section - German (for use with German by Team GerX)

To say simple chat zero option:
say “oder 0 um nichts zu sagen[run paragraph on]”.

Section - French (for use with French by Eric Forgeot)

To say simple chat zero option:
say “ou 0 pour ne rien dire[run paragraph on]”.

Activity-based Simple Chat ends here.

---- DOCUMENTATION ----

Section: Changes from Simple Chat

Activity-based Simple Chat is a rewrite of Mark Tilford’s Simple Chat extension. It uses activities where Simple Chat uses actions, in order to simplify the process of writing rules for chat nodes. Among other things, this means that the original player action (including noun, second noun, etc.) that initiates the conversation is always available rather than being overridden by nested actions.

It also turns chat nodes into things instead of values, allowing standard object properties to provide link names and text for chat nodes - so many chat nodes will require no additional rules except to build the link menu.

I’ve also updated some of the table handling, to avoid maintaining a global row count and in order to simplify the syntax. Some other unnecessary globals have also been removed.

For questions, bug reports, etc, contact shadowolf3400@gmail.com

Section: Using Chat Nodes

A “chat node” is a conversational object, typically a quip spoken by the player, with a response from an NPC. By default, the “quip” property will be the player’s quip (as shown by the extension’s menus), while the “initial appearance” property is the response text. This makes defining a basic chat node fairly simple:

Node-harry-hello is a chat node with quip "'Hello, Harry.'". "Harry says, 'Hi, player! What's up?'".

(Note that with this syntax it is important to be sure there is a period between the quip and the initial appearance. In particular, if you have single quotes around the quip, you need to ensure that there is a period outside of the quotes, as above. Otherwise the compiler will not set the property correctly.

You can override the use of the quip property by providing a “Rule for showing the link to ___:” These rules can be qualified with the usual clauses. In particular, if you want to base the text on the chat node just displayed, you can test the “prior node” value:

Rule for showing the link to harry-good-bye when the prior node is harry-hows-tricks: say "'Well then, good-bye.'".

To override the use of initial appearance for the NPC response, create “Rule for giving text for ___:” Again, rules can be qualified with the usual clauses.

To build the menu of player choices, create a “Rule for finding responses to ___:” For each quip the player may pick, call the “link to ___” phrase for the appropriate node. Non-active nodes (see the chat node types below) will not be displayed. Additional conditional checks can be built into this rule as well. If you want to copy the responses of another node, you can call “Find responses to ___.” Be careful to avoid circular loops.

If there is no “rule for finding responses”, then the conversation will end. There can be at most twenty links displayed for a given node (should be plenty)! But this can be increased by extending the Table of Current Choices with additional blank rows.

Chat node types: There are four chat node states: activated, non-active, shown-once, and choose-once. Activated is the default with normal behavior. Non-active nodes will never be linked to until the state is explicitly changed (You can use the phrases “activate ___” or “deactivate ___”). A shown-once node will become non-active once the link has been displayed once - if the player doesn’t select it, they will never get the option again. A choose-once node will become non-active only once it has been picked by the player, after which it will not be displayed again.

To begin a conversation, simply use the phrase “Start a conversation with ___” (where the blank is the first node of the conversation). This can be used in the rule for a “Talk to…” action, for instance.

Section: Exiting a conversation

As with Simple Chat, the default is that the player can choose “0” to exit the menus and return to the normal prompt. The code can instead “Forbid exiting on zero” to turn this behavior off, or “Allow exiting on zero” to turn this behavior on again. I’ve included the German and French translations of the “simple chat zero option” text.

Example: *Simplest Chat - shows the basic functionality. This parallels the example in Mark Tilford’s version.

*: "Simplest Chat" by Shadow Wolf

Include Activity-based Simple Chat by Shadow Wolf.

Talking to is an action applying to one visible thing.

Understand "talk to [someone]" as talking to.
Report talking to: say "You have nothing to say.".

Living Room is a room. Larry is a man in Living Room.

chat-hello-larry is a chat node. "Larry looks up as you approach him."
Rule for finding responses to chat-hello-larry:
	link to chat-hows-tricks; link to chat-good-bye.

chat-hows-tricks is a chat node with quip "'How's tricks?' ". "'Just fine.'".
Rule for finding responses to chat-hows-tricks: link to chat-good-bye.
Rule for giving text for chat-hows-tricks: deactivate chat-hows-tricks; continue the activity.

chat-good-bye is a chat node with quip "'Good bye.' ". "'You too.'".
Rule for showing the link to chat-good-bye when the prior node is chat-hows-tricks:
	say "'Well then, good bye.' ".

Instead of talking to Larry: start a conversation with chat-hello-larry.

Test me with "talk to larry / 1 / 1 / talk to larry / 1 / talk to larry / 0".

Example: **Less Simple Chat - Shows some of the more advanced functionality. Functionally identical to the example in Tilford’s extension, although the order of menu options is likely different.

*: "Less Simple Chat" by Shadow Wolf

Include Activity-based Simple Chat by Shadow Wolf.

Talking to is an action applying to one visible thing.

Understand "talk to [someone]" as talking to.
Report talking to: say "You have nothing to say.".

When play begins:
	forbid exiting on zero.

Living Room is a room. Harry is a man in the Living Room. He carries Finnegans Wake.

Harry-chat-hello is a chat node. "Harry looks up as you approach him."
Rule for finding responses to Harry-chat-hello:
	link to Harry-chat-book; link to Harry-chat-fire; link to Harry-chat-again; link to Harry-chat-goodbye.

Harry-chat-book is a choose-once chat node with quip "What was that book you told me about?". "'It's by some guy called Finnegan Wake, and I think it's in Irish or something. Do you want it?'"
Rule for finding responses to Harry-chat-book:
	link to Harry-chat-want-it; link to Harry-chat-dont-want.

Harry-chat-want-it is a chat node with quip "'Sure.' ".
Rule for giving text for Harry-chat-want-it: 
	move Finnegans Wake to player;
	say "Harry hands the book to you. ".
Rule for finding responses to Harry-chat-want-it: Find responses to Harry-chat-hello.

Harry-chat-dont-want is a chat node with quip "'No, thanks.' ". "Harry sighs. 'I'm never going to get rid of it.'"
Rule for finding responses to Harry-chat-dont-want: Find responses to Harry-chat-hello.

Harry-chat-fire is a show-once chat node with quip "'Run! Fire!'". "'We are only pixels on a two-dimensional screen. There is nowhere to run to.' Harry's words shatter the fourth wall.".
Rule for finding responses to Harry-chat-fire: Find responses to Harry-chat-hello.

Harry-chat-again is a non-active chat node with quip "'Didn't we have this conversation before?'". "'The world is one big circle, and we are doomed to repeat ourselves.'"
Rule for finding responses to Harry-chat-again: Find responses to Harry-chat-hello.

Harry-chat-goodbye is a chat node with quip "'See you later, Harry.'". "'Later!'"
After giving text for harry-chat-goodbye: activate Harry-chat-again.

Instead of talking to Harry: start a conversation with Harry-chat-hello.

Test me with "talk to harry/2/2/talk to harry/2/1/1/2/i/talk to harry/2".

[/code][/spoiler]

If my guess is true, it’s not the conditions in the ‘instead of talking’ rules that cause the problem; the problem would occur because you test conditions on the noun in the ‘report giving text for’ rules, like in:

Report giving text for Doctor_West_hello when the noun is a gambler: instead say "Ain't that a shame.".

Hmm, well I don’t do that, they all say stuff like ‘Instead of talking to Sid when the Gender of the player is boy and the Profession of the player is Gambler’. Since all the newest stuff is for the Attack module my guess would be it has something to do with the extra scripting I added. Maybe

Well I went through my entire game and quoted out everything to do with Attack and it still happens. I got rid of all the game locations but one room and it still happens. I think it really must be the chat thing like you said, but I really don’t know how to fix that.

Shadow Wolf, I tried to install your extension but Inform thinks the spacing is wrong, could you post a link to the extension as a file? I really like the sound of some of the new features in it. This error has kinda brought my gamemaking to a standstill and I would much rather re-write my nodes than be stuck with it.

Skylark, the forum converts tabs to spaces - you have to convert them back to use the extension I posted above. (three spaces to one tab works).

I put up a slightly more recent version here (added an option to change the prompt): pastebin.com/CrrHxXVy

You can also do it like this:

Hit “quote” to the post that has the code you want in it. You should get a comment box with the entire original comment in it.

Find the code in that post. Copy it and paste it into Inform.

If the original poster copied the code from Inform, then the tabs should be preserved. (If not, there’s no way to get them back.)

Hope this helps! It should be a lot less tedious and prone to introducing errors than trying to reconvert the spaces into tabs.

Thanks both of you! I haven’t gotten very far with my rewrite but in the nodes I have tested so far the error seems to be completely gone! Shadow, you should really publish that extension, it is way more clean and compact than simple chat and I love that you ditched the list-based management of nodes and made it so you can add proper scripts to them. :slight_smile:

Urrrgh. I keep getting this error but I am sure I have the spacing right:

I’ve trimmed all the text out of the node to make it simpler to read. I really don’t get why this keeps on happening!

Rex-Talk is a chat node with quip "(Go to main menu)". Rule for giving text for Rex-Talk: if Rex is unfamiliar: Say "Intro text". Now Rex is familiar. Otherwise: Say "Meeting again text".

You’ve got periods (full stops) in a few places where you need semicolons.
This –

– should beRule for giving text for Rex-Talk: if Rex is unfamiliar: say "Intro text."; now Rex is familiar; otherwise: say "Meeting again text.".
Only use periods at the very end of a rule (or inside quotes).

Oh right, sorry. :stuck_out_tongue:

I seem to have a lot of trouble with these but I’m getting a lot better at it with all your help. :wink: At the moment I’m having this really weird problem at the moment with a ‘To say’ script that allows me to imput a description based on what type of character is playing in a specific scene. Basically what happens is that if, say, the player is a gambler and some text with [Classdata] appears it will print all three gambler ‘say’ commands one after the other. The same is true for all the other classes. Can anyone help? :blush:

At the moment it looks like this:

To say Classdata: If Slygambler is Slyistrouble: If the profession of the player is gambler: Say “”; If the profession of the player is detective: Say ".”; If the profession of the player is thief: Say “.”; [otherwise: Say "";] If Slygambler is SlyNON: If the profession of the player is gambler: Say “”; If the profession of the player is detective: Say ".”; If the profession of the player is thief: Say “.”; [otherwise: Say "";] If Slygambler is SlyBad: If the profession of the player is gambler: Say “”; If the profession of the player is detective: Say ".”; If the profession of the player is thief: Say “.”; [otherwise: Say "";] otherwise: If the profession of the player is gambler: Say “”; If the profession of the player is detective: Say ".”; If the profession of the player is thief: Say “.”; [otherwise: Say "";]

I don’t know. But the last (high-level) otherwise block in your code is only associated with the condition “If Slygambler is SlyBad … otherwise”. So it should run whenever Slygambler is anything else than SlyBad (e.g. when Slygambler is Slyistrouble). Possibly, what you want is if Slygambler is Slyistrouble: …; otherwise if Slygambler is SlyNON: …; otherwise if Slygambler is SlyBad: …; otherwise: …;

Oh right, I didn’t know you could do ‘otherwise if’ in inform! That’s cool, thanks, it seems to have fixed it now and it may well fix a lot of other little problems I’ve been having.

If you can help though, another weird little problem is with a script I made for borrowing an object from someone. In my story there are a couple of times where you have to borrow an item and then bring it back and replace it. In my script I have this:

Mark can be returned, borrow or askfirst. Mark is askfirst.

I then have a conversation node with the line “Now Mark is borrow;”, meaning you can go and borrow the item. The snag is the moment you quit the conversation he becomes askfirst again. I really don’t know what is going on here, this sequence worked fine last night and I haven’t done anything to that part since.

To be honest I am having an awful lot of problems with this kind of thing in general, I have a lot of variables formatted like the one above that I want to give to every NPC plus the player, but I can’t seem to get it right and I can’t find anything in the documentation to help.

Possibly a dumb question, but are you trying “A person can be returned, borrow, or askfirst” or whatever it is that you’re giving to the NPCs and player? There’s a lot in chapter 4 of the documentation that could help here; sections 4.5, 4.8, and 4.10 might be especially relevant.

This by itself doesn’t explain why Mark’s condition is resetting itself, though.