Targeting with intercepts

For builders to discuss and ask building questions.
Post Reply
User avatar
Casamir
Sword Grand Master
Sword Grand Master
Posts: 286
Joined: Tue Aug 04, 2009 2:27 am
Location: The Twilit Grottoes beneath Exham Priory
Contact:

Targeting with intercepts

Post by Casamir » Fri Sep 13, 2013 6:15 pm

I was wondering how I might code a target into an intercept prog. Similarly if I wanted to do something like an embroider-able handkerchief. Or if I wanted to have a magic kazoo shoot a sound burst at X for example, with the trigger word of 'humm', how do I get that to target X? Is there a place holder like with % in aliases?

Code: Select all

>intercept_prog embroider %~
mposet $o short a handkerchief embroidered with '%'
~
>intercept_prog humm~
if string(1) == X
  mpcast soundburst X
endif
~
|
"Get thee back into the tempest and the Night's Plutonian shore!" "'Tis as impossible that he's undrowned as he that sleeps here swims." "I'm begging you please wake me up, In all my dreams I...."
User avatar
Harroghty
Staff
Staff
Posts: 9695
Joined: Tue Jul 27, 2004 5:38 pm

Re: Targeting with intercepts

Post by Harroghty » Fri Sep 13, 2013 7:23 pm

You need to check for the correct subsequent phrase. e.g.

Code: Select all

>intercept_prog embroider~
if actorhasobjnum(i12345)
  if stringprefix($1) == handkerchief
    embroiders....
  else
    mpunintercept
  endif
else
  mpunintercept
endif
~
The embroidery itself could be done a couple of ways: you could create certain parameters that must be applied (think about some of the custom merchants) or you could give total free reign (think the dummies). I can look at your product and give you some suggestions based upon your desired goal.
"A man may die yet still endure if his work enters the greater work, for time is carried upon a current of forgotten deeds, and events of great moment are but the culmination of a single carefully placed thought." - Chime of Eons
Levine
Sword Grand Master
Sword Grand Master
Posts: 254
Joined: Tue Sep 28, 2004 7:31 am

Re: Targeting with intercepts

Post by Levine » Tue May 14, 2019 12:25 pm

I've been trying to figure out how I can have a customisable variable. I don't have a specific goal right now (I found a workaround), but theoretically, I'd like to know how, say, the handkerchiefs or wooden signs were achieved so I can streamline my scripts and have the option brewing in my mind for other uses.

I wrote something up below (the blank after == is intentional), and I want that to be whatever variable that the user inputs. So, I'm hoping this following script:

Code: Select all

>intercept_prog customise~
if stringprefix($1) ==
  mposet $o short a $1 birthday card
  mpechoat $N You customise a birthday card.
else
  mpunintercept
endif
~
Would produce this effect:

Code: Select all

> customise pink
You customise a birthday card.
You are carrying:
     a pink birthday card (perfect)
Would that work?
Must I kill them
To make them lie still
User avatar
Harroghty
Staff
Staff
Posts: 9695
Joined: Tue Jul 27, 2004 5:38 pm

Re: Targeting with intercepts

Post by Harroghty » Tue May 14, 2019 1:06 pm

Yes, it's possible but I typically don't encourage it. Otherwise one finds:
A butt birthday card lies here.
For posterity though, one uses $0, not $1. e.g.

Code: Select all

>intercept_prog customize~
mposet on $n $o short a $0 birthday card
mpechoat $n You customize a birthday card (and it better be an acceptable, IC choice).
~
There are tons of things out there that give a player a range of choices. Pick (once) any color from these colors, then you just maybe have a prog like...

Code: Select all

>intercept_prog color~
if stringprefix($1) == pink
or stringprefix($1) == red
  if stringprefix($1) == pink
    mposet on $n $o etc... etc..
  else
    if stringprefix($1) == red
      mposet on $n $o etc... etc... etc..
    endif
  endif
else
  mpechoat $n That is not an acceptable color.
endif
~
"A man may die yet still endure if his work enters the greater work, for time is carried upon a current of forgotten deeds, and events of great moment are but the culmination of a single carefully placed thought." - Chime of Eons
Levine
Sword Grand Master
Sword Grand Master
Posts: 254
Joined: Tue Sep 28, 2004 7:31 am

Re: Targeting with intercepts

Post by Levine » Tue May 14, 2019 2:45 pm

In the first example, does this mean that instead of having an empty value after "==", I can just use $0 right away without an if string/stringprefix?

And, does that mean that if string/stringprefix isn't used, the intercept (in this case, "customize") would not be treated as $0?
Must I kill them
To make them lie still
User avatar
Harroghty
Staff
Staff
Posts: 9695
Joined: Tue Jul 27, 2004 5:38 pm

Re: Targeting with intercepts

Post by Harroghty » Tue May 14, 2019 6:23 pm

$0 will be everything after customize: no if check is needed.
"A man may die yet still endure if his work enters the greater work, for time is carried upon a current of forgotten deeds, and events of great moment are but the culmination of a single carefully placed thought." - Chime of Eons
Post Reply