...if listed in rulebook?

Hi, I have a particular problem. I have a new action phase in my extension called the “redirect” phase, which remaps an action into a different action. I’m trying to write an Unsuccessful Attempt By rule that will suppress the “X can’t do that” when an action is redirected. The simplest means of doing this would be to have a phrase that returns the rulebook a rule is currently in. For example:

Unsuccessful attempt by someone doing something (this is the throw out messages for redirected actions rule):
	if the reason the action failed is listed in the redirect rulebook:
		rule succeeds;
	else:
		continue the action.

Problem is, there seems to be no such phrase that returns the rulebook a rule is in. I’ve looked into a number of extensions and it doesn’t look like any of them quite do this. Does anyone have any ideas?

Based on the final example in Problem-Solving Characters:

To repeat with (Rth - nonexisting rule variable) running through (rb - a rule based rulebook) begin -- end:
	(- for (parameter_object = 0 : (rulebooks_array-->{rb})-->parameter_object ~= NULL : ++parameter_object) 
		{ {Rth} = (rulebooks_array-->{rb})-->parameter_object;  !-).

To decide whether (R1 - [type] based rule) is listed in (RB - a rule based rulebook):
	repeat with R2 running through RB:
		if R1 is R2, yes;
	no.

See if that works for your purposes. Change [type] to whatever you need.
[/code]

That code is for 6G60; it won’t work in 6L02.

Remember that in general a rule can exist in several rulebooks at once.

There’s no way to inspect rulebooks in the current system. They’re meant to be executed, not analyzed.

Your best bet is to set flags somewhere as the redirect phase operates, so that you can look back later and determine that that’s what’s happened.

Thanks… after I modified it, it compiled, and it worked perfectly. I wish I could post an example but it’s quite a hefty chunk of code I’ve been working on for months.

Thanks. In this particular case there are no rulebooks which share rules. I’m using 6L02 by the way.

Actually I managed to get it down to its essential components. Here it is in compilable format.

The big room is a room.

To repeat with (Rth - nonexisting rule variable) running through (rb - an action based rulebook) begin -- end:
	(- for (parameter_object = 0 : (rulebooks_array-->{rb})-->parameter_object ~= NULL : ++parameter_object) 
		{ {Rth} = (rulebooks_array-->{rb})-->parameter_object;  !-).

To decide whether (R1 - action based rule) is listed in (RB - action based rulebook):
	repeat with R2 running through RB:
		if R1 is R2, yes;
	no.

The redirect rules are an action based rulebook. The redirect rules have default failure.

This is the redirect phase rule:
	abide by the redirect rules.

The redirect phase rule is listed before the before stage rule in the action-processing rules.

Unsuccessful attempt by someone doing something (this is the throw out messages for redirected actions rule):
	if the reason the action failed is listed in the redirect rulebook:
		rule succeeds;
	else:
		continue the action.

Josie is a woman in the big room.

Persuasion rule for asking Josie to try doing something:
	persuasion succeeds.

Redirect Josie waiting:
	try josie jumping.

That code really doesn’t work in 6L02. It outputs garbage. Test it:

When play begins:
	showme whether or not the can't take yourself rule is listed in the check taking rules;
	showme whether or not the can't take other people rule is listed in the check taking rules;
	showme whether or not the can't drop body parts rule is listed in the check taking rules;

OK, yes, thanks, you are totally right. I’ve removed it and I’ve been looking at various alternatives. I found the making the redirect rules succeed by default rather than fail makes it do what I want it to do. That throws up another problem: redirected rules don’t activate the unsuccessful attempt by rules. I’ve experimented quite a bit and it doesn’t seem like there’s an easy solution to this, even with editable stored actions. If anyone has any insight into this, I’d be grateful.

Unsuccessful Attempt rules only run for requested actions, so if you really need them to run for redirects you could turn them into requests and set a flag so they succeed:

[code]
Redirecting is a truth state that varies.

First redirect rule: now redirecting is true.

Redirect Josie waiting:
try asking Josie to try jumping.

Last redirect rule: now redirecting is false.

Persuasion rule when redirecting is true: persuasion succeeds.[/code]

I did something like this in Faithful Companion though since it was operating on a variable stored action I had to use Editable Stored Actions to convert the action to a request. Though it’s likely that there are a lot of suboptimal solutions in that code (it was originally coded with a time limit so I had to do some quick patches, in particular that patch arose because I hadn’t realized that Unsuccessful Attempt only ran for requests and I had to kludge it in a hurry).

I think the extension After Not Doing Something by Ron Newcomb is supposed to provide hooks for failed actions that aren’t unsuccessful attempts, but according to this thread it may not be working in 6L02.

Yeah. I tried using editable stored actions, but it doesn’t look like they can alter the current action. I’ll try using that workaround you’ve pointed out, though I think it might complicate things more than I want. After all, this is all for a (very large) extension, and I don’t want to complicate other things. My other solution is to create my own message system, which is not what I want but… I guess that’s the best solution right now.

There are unindexed phrases such as “convert to…” which can modify the current action, but you need to be careful. If possible, avoid them entirely.