Prevent automatically entering the room on startup - inform7

I want to give the player a chance to select a few options on game startup, such as their name.
The only problem is that the game insists on putting the player into the first room immediately and print the room name and description. That's not interesting for the player yet, though.
How can I prevent Inform 7 from automatically putting the player into the first room, or at least suppress the room name and description printing at startup?

The solution I found:
The initial room is a room.
The first rule for printing the name of a room:
if the player is in the initial room:
do nothing;
otherwise:
continue the action.

Related

Inform7: How do I make Inform7 display text only once when you enter a room but display every time you enter that room

I would like to know if you can have Inform7 display something like say "Welcome to the room!".
only once when you enter that room. All preceding commands you type will not re-trigger this message but if you leave and re-enter the room it will display again.
The idea is that I have a person in the room who I want to have some greeting text.
Also if possible can I make their text print out after anything else that may be printed in the room?
You can record whether an actor has just arrived in a room using a new either/or property ("a new arrival" in this example) - set it in an after rule for the "going" action, and clear it in a general every turn rule. The greeting text can be displayed in another every turn rule - a more specific one to ensure that it runs before the general one that clears the property - restricted to cases where the person saying the greeting ("The Greeter" in this example) is both in the correct room ("The Greeting Room" in this example) and able to see a person who is a new arrival:
A person can be a new arrival.
A person is usually not a new arrival.
After going:
now the actor is a new arrival;
continue the action.
Every turn when the Greeter is in the Greeting Room and the Greeter can see a new arrival person:
if the player can see the Greeter:
say "Welcome to the Greeting Room![line break]".
Every turn:
repeat with newcomer running through new arrival people:
now the newcomer is not a new arrival.

Game Maker - Turn On/Off Sound

What I have
I have two rooms: rm_home and rm_options. I have a sound: snd_Bgm. And, I have three objects: obj_bgm, obj_BtnOnClicked, and obj_BtnOffClicked.
What I want is very simple
Player can turn on/off the snd_Bgm.
What I have done
In obj_bgm, I have these events:
Create Event: set var global.sound to 1
Room Start: stop sound snd_Bgm; if global.sound == 1 then play sound snd_Bgm
In obj_BtnOnClicked, I have these events:
Left-Pressed Event: play sound snd_Bgm; set var global.sound to 1
In obj_BtnOffClicked, I have these events:
Left-Pressed Event: stop sound snd_Bgm; set var global.sound to 0
I put obj_BtnOnClicked, and obj_BtnOffClicked in rm_options, which can be accessed from rm_home. Then, I put obj_bgm in rm_home.
This is the problem
When game start, it will show rm_home and plays the snd_bgm. I go to rm_options, then click the obj_BtnOffClicked to turn off the sound, so the sound is off. But, when I go back to rm_home, the sound is on again.
What I think
I shouldn't put Create Event: set var global.sound to 1 in obj_bgm, because when rm_home start, it takes the value of var global.sound from Create Event. But, if I put Create Event in obj_BtnOnClicked or obj_BtnOffClicked, it shows a Get Error.
What should I do? Please explain your answer. Thanks.
Are your rooms and your variables persistent ?
If rm_home is not persistent, it will restart every time you leave it. So every object placed in that room will be reset, including obj_bgm, which sets your sound variable to 1. I think this is the reason the sound restarts when you come back to rm_home.
If you still want to reset the room but not this particular object, you can make it persistent. You can do it either by ticking the box in the object or through code.
If you put the create event in a button object, it will not be read until you go to the options room. So when the obj_bgm tries to set it to 1, it does not exist yet. I believe it causes the error.
I make these remarks on assumptions, but I would need to see your code or your error message to help you further.

Inform 7 error using If player consents

I'm trying to write a piece of interactive fiction using inform 7, I want to put a choice in there for the player and I want a simple yes or no I used the following code:
if the player consents say "You get a better view of the stranger."
Otherwise:
say "You can't make out what's happening clearly, however, you notice the stranger walking out of the pub"
I then get this useless error message:
You wrote 'if the player consents say "You get a better view of the stranger."' : but I can't find a verb that I know how to deal with. This looks like an 'if' phrase which has slipped its moorings, so I am ignoring it. ('If' phrases, like all other such instructions, belong inside definitions of rules or phrases - not as sentences which have no context. Maybe a full stop or a skipped line was accidentally used instead of semicolon, so that you inadvertently ended the last rule early?)
Any help would be greatly appreciated.
The punctuation is off. Phrases should end with a semicolon, and if phrases should use either begin..end blocks, or the "colon-and-indentation" style. So either:
if the player consents begin;
say "You get a better view of the stranger.";
otherwise;
say "You can't make out what's happening clearly, however, you notice the stranger walking out of the pub";
end if;
or
if the player consents:
say "You get a better view of the stranger.";
otherwise:
say "You can't make out what's happening clearly, however, you notice the stranger walking out of the pub";
Note the colons and semicolons and tabs in the second example.
Also, as the error message says, you need to specify when that question should be asked. If phrases must be inside rules or phrases. For example, if the question should be asked as a result of an action:
After examining the stranger for the first time:
say "Move closer?";
if the player consents begin;
say "You get a better view of the stranger.";
otherwise;
say "You can't make out what's happening clearly, however, you notice the stranger walking out of the pub";
end if;

How do I restart the current room to what it was when the player entered it?

While making a game, I had set it up so when the player dies, the game resets. Feeling this was a bit too harsh, I did some research and found the room_restart() code, which is meant to restart the current room. But, when I input it and triggered it via dying, it did not reset the room to how it was. How do I reset it?
{
room_restart()
}
That is the code that triggers on collision with an enemy.
You would have to record the state somehow. Game Maker has a native state save function, but if you wanted a room to stay the same without changing the player's inventory or something, you'd have to manually record the state of every object in it so when the player leaves and comes back, everything resumes where it was.
You could try having each object record important variables to a file with sections for each room. For instance, you could use a JSON file with sections for each room, and each object would record their vital data into that section. For example:
{
"rmHouse": {
"Mom": {
"x": 64,
"y": 128,
"action": "lookingDown"
}
}
}
Check around for Game Maker JSON extensions. Here's one for GM8.1/Studio: http://gmc.yoyogames.com/index.php?showtopic=565659
room_goto(room);
That will send the room back to how it was when you first entered it, but room_restart should do the same.
Make sure that you do not have "persistent" checked in the room options. That's what sounds like it's probably the issue to me.
If you had
if(health = 0) {
instance_destroy();
}, then delete instance_destroy. Replace it with x = 32
y = 64
health = max_hp
restart_room();
so that the X position is set, the Y position is set, the health is back, and the room restarts.

Prolog: Recursion and splitting lists

I'm trying to write a game in which the program reads through a database, grabs attributes and asks the player if the Movie that the player is thinking of will have that attribute. The user will answer either yes or no and if yes, the game will ask about the next attribute until either the user has said yes to every attribute, at that point the program will output the name of the movie. Or if the user says no, the game will then move along to the next movie in the database and start asking about those attributes.
The game ends when either it finds a movie with all the attributes or there are no more movies in the database in which the program could ask about.
Here is the database file.
object_properties(crocodile_dundee,[comedy,australian,paul_hogan_movie]).
object_properties(flipper,[action_movie,australian, paul_hogan_movie,
-comedy]).
object_properties(jackass,[comedy,-australian]).
object_properties(the_godfather,[drama,crime,-character_batman]).
object_properties(the_dark_knight,[drama,crime,character_batman]).
object_properties(the_living_planet, [documentary,director_attenborough]).
object_properties(the_code, [documentary,nerds_love_it]).
object_properties(the_russian_revolution, [documentary,about_history]).
Here is my game file.
go():-
guess_object(0,[]).
guess_object(Obj,[A|As]) :-
object_categories(Obj,A).
guess_object(1).
guess_object(2).
guess_object(3).
guess_object(4).
guess_object(5). %how do i do this specifically for the current Obj attributes?
guess(X) :- guess_object(_, X),
writeln('Does your object have the attribute '(X)'?'),
read(Input), Input=('yes') -> assert(object(X)) ; retractall(X), guess(X).
writeln('I guess that the film is: 'guess_object(Obj,_).
The main questions I have:
How do I split the object attributes in to a list like I'm trying to do on guess_object(1) through to guess_object(5) depending on whether the object has 2 attributes or 4 attributes, etc.
How do I make my guess(A) predicate recursive so once the user says no it will then go to the next object in the database file?
I'm not too great at prolog but any advice or pointers would be greatly appreciated, even if it's just pointing out a stupid mistake I may have made. I will also answer any questions anyone has to the best of my ability.

Resources