Advice on finding/overriding rules?

Cheers all. I’m still grinding away at my first game and running into the n00b blocks.

I have an container which I want the player to turn into another object by:
-opening
-inserting components

I’m going to handle this by having an ‘after’ rule for inserting into that container, and if the container contains the fully assembled list of components, I’m going to swap it for an instance of the final object (which is waiting off-stage). I’m doing this b/c I couldn’t figure out how to have an object change its referred-to-as name when assembly was finished, and I didn’t want to give away the puzzle by letting the player refer to the original object via the finished object’s name.

Anyway, sorry, background. Here’s my problem. The original object (let’s call it a fleeb) is a container, but it’s closed and unopenable (as per my last question) so that the player doesn’t get told ‘the fleeb is closed’ and thus giving away that it’s a container. So I need to override “open [something] with [something]” to allow the player to open the fleeb with the appropriate tool. However, when I code that up, I instead get

So it seems like despite the fact that I have:

Opening it with is an action applying to two things.
Understand "open [something] with [something]" as opening it with.

…and then have check and carry out clauses for the ‘opening it with’ activity, Inform is still assuming that opening something with something is unlocking. I presume I need to remove the unlocking rule from the rulebook (which is OK, I don’t use keys in my game) or something like that. But I don’t know how to find the precise name of the rule I need to remove. I looked in the rules section of the index, and none of the ‘built in’ rules are there. When I turn on rules tracing in the game, instead of named rules I get a big list of things like “The rule at address (497342)”.

Any help most gratefully appreciated. Thanks all.

The thing you are describing with rules tracing shouldn’t happen. Are you using the command “rules”? Do you have any extensions included?

But if you want to use the index, look in the “actions” tab – the rules that pertain to specific actions are listed there.

Yep, using ‘rules’. I have no extensions included/enabled at this point. It first started doing Address-based rules when I had to switch to Glulx due to memory limits.

When I look in the ‘rules governing actions’ section of the Rules tab in the index, it shows all the actions I’ve set, but it doesn’t show the built-ins.

Anyhow…I think I’m overengineering a hack, here. So here’s my design block in generic terms - maybe you folks can suggest a ‘proper’ (or at least ‘not hideously hackish’) option for doing this. :slight_smile:

I want my user to find components throughout the game, and then use those components to build a new item.

The way I was trying to do it was having the ‘base’ component be a container (which was hidden from the player) and when they figured out how to open the container, have them put the other components inside it. Then use an ‘After inserting into (container)’ rule, and when they had the requisite pieces, have the finished item (which was held offstage) swap places in their inventory with the container. Actually, my original plan was to have the base item be a part of another item, have them disassemble that to get the base part; that didn’t work because I couldn’t figure out how to make something no longer a part of anything. The Red Label example just showed how to make it part of something else…

Wow, I’m making less and less sense as I go along, huh. :stuck_out_tongue:

EDIT: Oh. Um, duh. I just found Example 416. After searching for all kinds of words in the built-in docs and not finding it. Because, yeah, I’m an idjit. Never mind. :slight_smile:

I suppose you could just use the unlocking it with action and make fleebs lockable as well as unopenable. No?
Also, I’m pretty curious about those ‘rule at address’ messages.

This shouldn’t cause that, however, before switching to glulx, you probably tried to avoid doing so by adding this:

Use memory economy.

… which does remove rule names to save memory. Now that you’ve switched you can remove that line; you won’t need it anymore. Rules tracing should return to normal.

Skinny Mike:

THAT’S A BEEENGOH.

Thank you. :slight_smile:

I don’t know what that means but, you’re welcome. :slight_smile:

So I spoke too soon re: my combining objects problem! Heh. I’m essentially copying Example 416, but that doesn’t work because the things I need to combine - here fleeb and programmed florb (and the item built entries) are kinds - and apparently you can’t put kinds in lists:

Is there a way to use the assembly algorithm for non-uniques?

Just move the base to wherever you want it to go. Any of these:

Now the player holds the base. Now the base is in the location. Now the base is held by the holder of the statue. Remove the base from play.

should make the base no longer part of the statue (if that’s what it was part of) and send it to different places.

“Now the base is held by the holder of the statue” is one I especially like, until someone tells me that I’m doing it wrong. It should make the base wind up wherever the statue was when you did the thing that removed it. If the statue was in your inventory, the base will wind up there; if it was on a supporter, the base will wind up on the supporter; and so on.

Note that if you’re writing a rule for kinds of thing instead of specific things, things get a bit more complicated. You won’t be able to say “Now the base is held by the holder of the fleeb” if “fleeb” is a kind (or if “base” is a kind); you’ll have to use things like “the noun” and “the second noun” to make sure you get the right fleeb and/or base.

Ooh, I am so confused.

Okay, so I figured if I can’t use lists of kinds for assembly, I can cheat and use their printed names - at least to determine their compatibility.

Sorry for the long include, but this is making me nuts:


"test" by "custo"

Combining it with is an action applying to two carried things.
Understand "combine [something] and [something]" as combining it with.
Understand "combine [something] with [something]" as combining it with.  
Understand the command "attach" as something new.  Understand "attach [something] to [something]" as combining it with.

The combining it with action has an object called the item built.

Setting action variables for combining something with something:
	let X be a list of texts;
	add the printed name of the noun to X;
	add the printed name of the second noun to X;
	say "X is presort: [X in brace notation].";
	sort X;
	repeat through the Table of Outcome Objects:
		let Y be the component list entry;
		say "Y is presort: [Y in brace notation].";
		sort Y;
		say "X is: [X in brace notation].";
		say "Y is: [Y in brace notation].";
		if X is Y:
			say "match![line break]";
			now the item built is the result entry.

Check combining it with:
	say "The item built lookup is: [the item built].";
	if the item built is nothing, say "[The noun] and [the second noun] don't make anything useful." instead;
	if the item built is not in limbo, say "That's not available." instead.
	
Carry out combining it with:
	move the item built to the holder of the noun;
	remove the noun from play;
	remove the second noun from play.
	
Report combining it with:
	say "You now have [an item built]!".

A memory chip is a kind of thing.

A broadcast chip is a kind of thing.

The player is carrying a memory chip and a broadcast chip.

Limbo is a container.  Limbo contains the Klein Blaster.

The test chamber is a room.  The description is "GlaDOS is watching you."

The player is in the test chamber.

Table of Outcome Objects
component list	result
{"broadcast chip", "memory chip"}	Klein Blaster

If I run that, I get:

Now. Note The order of the lists is the same, presort. Then note that the orders are not the same post-sort. Also, the comparison fails. (it fails even if I ‘force’ the lists into the correct order using reverse sort or other trickery). The differing behavior of sort() tells me that the two lists, despite looking like they’re lists of the same things, aren’t, and that’s both why the comparison (X is Y) is failing and why sort is doing two different things.
Can anyone tell me why they’re not the same? Is it that having a list declared in a table doesn’t automatically make it a list of texts, even if the elements are quoted text?

Just to make myself more confused: If I change the order of the texts in the table component list, it seems that it does do what I expect, leave it in the same order (alphabetic). So why does this work on the list in the table but not the one built during the check? Why does the latter end up reversed?

UPDATE UPDATE: AIGH. OK, figured out part of this. The property ‘printed noun’ was being added to a list as a property, I think, not as a text. So changing the code to the following:

	add "[the printed name of the noun]" to X;
	add "[the printed name of the second noun]" to X;

…seems to now make ‘sort’ behave identically on both lists. But they still fail to match:

This was all starting to sound sort of familiar so I dug through some old code examples and found something from back in the raif days. Some of the code is outdated and won’t compile as written, but it (or something else in the thread) might give you some ideas. Here’s the link to the post:
http://groups.google.com/group/rec.arts.int-fiction/msg/259036a2bdddac3c
Ignore my code at the beginning, I’m pretty sure that’s useless now. Take a look at Roger Helgeson Jr’s code for ideas. I have to run, but will be back later tonight.

Mike-

That looks like just what I need. I tried it, though, and I got this:

…which is really funny, you know, because the Inform manual it points me to says:

…so I’m wondering if I have spacing/typo errors in there somewhere, or if this capability was in fact broken/removed. Probably the former, I know.

HAVING SAID ALL THAT (haha) if I manually define whoozits/whatsits/gewgaws then…that works! So please accept an internet beer or a cookie or both in gratitude. I’m going to try using that code rather than my butchered Ex. 416 and see if that works.

It’s kind of a typo – of sorts … perhaps.

The pluralforming algorithm of Inform wants “gizmoes” rather than “gizmos”.

Both “Some kinds of gizmo are defined” and "Some kinds of gizmoes are defined " compile.

Try adding a line : Understand “open” as something new. Understand “open [something]” as opening. Understand “open [something] with [something]” as opening it with.

(Just adding a new grammar line won’t remove the original ‘unlocking it with’ line.)

Try this. It seems to work.


"Test" by Custo

Combining it with is an action applying to two carried things. Understand "Combine [something] and/with [something]" as combining it with.

Understand the command "Attach" as something new.  Understand "Attach [something] to [something]" as combining it with.

The combining it with action has an object called the item built.

Match state is a truth state that varies. Match state is true.

Setting action variables for combining something with something:
let X be a list of indexed texts;
add the printed name of the noun to X;
add the printed name of the second noun to X;
say "X is presort: [X in brace notation].";
sort X;
say "X is: [X in brace notation].";
repeat through the Table of Outcome Objects begin;
let Y be the component list entry;
say "Y is presort: [Y in brace notation].";
sort Y;
say "Y is: [Y in brace notation].";
now match state is true;
repeat with count running from 1 to the number of entries in Y begin;
unless entry count of X exactly matches the text entry count of Y, now match state is false;
end repeat;
if match state is true begin;
say "Match![line break]";
now the item built is the result entry;
end if;
end repeat.

Check combining it with:
say "The item built lookup is: [the item built].";
if the item built is nothing, say "[The noun] and [the second noun] don't make anything useful." instead;
if the item built is not in limbo, say "That's not available." instead.

Carry out combining it with:
move the item built to the holder of the noun;
remove the noun from play;
remove the second noun from play.

Report combining it with:
say "You now have [an item built]!".

A memory chip is a kind of thing.

A broadcast chip is a kind of thing.

The player is carrying a memory chip and a broadcast chip.

Limbo is a container.  Limbo contains the Klein Blaster.

The test chamber is a room.  The description is "GlaDOS is watching you.".

The player is in the test chamber.

Table of Outcome Objects
component list	result
{"broadcast chip", "memory chip"}	Klein Blaster

You need to have X be a list of indexed text in order for the sorting to work. Also, comparing any text using “if A is B”, even if it is in a list, doesn’t work nicely. I’ve had this problem before. The best way is to compare them using “if A matches the text B” and “if A exactly matches the text B”.

Hope this helps!

Incidentally, you can accomplish this with an “Understand … as … when” phrase. For example:

[code]There is room.

Blorb assembled is a truth state that varies.

A blorb is here. Understand “superblorb” as the blorb when blorb assembled is true.

Before jumping: now blorb assembled is true; continue the action.

Test me with “get superblorb / jump / get superblorb”.[/code]