Defining new action.

Hi guys. I’m beginner with Inform7 and I wanted to try and implement a new action named kicking.

What I want the player to be able to is to kick a ball in a direction. How far the ball rolls (how many rooms) should ideally be random but more than one should suffice.

I’ve read through most of the documentation but it turns out I’m just not very clever at this.

This is what I have so far:

[code]Understand “kick [something] [somewhere]” as kicking.
Understand “kicking [something] [somewhere]” as kicking.

Kicking is an action applying to one thing.

Check kicking:
if the ball is not in a room with the player:
say “There is nothing to kick here.” instead.
if the noun is not the ball:
say “You don’t want to kick this.” instead.

Carry out kicking:
(this is where the magic should happen, but I have no idea how to do this)[/code]

I’m sorry if this question has been answered a thousand times already but I tried to search it and didn’t find anything that worked for me. If you can direct me to somewhere helpful I will be just as happy :slight_smile:

thanks for your time

Here’s a stab at it, which you should be able to modify to suit your purposes. This will probably make a lot more sense if your map is pretty grid-like.

Kicking it towards is an action applying to one thing and one visible thing. Understand "kick [something] [a direction]" as kicking it towards. Understand "kick [something] towards [a direction]" as kicking it towards.

Check kicking it towards: if the noun is not a ball, instead say "That doesn't look kickable."

Carry out kicking something (called weapon) towards somewhere (called target) begin;
send weapon toward target;
while a random chance of 1 in 2 succeeds begin;
send weapon toward target;

To send (weapon - a thing) toward (target - a direction) begin;
let R be the location of the weapon;
let S be the room target from R;
if S is a room, now weapon is in S;

I haven’t tested this so it probably has syntax errors, but it should get you started.

Edit: fixed some punctuation. Still not tested though.

Thank you so much! I’ll try this right away :slight_smile: