Detecting Out Of World actions 2023

I ask because I need to set a flag when an action is out of world.

My understanding is I can detect out-of-worldness with this:

But as soon as it’s the new turn, that would no longer be true, so I need to poke the result into a variable then read it on the next turn.

I guess I’m trying to work out the best time to capture the result. It needs to be in a rule that will indeed run every turn (which the every turn rules do not…) at the end of the turn, and I’m looking around the vicinity of “the last specific action-processing rule” as a good place to intervene. Is it?

-Wade

How about “before reading a command”?

Could you live with being able to tell if the previous action was out of world at the beginning of a turn?

lab is a room.

previous-action-was-out-of-world is a truth state that varies.
current-action-is-out-of-world is a truth state that varies.

To decide if the current action is an action out of world: (- meta -)

Setting action variables:
  now previous-action-was-out-of-world is current-action-is-out-of-world;
  if the current action is an action out of world, now current-action-is-out-of-world is true;
  else now current-action-is-out-of-world is false;
  if the previous-action-was-out-of-world is true, say "It was out of this world."

Setting action variables isn’t part of the action-processing rules and is run for both out of world actions and otherwise.

And in case the flexibility is useful, you can get the out-of-worldness of an action, current or otherwise, with:

To decide if (ac - an action) is out of world: (- ActionHasFlag({ac}, OUT_OF_WORLD_ABIT) -)

Include (-
[ ActionHasFlag stored flag ac at;
ac = BlkValueRead(stored, STORA_ACTION_F);
at = FindAction(ac);
if (at == 0) rfalse;
if (ActionData-->(at+AD_REQUIREMENTS) & flag) rtrue;
rfalse;
];
-)
1 Like

Yeah, that’s really what I want to do. Sounds like I didn’t make myself clear enough in my OP; my apologies. I’ll give this code a try. Thanks.

EDIT - Looks like it’s delayed by a turn? If I do an out of world action, the alert shows up two prompts later. I just added this code to yours so it would print FROTZ every time I performed this out of world action.

frotzing is an action out of world.

Understand "frotz" as frotzing.

Carry out frotzing:
	say "FROTZ.";

-Wade

looks right to me…

lab is a room.

previous-action-was-out-of-world is a truth state that varies.
current-action-is-out-of-world is a truth state that varies.

Setting action variables:
  now previous-action-was-out-of-world is current-action-is-out-of-world;
  if the current action is out of world, now current-action-is-out-of-world is true;
  else now current-action-is-out-of-world is false;
  if the previous-action-was-out-of-world is true, say "It was out of this world.";
  if the current action is out of world, say "it *is* out of this world.";

To decide if (ac - an action) is out of world: (- ActionHasFlag({ac}, OUT_OF_WORLD_ABIT) -)

Include (-
[ ActionHasFlag stored flag ac at;
ac = BlkValueRead(stored, STORA_ACTION_F);
at = FindAction(ac);
if (at == 0) rfalse;
if (ActionData-->(at+AD_REQUIREMENTS) & flag) rtrue;
rfalse;
];
-)

test me with "z / z / verify / z / verify / verify"

lab
 
>test me
(Testing.)
 
>[1] z
Time passes.
 
>[2] z
Time passes.
 
>[3] verify
it *is* out of this world.
 
The game file has verified as intact.
 
>[4] z
It was out of this world.
 
Time passes.
 
>[5] verify
it *is* out of this world.
 
The game file has verified as intact.
 
>[6] verify
It was out of this world.
it *is* out of this world.
 
The game file has verified as intact.
 
> 

I didn’t include the I6 part the first time. I was still using To decide if the current action is an action out of world: (- meta -) as per your first code block, which gave the delay. With that out and the I6 in, it’s working. Thanks.

-Wade

Other than the meta version considering the test me itself to be an out of world action, It’s the same results.

Output with meta lab

test me
it is out of this world.
(Testing.)

[1] z
It was out of this world.

Time passes.

[2] z
Time passes.

[3] verify
it is out of this world.

The game file has verified as intact.

[4] z
It was out of this world.

Time passes.

[5] verify
it is out of this world.

The game file has verified as intact.

[6] verify
It was out of this world.
it is out of this world.

The game file has verified as intact.

Not for me!

Try this:

Summary
lab is a room.

previous-action-was-out-of-world is a truth state that varies.
current-action-is-out-of-world is a truth state that varies.

To decide if the current action is an action out of world: (- meta -)

Setting action variables:
  now previous-action-was-out-of-world is current-action-is-out-of-world;
  if the current action is an action out of world, now current-action-is-out-of-world is true;
  else now current-action-is-out-of-world is false;
  if the previous-action-was-out-of-world is true, say "It was out of this world."

frotzing is an action out of world.

Understand "frotz" as frotzing.

Carry out frotzing:
	say "FROTZ.";

Test me with "frotz/s/z/frotz/verify/z/z".

I get a delay of a turn on the first frotz, then a one-turn-delayed double echo on the frotz/verify combo.

-Wade

… Okay you tricked me by adding a present tense check between versions :stuck_out_tongue:

Finally, when I text-dump the code you placed under ‘looks right to me’, it is indeed right, and it’s right with -meta- or the fancy code.

-Wade

1 Like

Won’t setting action variables be run again if one action triggers another, though?

… yeah.

@severedhand , try this:

previous turn count is a number that varies.
previous-action-was-out-of-world is a truth state that varies.

setting action variables:
if the previous turn count is the turn count, now previous-action-was-out-of-world is true;
else now previous-action-was-out-of-world is false;
now the previous turn count is the turn count

That’s why I’d stick it in before reading a command: that’s guaranteed to happen only once per turn, and definitely before the new action has started clobbering the old variables.

1 Like

At most once per turn, really. Consider goofy inputs like “WAIT.VERSION.WAIT.VERSION.”

1 Like

Good point. Maybe at the beginning of the turn sequence rules?

The turn count comparison approach works for “WAIT.VERSION.WAIT.VERSION.”

Does it work for WAIT. VERSION. VERSION ? I thought the turn count didn’t increment for out-of-world actions.

Yes.

It doesn’t; that’s what it was relying on. If the turn count is unchanged since the last action, it concluded the previous action was out of world.

But it fails for the multiple action case. I had convinced myself it would work and didn’t check. Dang, this is hard. OK, how 'bout:

lab is a room.
spam is in lab.
box is in lab.

Include (-
Global previous_action_name;
Global current_action_name = ##Look;
[ BeginAction a n s moi notrack  rv;
        ChronologyPoint();
previous_action_name = current_action_name;
current_action_name = action;
        @push action; @push noun; @push second; @push self; @push multiple_object_item;

        action = a; noun = n; second = s; self = noun; multiple_object_item = moi;
        if (action < 4096) rv = ActionPrimitive();

        @pull multiple_object_item; @pull self; @pull second; @pull noun; @pull action;

        if (notrack == false) TrackActions(true, meta);
        return rv;
];
-) replacing "BeginAction".

To decide what action name is the previous action name: (- previous_action_name -)

To decide if the previous action was out of world:
decide on whether or not previous action name is out of world.

setting action variables:
say "previous action [previous action name] was [if previous action was out of world]out of[else]in[end if] world.";

To decide if (ac - an action name) is out of world:
(- ActionNameHasFlag({ac}, OUT_OF_WORLD_ABIT) -)

Include (-
[ ActionNameHasFlag ac flag at;
!ac = BlkValueRead(stored, STORA_ACTION_F);
at = FindAction(ac);
if (at == 0) rfalse;
if (ActionData-->(at+AD_REQUIREMENTS) & flag) rtrue;
rfalse;
];
-)
test me with "jump. actions. z. z. verify. verify. take all. verify. verify. jump. jump."

You don’t get good results until turn 2, and results after turning on the actions listing is weird because of how that’s special-cased.

output previous action waiting was in world.

lab

You can see spam and box here.

test me

previous action waiting was in world.

(Testing.)

[1] jump. actions. z. z. verify. verify. take all. verify. verify. jump. jump.

previous action was in world.

You jump on the spot.

previous action jumping was in world.

Actions listing on.

previous action was in world.

[waiting]

Time passes.

[waiting - succeeded]

previous action waiting was in world.

[waiting]

Time passes.

[waiting - succeeded]

previous action waiting was in world.

[verifying the story file]

The game file has verified as intact.

[verifying the story file - succeeded]

previous action verifying the story file was out of world.

[verifying the story file]

The game file has verified as intact.

[verifying the story file - succeeded]

previous action verifying the story file was out of world.

[taking spam]

spam: Taken.

[taking spam - succeeded]

previous action taking was in world.

[taking box]

box: Taken.

[taking box - succeeded]

previous action taking was in world.

[verifying the story file]

The game file has verified as intact.

[verifying the story file - succeeded]

previous action verifying the story file was out of world.

[verifying the story file]

The game file has verified as intact.

[verifying the story file - succeeded]

previous action verifying the story file was out of world.

[jumping]

You jump on the spot.

[jumping - succeeded]

previous action jumping was in world.

[jumping]

You jump on the spot.

[jumping - succeeded]

1 Like

I think Zed’s first system’s already working for me, though maybe not quite as intended?

Summary:

  • Zed’s setting action variables code sets a flag during a turn (is the current action out of world?).
  • At the start of the next turn, at Before reading a command, I read the status of that flag to see if it is true, which would indicate the last action that ran was out of world. From my testing, this is working. Since out of world actions don’t trigger each other, it doesn’t matter if this flag gets set a bunch of times during a turn. All that matters is the last action to run sets it correctly.
  • I am not making any use of the second flag (previous action was out of world).

Re: turn count counting, we/I cannot use that method because it’s what led me to asking this question in the first place :slight_smile: I’m already using the Variable Time Control extension with the ability to have some actions take no time, which then doesn’t increase the turn count. And, for another mechanism I’m making, I needed a way to distinguish non-time-taking in world actions from out of world actions… because neither makes the turn count advance, how could I otherwise tell them apart?

-Wade

Like Daniel pointed out, my solution of last night has a problem. Say you have…

>verify
The game file has verified as intact.
 
>unlock case with key
(first taking the brass key)
 
You unlock the case.

when the unlock case with key action begins, previous action was out of world is true. But during the carrying requirements rule for the unlocking action, an implicit take is triggered. During that take, previous action was out of world becomes false… and it stays false when the take ends and the unlocking action resumes. So the unlocking action thought the previous action was out of world during its Before rules, but not the other rulebooks.

Is what you want more like “did previous command correspond to an out of world action?” than “was previous action out of world?”

Let me illustrate why I think it’s working now by pasting into the verify/unlock demo:

See, I’m not making use of that ‘previous’ flag you supplied, only the ‘current’ one. And it seems to be set correctly at the moment just before we produce a new prompt.

-Wade