Can a relation imply or execute an action?

Is it possible to have a relation that can imply or execute an action, such as:

Thingy adjusts X by Y. [Where Thingy is a kind of thing, adjusting is the relation, x is a value that varies, ‘by’ is an addition action defined in the relation, and Y is a number that varies.]

I’ve looked and hacked code, but can’t seem to find a way to do it.

I have, however, been able to come up with a bit of a work-around by changing the relation’s name to identify the action I want, and then using code to identify the relation and execute a function. (I should note that I’m breaking up the pieces of code between a source project and an extension so that the source code reads like English, not like code.) As such, my work-around looks like this…

In the source code…

Thingy adds1to X. [Where Thingy is a kind of thing, X is a kind of Z and adds1to is a relation.]

And then (in my extension)…

Repeat with N running through Zs adds1toed by Thingy: adds1function to N; [Where adds1function is a function that adds 1 to a value contained within Zs, and N is the particular Z being adjusted]

The code works. (Which I’m pretty happy about… Hurrah for the beginner!) But the obvious downside, of course, is that I need to set up a relation for any value I want to alter (ie. adds2to, adds3to, rolls1die6for, etc.) which makes it very clunky coding.

Any suggestions??

To piggyback on Neo’s question, in trying out an answer for this it seems like I7 only passes values into phrases, for example:

There is a room.

Sliminess is a number variable. 

Dungeon Master is a thing. 

To (Thing - a thing) adjusts (X - number) by (Y - a number):
	say "[Thing] adjusts [X] by [Y].[line break]";	
	increase X by Y.
	
Instead of jumping:
	Dungeon Master adjusts sliminess by 1. 
	
test me with "jump / jump / jump".

How would you write that phrase to increase whatever number variable you pass into it?

This question is somewhat ambiguous.

If you’re asking how you can use a relation to link objects to actions, that depends on when you want the actions to take place. Do you want to affect every object that’s in the relation at the end of each turn (which is easy enough), or do you want to affect an object as soon as it’s related with “now” (which is harder)?

Here’s an example of linking objects to stored actions which can then be executed by other code:

[code]Home is a room.

Leading-to relates various things to one stored action. The verb to lead to (it leads to, they lead to, it is leading to, it is led to) implies the leading-to relation.

After examining something:
if the noun relates to a stored action by the leading-to relation:
let SA be the stored action that the noun relates to by the leading-to relation;
try SA.

Adjusting it to is an action applying to one thing and one number.

Report adjusting something (called X) to a number (called Y):
say “You adjust [the X] to [Y].”

A dial is in Home. It is fixed in place.

Thingy is in Home.
Thingy leads to the action of adjusting the dial to 5.

Test me with “x thingy”.[/code]

If you’re asking how you can relate three things together (Thingy, X, and Y), the easiest way to do that is probably to use a table. The second easiest is to use a relation of relations, so that Thingy is related to a set of relationships between Xs and Ys.

Hey Vapor,

Thanks! I haven’t been able to sit down and try out your suggestion, but your code example looks spot on. I had no idea you could use a stored action or even another relation with relations.

Again, thanks heaps!

Cheers!