Setting the Clock to a Specific Time

I have several clocks in-game that are set at the right time. One puzzle has the player resetting the clocks to 2:30. After that the player can reset the clock back to the real time. I want to prevent the player from setting the clock to any other time other than 2:30, but I’m not so sure how would I do that without the message sounding ridiculous. Right now attempting to set the time to anything other than 2:30 results in “No, you can’t set that to anything.”

[code]Setting is an action applying to one visible thing. Understand “set [something] to half past two” and “set [something] to2:30” and “set [something]” as setting.

Resetting is an action applying to one visible thing. Understand “reset [something]” as resetting.

Carry out resetting:
now the noun is not set;
say “Now the clock is set to [the time of day in words].”

Check resetting:
if the noun is not a clock,
say “You can’t reset that!” instead;
if the clock is not set,
say “The clock is already set at the right time.” instead.

Check setting:
if the noun is not a clock,
say “Why would you set that?” instead.

Carry out setting:
now the noun is set;
say “Now the clock is set to half past two.”[/code]

Also is there anyway to allow the player to type

       > set clock to 2:30

without having an error popping up?

You can actually understand the time set, which will allow your grammar to understand any time, and your check rules to reject unwanted cases:

[code]Setting is an action applying to one visible thing and one time. Understand “set [something] to [time]” as setting.

Check setting:
if the time understood is not 2:30 pm:
say “No, you can’t set the clock to anything but 2:30 PM.” instead.

Carry out setting:
now the noun is set;
say “Now the clock is set to half past two in the afternoon.”[/code]

You’d probably want to provide some alternate grammar to catch incorrectly typed times and instruct the player how to correctly type a time.

–Erik

I didn’t know that. Thank you.

Actually I just tried that and it produces a really odd reaction.

[code]A clock is a kind of thing. Clocks can be set or not set. A clock is usually not set. Clocks are rarely portable.

A hall-grandfather is a clock. A hall-grandfather is in the uhall. The description of the hall-grandfather is “Your standard grandfather clock, all cherry wood and polished brass. [if not set]The hands rest on [the time of day in words].[otherwise]The hands rest frozen on half past two.” The printed name of the hall-grandfather is “grandfather clock”. Understand “grandfather clock” or “clock” or “grandfather” as hall-grandfather.

Setting is an action applying to one visible thing and one time. Understand “set [something] to [time]” as setting.

Resetting is an action applying to one visible thing. Understand “reset [something]” as resetting.

Carry out resetting:
now the noun is not set;
say “Now the clock is set to [the time of day in words].”

Check resetting:
if the noun is not a clock,
say “You can’t reset that!” instead;
if the clock is not set,
say “The clock is already set at the right time.” instead.

Check setting:
if the time understood is not 2:30 pm:
say “No, you can’t set the clock to anything but 2:30 PM.” instead;
if the noun is not a clock,
say “Why would you set that?” instead.

Carry out setting:
now the noun is set;
say “Now the clock is set to half past two in the afternoon.”[/code]

It works perfectly until you try to reset the clock. Technically it shouldn’t do anything but revert the description back to telling the right time, but instead you get this.

x clock
Your standard grandfather clock, all cherry wood and polished brass. The hands rest on twenty-two minutes past eight.

set clock to 2:30 PM
Now the clock is set to half past two in the afternoon.

x clock
Your standard grandfather clock, all cherry wood and polished brass. The hands rest frozen on half past two.

reset clock
The clock is already set at the right time.

It’s technically true since the change is just superficial, but I’m not sure why the clock doesn’t go back to being not set.

Your problem is the line “Clocks can be set or not set” – Inform is getting confused about what “not set” means. If you just do this:

A clock is a kind of thing. Clocks can be set. Clocks are rarely portable.

…it should work. (Inform generates its own “not set” when you declare that clocks can be “set”.)

–Erik

It still doesn’t work…unless I’m missing your point?

[code]A clock is a kind of thing. Clocks can be set. Clocks are rarely portable.

A hall-grandfather is a clock. A hall-grandfather is in the uhall. The description of the hall-grandfather is “Your standard grandfather clock, all cherry wood and polished brass. [if set]The hands rest frozen on half past two.[otherwise]The hands rest on [the time of day in words].”

Setting is an action applying to one visible thing and one time. Understand “set [something] to [time]” as setting.

Resetting is an action applying to one visible thing. Understand “reset [something]” as resetting.

Carry out resetting:
say “Now the clock is set to [the time of day in words].”;
now the noun is not set.

Check resetting:
if the noun is not a clock,
say “You can’t reset that!” instead;
if the clock is not set,
say “The clock is already set at the right time.” instead.

Check setting:
if the time understood is not 2:30 pm:
say “You move the hands to [time understood in words] but hastily move them back again. You wouldn’t want to accidentally confuse someone.” instead;
if the noun is not a clock,
say “Why would you set that?” instead.

Carry out setting:
now the noun is set;
say “Now the clock is set to half past two.”

[/code]

Reset doesn’t change the clock’s status back to “not set” for some reason.

Also, is there a way to turn off the pm/am distinction? I mean it is a 12-hour grandfather clock.

Actually thinking about it I think I know what’s wrong.

[code]Carry out resetting:
now the noun is not set;
say “Now the clock is set to [the time of day in words].”;

Check resetting:
if the noun is not a clock,
say “You can’t reset that!” instead;
if the noun not set,
say “The clock is already set at the right time.” instead.[/code]

Inform resets the clock to “not set” then checks it apparently, leading to “The clock is already set at the right time”.

I fiddled around with the order and came up with this:

[code]Carry out resetting:
now the noun is not set;
say “Now the clock is set to [the time of day in words].”;
stop the action.

Check resetting:
if the noun is not a clock,
say “You can’t reset that!” instead;
if the noun is not set,
say “The clock is already set at the right time.” instead.[/code]

I have no idea why that works but it does. Thank you for all your help Erik.

Now if only I can figure out how to make the game accept 2:30 and not 2:30 pm exclusively.

That may work, but it bothers me. Shouldn’t it be:

[code]Carry out resetting:
now the noun is not set;

Report resetting:
say “Now [the noun] is set to [the time of day in words].”;[/code]

Your earlier posts said “if the clock is not set,” not “if the noun is not set” - maybe that was the real problem?

Oh…that was rather stupid of me, especially since I was agonizing over that for like 3 hours.

Thanks capmikee! At least I don’t have to wonder anymore. Also I’m really sorry for wasting every one’s time over a typo.

Actually, I couldn’t reproduce the problem with the not set clock at all.

Perhaps you were typing commands right into your work in progress rather than into a tiny “game” with just the fragment of source text presented in this thread? As, in your WIP you have several clocks, Inform may perhaps have interpreted “the clock” as some other clock than the one you were resetting. (Changing “clock” to “noun” shouldn’t make any difference to the code presented in the posts, I think, since there is only one clock in it.)

Two more things by the bye, both rather general and both such that you may be well aware of the already. In that case, please, have forbearance with my meddling.

  1. You made a reasonable guess as to the problem:

But that couldn’t be the answer, for a reason that is well worth to know. Check rules for an action are always run before the carry out rules for that action. It doesn’t matter if you put the check or the carry out rules first in your source text. (The rulebooks for an action are run in this order: before, instead, check, carry out, after, report.)

  1. In your source you define setting and resetting as applying to “one visible thing”. That will make it possible to set and reset clocks that the player can see but can’t touch. Obviously, I know nothing of your game, so that may well be exactly what you want. But if you want to keep the player from setting and resetting clocks that he/she can’t touch, make the actions simply apply to “one thing” (which Inform will interpret as “one visible and touchable thing”).

That’s might be because you used the “defective” code I posted at 10:47 pm. It wasn’t really defective though. Both codes in that post work, mainly because by then I had changed clock to noun in one of my many attempts to fix the clock mechanism. Looking back, I actually have no idea that “defective” code is since I clearly didn’t run it through Inform.

I do know the order (I vaguely remember reading it), but I couldn’t think of other any reason why it worked while absolutely nothing I had tried so far hadn’t. After all, I hadn’t notice the typo until capmikee pointed it out for me. shrug Live and learn, I guess.

Thanks for that tip. I wasn’t sure if making an action touchable would require the player to carry the item (in this case the ridiculously heavy and part of the scenery grandfather clock). Since there are no grandfather clocks that can be seen but not touched in the game, I decided to just go with visible .

As you probably guessed, I am ridiculously new to Inform, and so any advice is absolute music to my ears. Thank you Felix.