inform7 problems - combat and machines

hello all,

im new to inform7 and im learning as i go…

i have a couple of issues that are stopping me writing a quick game, if anyone can help that would be great!

Combat - i would like a man in a room who will attack you with random hits - but i dont know how…

Machines - i would like also a machine with levers or buttons , for example a machine with 3 levers , one lever opens a door?

thank you all

:slight_smile:

The ATTACK extension (I believe the latest version is here: http://gamingphilosopher.blogspot.com/2011/04/attack-inform-attack-version-2-released.html) is worth a look for combat purposes. There are other ways to do it, of course! Consider, too, whether you genuinely want random attacks - are you willing to end the game for certain unlucky players? Even if it means they may not replay?

You may find the documentation about parts of things instructive, as well as that on devices. Here’s a simple example that unlocks and opens a door when you pull a lever.

[code]The Machine Room is a room. The Main Lab is a room. The steel door is east of the Machine Room and west of the Main Lab. The steel door is a door. The steel door is lockable and locked.

The heavy lever is in the Machine Room.

Instead of pulling the heavy lever:
if the steel door is locked or the steel door is closed:
say “There is a click from the steel door and it slides open.”;
otherwise:
say “You pull the lever, but nothing happens.”;
now the steel door is unlocked;
now the steel door is open;

test me with “e / pull lever / e”[/code]

thank you for the quick response, as for random combat , i mean random hit points to within a limited range

ive just tried to test that by copying it but i get this error?

Problem. The phrase or rule definition ‘Instead of pulling the heavy lever’ is written using the ‘colon and indentation’ syntax for its 'if’s, 'repeat’s and 'while’s, where blocks of phrases grouped together are indented one tab step inward from the ‘if …:’ or similar phrase to which they belong. But the tabs here seem to be misaligned, and I can’t determine the structure. The first phrase going awry in the definition seems to be ‘if the steel door is locked or the steel door is closed’ , in case that helps.

i take it thats a TAB error or spacing?

how do i adjust or change that?

thank you

Try “quoting” my reply, and then copying and pasting from there. A straight copy-paste from the forum removes tabs. (You can also manually re-enter tabs in the appropriate places, but where’s the fun in that?)

If the PC isn’t going to be doing combat hirself, it might be more straightforward to do something like the following:

[code]The Dojo is a room. “You are sparring.[if Julie is in the location] Julie circles you, watching for an opening.[end if]”.
The Locker Room is a room.

The player has a number called health. The health of the player is 25.

Instead of attacking Julie:
say “You try your best, but you don’t even come close to landing a blow.”

Julie is a woman in the Dojo.

Every turn while Julie is in the location and the location is the Dojo:
say “[one of]Julie darts in a strikes your leg, hard enough to bruise[or]You move back, and Julie’s fist strikes your upper arm, which tingles and goes numb[or]A blow catches you in the stomach[at random].”;
decrease the health of the player by a random number between 5 and 15;
if the health of the player is less than 1:
say “The match ends, with Julie victorious. You bow to each other, and hit the showers.”;
now the player is in the Locker Room.

test me with “z / z / z”.[/code]

you sir are a superstar!!!

many thanks…i’ll be playing with your code and trying different things.

i have tried many times copying bits from the web and usually none of it works…

indents screwed up i think.

again thank you

No prob. You do have to watch the indents really carefully; if you’re getting code from the rec arts if feed, you’ll always have to manually tab. But when you post code here, just put it in “code” tags, and the indents can be retrieved by others.

ive copy bits of code from here there and everywhere while i try things but unless its a simple sentence i usually get error about indents / tabs or spaces

but now ive joined here, hopefully people can guide me through the pitfalls…

thanks

The rules about indentation are explained in my Handbook (www.musicwords.net/if/i7hb.htm). Basically, Inform is finicky about indentation with tabs, and it’s finicky about how you end a line – with a semicolon or period, for example. It’s no different from other computer programming languages in that respect.

Your best bet is to study the documentation in a systematic way. Inform looks easy, but in reality it’s a form of computer programming. Getting numerous error messages from the compiler is absolutely normal.

Haha. I’m always suspicious when I write more than a single line or two and the game compiles smoothly.