Question about limiting player movement

Hi there everyone! I’m new to Inform and I don’t really know what I’m doing. I’m playing around with the program trying to jump feet-first into a project so I can get a taste of the syntax (I learn much better by doing), but I’m already running into problems. I’m trying to create a condition where, if it’s active, the player cannot go anywhere (and preferably also can’t get off or on anything, so basically totally limiting their ability to move around). This is the syntax I came up with, but it doesn’t work. Can someone explain what it is I’m doing wrong?

Code:

A person is either mobile or immobile. A person is usually mobile.

This is the mobility rule:
Before the player going somewhere, if the player is immobile say “You are stuck in place and cannot move!” and stop the action.

(This is right up at the top of the code, the first thing after the opening dialogue I wrote).

Any help is appreciated! <3

Oh, I should also say: I also tried adding in “Every turn: use the mobility rule” and that also threw another flag, so I don’t know how to do that either haha

Welcome to the forum and messing around with Inform! One quick FYI is that the forum software often messes up code formatting, which you can get around using the “preformatted text” option in the options bar up above – it looks like </>

Before getting to the syntax, an FYI is that you can just use a before rule for this – you don’t need to put it into an every turn rule unless there’s some separate reason for that.

OK, here’s what it should look like:

(You can click “play” and see how it works. I made listening and jumping switch mobility since those are built-in verbs and it was easy to hack things that way).

The main things to flag are that indents are important, and multiple steps need to be separated on different lines with semicolons in between. And “use a rule” isn’t syntax Inform accepts. Hope this helps!

1 Like

This should work:

A person is either mobile or immobile. A person is usually mobile.

The player is immobile.

Instead of going somewhere while the player is immobile:
	say “You are stuck in place and cannot move!”;

It’s pretty minimal; it only blocks actually going somewhere and not “trying going”, so if you walk east in a room with no eastern exit you might not get quite the results you’re looking for. But maybe it’ll get you started.

(You could also use “instead of going while the player is immobile”, which blocks both.)

2 Likes

Thanks so much! <3

Thank you so much! <3

One more question: Why are you using semi-colons where you are? Or I guess a better question is, when are you supposed to use semi-colons?

<3

Every time you put in a new statement in a complex block of code, basically! The colons signal that the next set of commands should be grouped, the semicolons mark progress through the set, and the period terminates. If you have a really simple conditional, you can get away just with a comma (Instead of going somewhere while the player is immobile, say “You’re stuck!”) – but as that example shows, that’s pretty limited. But yeah, Inform likes semicolons.

1 Like