[I7] Running a code block from bracketed text?

Howdy all. I apologize if this is a silly question. I seem to recall seeing something about it in the documentation at one point, but I’ll be darned if it can’t find it now! And I’ve been unable to come up with something via google or the search function of these forums (probably because I am still stuck in “normal-programming-language” lingo and don’t know what I7 is calling things that I need to be searching for).

I have a high tension scene during which I have an NPC urging the protagonist to go somewhere and do something before something bad happens. The player is urged for several turns, and if they fool around and don’t leave the room, Game Ending Things happen. But if they do leave the room and start trying to solve the problem, they are given more time. It is currently implemented with several timed events, the “event handlers” for which only do something if the player is in a particular room. But that is something of a mess. I’ve been attempting to clean it up, because I am an anally-retentive codemonger (which could explain why I so seldom ever actually finish anything, instead polishing code endlessly)!

Anyway, my attempt goes something like this:

[code]this is the you-better-get-moving-or-die rule:
say “Now that the Immobile Generic NPC has run out of pithy three-letter words to say, I self-immolate and die horribly!”;
end the game saying “Uh oh! I’m dead!”.

Every turn when our intrepid heroine is in a particular room during chapter three part two:
say “[one of]Foo![or]Bar![or]Baz![or][follow the you-better-get-moving-or-die rule][cycling]”.[/code]

This, of course, doesn’t work. But I swear I’ve seen something about calling a “block of code” from bracketed text somewhere before.

I have a feeling I need to wrap this up in something that returns some empty text (or something; please forgive my still being rather stuck in “normal programming language” lingo here), but I’m having trouble figuring out how to do it. Any advice? Or is the above not a good way to be trying to do things; mayhaps I’d be better off with the less concise wall-o-timers and “event handlers” (or whatever they are called)?

Thanks a bunch. And again, apologies for both my ignorance of I7 terminology and silly questions that have probably been asked before! Still learning the ins and outs of this I7 thing!

The bracketed text substitutions produce “say” phrases, so you just need something like this:

To say you better get moving or die: follow the you-better-get-moving-or-die rule.

And then you can use [you better get moving or die] as a bracketed text substitution. (Or you could just put your code block in the “say” phrase, if that’s the only place you need it.)

EDIT: And in fact these phrases don’t need to return any text. Making new substitutions is discussed in section 5.13 of the manual, but I forget where I saw how to use “say” phrases to do stuff in this way.

Excellent! Thank you!

This is a favorite of mine:

To say (ph - phrase): (- if (true) {ph} -).

With that lovely piece of code you can call any I7 phrase from within quoted text.

Cute, but is it safe? I know that “if COND” and “say if COND” are both defined phrases, and if your line picks up the wrong one, things will break.

I suspect that executing “stop” or “stop the action” in the middle of a say phrase will also bugger up the printing mechanism. Not that you’re likely to do that, but just be aware.

Right. This is probably wiser: To say do (ph - phrase): (- if (true) {ph} -).

I do: To say @ (ph - phrase): (- if (true) {ph} -).

So then you just have “[@ move the sword to the player]” or whatever. The @ makes it immediately clear that the bracketed text is not a text substitution, and it’s quick to type.

Note that you can’t run any phrase like this: commas in your phrase won’t compile, for example.


Oh my. Way to overclock the awe-inspiring power of text substitutions.

Very very cool, that. I have a sneaking suspicion that I’ll be using the bjesus out of that little gem.

I really must look further into inline I6. I really like how I7 seems to keep one in a “writerly” mindset and out of a “programmerly” mindset, but I’ve come across several places now where I feel like a section of a more traditionally structured language would be cleaner for certain bizarre things. Though perhaps that’s just due to my ignorance!

I do also wish I could either split my story into multiple files or tear the index off into another pane or separate window, so I don’t have to spam back and forth all over the source code to get at what I need to get at. It makes the workflow seem awfully lumpy sometimes. But maybe I am still trying to be too OO with keeping all of the scene-neutral implementation of various things in their own sections. One big file also seems a little lumpy to be diffing against various revisions in version control, when I get deep in the zone and forget to synchronize regularly.

Not criticisms per se, just… I guess I want to have my cake and eat it too. :stuck_out_tongue_winking_eye: Sometimes I think about writing some kind of frontend that would allow for that sort of thing, but… Too lazy, even if WindowBuilder makes it all too easy!

But I digress (at usual)! Thank you all again. With some measure of luck, perhaps I’ll become reasonably proficient with this I7 thing yet!

Me too. For the really large game I split off code into “extensions”.

I’m thinking like maybe it wouldn’t be terribly hard to write some kind of build script to do it. Some kind of master list file, to make sure everything went together in the right order (though that might not be needed if things were split up in a fashion where rule ordering outside each file doesn’t matter so much, like along scenes). cat them all into a temporary .ni and compile it. Annoyingly unfun and tedious to make a table of what lines correspond to what source files and translate the error log back into something with correct filenames and line numbers, though.

Sometimes I think about trying to find the source for that seemingly defunct I7 Eclipse plugin and getting it back up to snuff (at least it seems to be pretty broken in Juno, unless I derped instead of reading the install instructions correctly), but… Yeah, I’m too lazy… >_> Background compilation while you type and error indicators directly in the source code with floaty messages would be pretty swell though!

I also think Graham is a very sharp fellow, so maybe I’m just missing something fundamentally awesome, which I will later realize and be all AH HA! :stuck_out_tongue:

The next I7 release should make it simpler by allowing you to put extensions in a project’s Materials folder, so you don’t need to keep track of files in two places.

Poster/AmberShards/whatever he’s calling himself had a thing for using multiple source files in I7; I’ve never tried it though, and it’s a few years old, so it might not be current.

Interesting! The shell script is definitely elucidating as far as seeing how the build process works behind the scenes.

I still think such a thing needs to somehow translate the error log back into something that points into the original, split, source files, though. Otherwise I’m not sure that gaining the ability to split a project into multiple files is worth losing sane error reports.

I’d probably try to implement such a thing in a more portable fashion, too, so as to not alienate our non-Unix peers. Python, or maybe Java if I had hopes of shoehorning it all into an Eclipse plugin at some point… or delusions of building a new multiplatform IDE in the style of the I7 frontend (the current situation of duplicating all that work across three different architectures does seem rather a shame, and somewhat ironic, considering the highly portable nature of the program’s output!).

Danger, Will Robinson! Feeping creatures detected!

Hmmmm, I probably ought to stop thinking about this, lest I exclaim “OH SHINY” and tilt another doomed-to-never-be-completed windmill. :laughing: I have high hopes that the new features of the next release of I7 will make all this possible from within the I7 IDE!


But I feel like I am already losing steam, and it isn’t even calling the toolchain and doing its own compilation yet, nor is there any embedded Zag! :unamused: