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

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.

Related

Prevent automatically entering the room on startup

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.

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.

How To Make An Int Score on Another Page in Xcode

I am trying to make an int on another page for my game. I tried This:
"score = score + 1;"
"scoretext.text = [NSString stringWithFormat:#"%i", score];"
But every time I switch out of that view controller and come back the score is at Zero! How do you save the Number so when you come back it is not gone!
i think you should have a look at user defaults in objective C so that you can save the data for local user game even when the game is sent to background you can have track to the score or also you can store the current user state
you can have a look at this in the links below
How do I save user preferences for my iPhone app?
http://www.idev101.com/code/Objective-C/Saving_Data/NSUserDefaults.html

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.

What is the most efficient way of filling in details on a web form?

Take a standard web page with lots of text fields, drop downs etc.
What is the most efficient way in webdriver to fill out the values and then verify if the values have been entered correctly.
You only have to test that the values are entered correctly if you have some javascript validation or other magic happening at your input fields. You don't want to test that webdriver/selenium works correctly.
There are various ways, depending if you want to use webdriver or selenium. Here is a potpourri of the stuff I'm using.
Assert.assertEquals("input field must be empty", "", selenium.getValue("name=model.query"));
driver.findElement(By.name("model.query")).sendKeys("Testinput");
//here you have to wait for javascript to finish. E.g wait for a css Class or id to appear
Assert.assertEquals("Testinput", selenium.getValue("name=model.query"));
With webdriver only:
WebElement inputElement = driver.findElement(By.id("input_field_1"));
inputElement.clear();
inputElement.sendKeys("12");
//here you have to wait for javascript to finish. E.g wait for a css Class or id to appear
Assert.assertEquals("12", inputElement.getAttribute("value"));
Hopefully, the results of filling out your form are visible to the user in some manner. So you could think along these BDD-esque lines:
When I create a new movie
Then I should see my movie page
That is, your "new movie" steps would do the field entry & submit. And your "Then" would assert that the movie shows up with your entered data.
element = driver.find_element(:id, "movie_title")
element.send_keys 'The Good, the Bad, the Ugly'
# etc.
driver.find_element(:id, "submit").click
I'm just dabbling in this now, but this is what I came up with so far. It certainly seems more verbose than something like Capybara:
fill_in 'movie_title', :with => 'The Good, the Bad, the Ugly'
Hope this helps.

Resources