intfiction.org

The Interactive Fiction Community Forum
It is currently Mon May 29, 2017 12:00 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Mon Mar 20, 2017 8:44 am 
Offline

Joined: Tue Mar 14, 2017 6:12 am
Posts: 45
Hello!

I have another few questions today that I hope you guys can help me for like that you had helped me last time :)

One) I have a door created, as seen in this code:

Main hall is a room. Main hall is north of Rusty house door. "The main hall of the house."



A door is a kind of thing. A door can be openable. A door can be open. A door is usually openable and closed.

Rusty front door is a door. Rusty front door is north of Outside House and south of Main Hall.

Carry out opening a door:
say "You slowly push open the door";

Which works just fine. However a few things I am not sure to do/want to have happen. Firstly, I want the player to have a key in their inventory at the start of play (I know how to do that bit) but then I want it to only be openable with the key in ones inventory. I guess that's a check rule? But not too sure what to put (as Check and carry out rules confuse the hell out of me for some reason). Also, I want it so the player HAS to type "Open rusty front door", and that it shuts upon going through it either way. What's happening right now is that the door stays open, and that if you're in Outside House or Main hall and then type north or south respectively, it will automatically open the door and then go into the room. While this isn't an issue, it just doesn't sit right with me.


2) In my game I have an archer that you can speak to. He has three topics that can be spoken about; Werewolves, Werewolf hunters and killing werewolves. I want to make a command that allows the player to see what topics are available to be spoken about to the archer (and then other characters later in the game as this is rather important to deepen the lore and story). I tried to make my own code for this but it doesn't do anything. Did I do something wrong or is there another way to go around this?


Code:


list-asking is an action applying to one thing.
understand "ask [thing]" as list-asking

Check list-asking:
if the noun is not the Archer, say "You cannot ask any questions";

After list-asking the archer:
say "[Topic entry]";

(Table is called Table of Archer Responses)

Cheers!


Top
 Profile Send private message  
 
PostPosted: Mon Mar 20, 2017 9:40 am 
Offline

Joined: Mon Dec 15, 2014 9:15 am
Posts: 144
You can make doors close behind you with an after rule:
Code:
After going through a door (called X):
          say "[The X] swings shut behind you.";
          now X is closed;
          now X is locked;
          continue the action.

Making it relock itself automatically will ensure that the player needs the key to get through it again.

But you might want to consider whether all this is really a good plan. Having the doors lock themselves behind you might be good atmospherically, but the player will quickly get fed up of unlocking the same door over and over. You could let the player automatically unlock doors (after the first time) if they have the right keys. (Emily Short's extensions, Locksmith and Approaches, are good for handling this sort of thing.)

By the way, you don't need to define doors. They're built into the standard rules. There's also a built in "matching key" relation.
Code:
The rusty door is a door. The rusty door is locked. The matching key of the rusty door is the square key. The player carries the square key. 



Edited to add a caution.


Last edited by jrb on Mon Mar 20, 2017 9:52 am, edited 2 times in total.

Top
 Profile Send private message  
 
PostPosted: Mon Mar 20, 2017 9:49 am 
Offline

Joined: Tue Mar 14, 2017 6:12 am
Posts: 45
Cheers @Jrb! I'll do that now, thanks again for helping me :)


Top
 Profile Send private message  
 
PostPosted: Mon Mar 20, 2017 5:16 pm 
Offline

Joined: Mon Dec 15, 2014 9:15 am
Posts: 144
For your question about conversation: there are a few problems with your code. But the good news is that there is already an action built into Inform which will do what you want --- the "asking it about" action.

See Section 16.13 of Writing with Inform for a simple way of getting a table-based conversation working. Here's an example:
Code:
After asking the archer about a topic listed in the Table of Archer Reponses:
       say the response entry.

Table of Archer Responses
Topic    Response
"Werewolf/Werewolves"   "They come out at full moon."
"Killing werewolves"       "You'll need a silver dagger."    

(You need to use tabs to separate the columns.)



Edit: if you really wanted to set up a new "list-asking" action", this is possible, but will be hassle. First of all you'd need to destroy the existing "ask" command. Which will also destroy the command for the "asking it for" action, which you might want to put back.
Code:
Understand the command to ask as something new. 
Understand "ask [someone] for [something]" as asking it for.

Now your new command needs two nouns: a thing (actually a person, but that comes later), and a topic. Because it takes two nouns, you need to tell Inform how the syntax works; so the action should be called "list-asking it about".
Code:
List-asking it about is an action applying to one person and one topic.

(Inform will understand that the "it" in the action name marks where the first noun belongs, so that we can write rules like "After list-asking the archer about something".)

Next we define the command for this action.
Code:
Understand "ask [someone] about [text]" as list-asking it about.

And now we have a brand new action ready to have rules written about it.

But there's no good reason I can think of to do all this, since the new "list-asking it about" action we've created is practically identical to the old "asking it about" action anyway. The only difference is that the default "asking it about" action comes with a check rule, the "block asking rule". (This rule is the one that prints "There is no reply.") If we don't like that rule, we can easily get rid of it without going to the trouble of making a new action:
Code:
The block asking rule does nothing.


Last edited by jrb on Mon Mar 20, 2017 5:43 pm, edited 1 time in total.

Top
 Profile Send private message  
 
PostPosted: Mon Mar 20, 2017 5:41 pm 
Offline

Joined: Tue Mar 14, 2017 6:12 am
Posts: 45
@Jrb the doors worked, but the way. So thanks! You are misunderstanding my second question. I have the table set up. I have the topics and the responses. What I want is for the player to try a command and for it to come up with the avalible topics so that the player knows what topics to ask.


Top
 Profile Send private message  
 
PostPosted: Mon Mar 20, 2017 6:03 pm 
Offline

Joined: Mon Dec 15, 2014 9:15 am
Posts: 144
Ah, sorry, my mistake. Something like this?
Code:
Carry out list-asking: 
	let N be the number of rows in the Table of Archer Responses;
	if N is 0:
		say "There is nothing to ask about.";
	otherwise:
		say "You could ask about ";
		repeat with X running from 1 to N minus 1:
			say  "[index in row X of the Table of Archer Responses][if N is greater than 2],[end if] ";
		if N is greater than 1: 
			say "or ";
		say "[index in row N of the Table of Archer Responses]."
	

Table of Archer Responses
Topic	Response	Index
"Werewolf/Werewolves"	"I hate them."	"werewolves"
"Bananas" 	"I eat them."	"bananas"

(more complicated than it needs to be perhaps, but you might want the number of rows in the table to vary.)

The "index" column is there because the "topic" column is special; the entries have the kind "topic" rather than "text" and can't be printed directly.


Top
 Profile Send private message  
 
PostPosted: Tue Mar 21, 2017 6:55 am 
Offline

Joined: Tue Mar 14, 2017 6:12 am
Posts: 45
@jrb that worked! And I don't mind complex, especially in this scenario. If it works, it works. And it does! Thanks so much once again!


Top
 Profile Send private message  
 
PostPosted: Tue Mar 21, 2017 10:22 am 
Offline

Joined: Tue Mar 14, 2017 6:12 am
Posts: 45
@jrb I need your help again! I am now trying to have a second character (White werewolf) for speech. However, my list-asking action is now clashing. I have this check rule:


Check list-asking:
if the noun is not the Archer, say "You cannot ask any questions" instead.

Which is great but then you can't list topics of the White werewolf (and the other werewolves in the same room)

I tried this code but it didn't want to know

(right under)

Check list-asking:
if the noun is not White Werewolf, say "You cannot ask questions" instead.

However this didn't grant me anything.

When I take this rule out as well, it will display both the archer and the white werewolf topics.


Attachments:
Capture.PNG
Capture.PNG [ 3.8 KiB | Viewed 254 times ]
Top
 Profile Send private message  
 
PostPosted: Tue Mar 21, 2017 12:52 pm 
Offline

Joined: Mon Dec 15, 2014 9:15 am
Posts: 144
You could write a check rule which covers all the cases. But probably the easiest way is to use instead rules to cover the cases you actually care about.
Code:
Check list-asking:
        say "You can't ask any questions."

Instead of list-asking the archer:
	let N be the number of rows in the Table of Archer Responses;
	if N is 0:
		say "There is nothing to ask about.";
	otherwise:
		say "You could ask about ";
		repeat with X running from 1 to N minus 1:
			say  "[index in row X of the Table of Archer Responses][if N is greater than 2],[end if] ";
		if N is greater than 1: 
			say "or ";
		say "[index in row N of the Table of Archer Responses]."

Instead of list-asking the white werewolf:
	let N be the number of rows in the Table of Werewolf Responses;
	if N is 0:
		say "There is nothing to ask about.";
	otherwise:
		say "You could ask about ";
		repeat with X running from 1 to N minus 1:
			say  "[index in row X of the Table of Werewolf Responses][if N is greater than 2],[end if] ";
		if N is greater than 1: 
			say "or ";
		say "[index in row N of the Table of Werewolf Responses]."

(Maybe there's a straightforward way of rolling the two instead rules into one to avoid the repetition, but I don't see it.)


Top
 Profile Send private message  
 
PostPosted: Tue Mar 21, 2017 2:43 pm 
Offline

Joined: Tue Mar 09, 2010 2:34 pm
Posts: 4818
Location: Burlington, VT
jrb wrote:
(Maybe there's a straightforward way of rolling the two instead rules into one to avoid the repetition, but I don't see it.)


The way I can think of would be something like this:

Code:
A conversation partner is a kind of person. A conversation partner has a table name called the conversation table.

Instead of list-asking a conversation partner (called buddy): 
	let the current conversation table be the conversation table of the buddy;
	let N be the number of rows in the current conversation table;
	if N is 0:
		say "There is nothing to ask about.";
	otherwise:
		say "You could ask about ";
		repeat with X running from 1 to N minus 1:
			say  "[index in row X of the current conversation table][if N is greater than 2],[end if] ";
		if N is greater than 1: 
			say "or ";
		say "[index in row N of the current conversation table]."


I'm not sure this counts as straightforward, though.


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Silas Black and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group