Work around for an action applying to an action? [Continuous Actions and Stopping Continuous Actions]

I am currently working on a continuous action system where certain actions, once initiated, will be done every turn by the actor that initiated the actor. So far I’ve gotten this to work, however I’m now stuck on trying to figure out how to allow an actor to stop the action. It seemed to me the best way to go about this would be a STOP action but it seems an action cannot apply to another action nor an action name. The only other approach that came to mind would be to create a stop action which applies to a text, and to then compare that string to the actions I have stored in a list, but I’m unsure if there is even a way to compare a string to an action or action name.

Here is the code for a stopping action applying to an action; which does not compile:
Stopping is an action applying to one action.

Understand "Stop [an action]" as stopping.

Carry out an actor stopping an action(called the stopped action):
	if the stopped action is listed in the currently performing continuous actions of the actor:
		remove the stopped action from the currently performing continuous actions of the actor.
And this is the code for the continuous actions:

Lab is a room. Here is a person called Gwen.

The list of continuous actions is a list of action names that varies.
The list of continuous actions is {jumping action}.
Every person has a list of stored actions called currently performing continuous actions.

Every turn:
follow the update continuous actions rule.

This is the update continuous actions rule:
repeat with p running through persons:
repeat with a running through the currently performing continuous actions of p:
try a.

After an actor doing something while the action name part of the current action is listed in the list of continuous actions:
if the current action is not listed in the currently performing continuous actions of the actor:
add the current action to the currently performing continuous actions of the actor.

Carry out an actor jumping when the current action is not listed in the currently performing continuous actions of the actor(This is the initiate jumping rule):
say “[actor] initiate jumping”.

Carry out an actor jumping when the current action is listed in the currently performing continuous actions of the actor(This is the continue jumping rule):
say “[actor] continue jumping”.

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

I feel pretty stumped on how even to approach this problem so any possible ideas would be greatly appreciated, even if you’re unsure if they would work/unsure how to implement them. Thanks in advance.

how long do you expect a person’s list of currently performing continuous actions to get? It looks like, as coded, If a person has 3 actions in their list, they perform all 3 each turn, sort of moving three times as fast as the player. Is that what’s intended?

1 Like

Yes this is intended, the amount of continuous actions in the project I’m making this for will be decently long I suspect, though I haven’t completely mapped it out, I’d guess a dozen or so actions at least. However the next step I have planned (after solving the stopping problem) will be to limit what continuous actions can be done at the same time, so that even if there may be a dozen or even dozens of continuous actions the aim would be that an given persons currently performing continuous actions would be limited to a couple of actions, maybe a half dozen max. I was mainly thinking of limiting things such that if someone is eating then they can’t also be talking, or if they’re holding something in both hands they can’t then hold a third thing.

One goal of this approach is for the combination of actions to sort of create their own unique action the actor is doing. So for example if walking was a continuous action you could be walking with an NPC somewhere while also talking to them, creating a sort of new interaction of walking and talking.

As for ‘moving faster then the player’, the player can also do continuous actions so everyone, NPC or player, will have the same amount of actions available to them barring circumstances that may limit an NPC or player’s pool of available actions. As well the continuous actions I have in mind will be things that are a bit more ‘trivial’ mainly meaning that they would make sense as things someone could do while doing something else. For example jumping (or exercising) may be a continuous action you can do alongside talking as a non-continuous action.

Ultimately the game I have in mind for this system is a sort of life sim sandbox game (though I think others could find other applications for it) and so the main goal of the additional actions per turn is to add more liveliness to the characters as well as more possible interactions (and combinations of interactions) to the player.

I think you’re going to want a list of actions, not action names per se. Actions are what you can use in a try phrase. And it’s easy to get an action name from an action.

I think you might be best off making a Table with an action column. And then…

Stopping is an action applying to one topic.
Understand "stop [text]" as stopping.
The stopping action has an action called the action understood.

and a check rule that iterates through the table seeing if the topic understood exactly matches the action name part of each action in turn. If it finds one, it assigns the action understood; otherwise it gives an error message. And then your carry out rule knows what action it needs to consider.

Then you might want to have separate lists per person of queued actions and ongoing actions. When someone’s finished doing their existing ongoing actions, check the queued action list. try the action, then add it to the ongoing action list and remove it from the queued list. So checking presence in the ongoing action list lets you give a message with " continues…" like you want.

2 Likes

Thank you, tables are actually the perfect solution. I did still keep it to action names since action names aren’t actor dependent, so I can just have one action name stored for say the jumping action, that then any actor can turn that into that actor jumping, as opposed to storing all possible actor noun actions as possible continuous actions.

Here is the code updated with the use of tables to make the stopping action work for anyone interested:
Lab is a room. Here is a person called Gwen.

Every person has a list of stored actions called currently performing continuous actions.

Table of Continuous Actions
String		Action Name
"jumping"	Jumping Action

Every turn:
	follow the update continuous actions rule.

This is the update continuous actions rule:
	repeat with p running through persons:
		repeat with a running through the currently performing continuous actions of p:
			try a.
			
After an actor doing something while the action name part of the current action is an action name listed in the table of continuous actions:
	if the current action is not listed in the currently performing continuous actions of the actor:
		add the current action to the currently performing continuous actions of the actor.

Carry out an actor jumping when the current action is not listed in the currently performing continuous actions of the actor(This is the initiate jumping rule):
	say "[actor] initiates jumping".

Carry out an actor jumping when the current action is listed in the currently performing continuous actions of the actor(This is the continue jumping rule):
	say "[actor] continues jumping".

Stopping is an action applying to one topic.

Understand "Stop [text]" as stopping.

Check an actor stopping when "[the topic understood]" is not a string listed in the table of continuous actions:
	say "That isn't a continuous action.";
	rule fails.

Check an actor stopping:
	choose row with string of "[the topic understood]" from table of continuous actions;
	repeat with a running through currently performing continuous actions of the actor:
		if the action name part of a is the action name entry:
			continue the action;
	say "You can't stop an action you aren't doing";
	rule fails.	

Carry out an actor stopping:
	choose row with string of "[the topic understood]" from table of continuous actions;
	repeat with a running through currently performing continuous actions of the actor:
		if the action name part of a is the action name entry:
			remove a from the currently performing continuous actions of the actor.

Report an actor stopping:
	say "[The actor] stops [the topic understood]".

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

test me with "jump/ z/ gwen, jump/ z/ stop jumping/ z/ gwen, stop jumping, z".
1 Like