Re: [tf-dis] Capturing a gagged line in a variable
Brought to you by:
kenkeys
|
From: Jacob F. <sup...@gm...> - 2016-05-06 00:18:32
|
You need to create a new evaluation scope so that %{world_name} will be
substituted with its value in time to act as part of the room_X variable
name. Like so, for example:
/eval /set room=%%room_%{world_name}
When the hook fires, a scope is created and substitution is performed on
the hook body, turning that line into this:
/eval /set room=%room_WORLD1
Then, /eval creates a new scope and substitution is performed again,
turning it into this:
/set room=My Room
On a side note, macro substitution is generally a strange thing to do in an
expression, but it works here thanks to some special cases for world fields
(which I didn't know about before, so thanks!). A nicer way to do it in an
expression would be with the world_info function:
/set world_name=$[replace("-", "_", world_info())]%; \
But then, this is a WORLD hook, so the world name is already passed as the
first argument. You can use %1 instead (Or {1} since it's in an
expression). Here's how I would write your hook (I always use /def, mostly
so I can name things, but that's entirely up to you):
/def -hWORLD setRoomWorldHook = \
/set world_name=$[replace("-", "_", {1})]%; \
/eval /set room=%%room_%world_name
I recommend you read the /help on: scope; evaluation; percent compression;
substitution; expressions.
On Thu, May 5, 2016 at 1:46 PM, Colin Mackay <zix...@gm...> wrote:
> So the %; \ fixed it... Starting to understand where it's needed after
> messing with it this afternoon. This is what I ended up with:
>
> /def -ag -t'^<loc>[A-Za-z0-9].*<loc>$' loc_name= %; \
> /set loc_full=%{P0} %; \
> /set loc_wn=$[replace("-", "_", ${world_name})] %; \
> /set room_%{loc_wn}=$[replace("<loc>", "", %loc_full)]
>
> So I end up with the following, when specific text appears:
>
> room_WORLD1 = My Room
> room_WORLD2 = My Other Room
>
>
> Now, I'm trying to use a hook, which works to some degree. All it needs
> to do is place the room_WORLDx contents into the 'room' variable.
>
> /hook WORLD = \
> /set world_name=$[replace("-", "_", ${world_name})] %; \
> /set room=%room_%{world_name}
>
> All it seems to do is put the world name itself there. I'm sure this
> isn't the right way to do this, it's just what I came up with.
>
>
> (*Note*: I do the replace on the world_name variable as my world names
> have hyphens (-) and variable names don't like hypens.)
>
>
> On Thu, May 5, 2016 at 7:38 AM, lost addams <fil...@gm...>
> wrote:
>
>> Wow, that was some serious overlooking on my part.
>>
>> On Thu, May 5, 2016 at 12:25 AM, Kai <tin...@ne...> wrote:
>>
>>> You need a %; between lines in the trigger body:
>>>
>>> /def -ag -t'^<loc>.*<\/loc>$' loc_name = \
>>> /set loc=%{P0} %; \
>>> /send say %{loc}
>>>
>>> --Kai
>>>
>>>
>>> On Wed, May 04, 2016 at 04:05:14PM -0400, Colin Mackay wrote:
>>> > Hello folks.
>>> >
>>> > I've been fiddling with the idea of putting my current location into
>>> the
>>> > status bar for a while, just got around to looking into it. Not sure
>>> if
>>> > this is the best way, but as I connect to 'freeform' MUCKs, there isn't
>>> > anything specific that I can use for my location, so I created a small
>>> > command that will output:
>>> >
>>> > <loc>Room Name</loc>
>>> >
>>> > My plan was to gag the line, while hopefully figuring out how to place
>>> that
>>> > line into a variable. This is my initial test:
>>> >
>>> > /def -ag -t'^<loc>[A-Za-z0-9].*<\/loc>$' loc_name = say %{P0}
>>> >
>>> > And hooray! My character says:
>>> >
>>> > Zxarr says, "<loc>Room Name</loc>"
>>> >
>>> > So I tried going a little farther, which is where I'm starting to lose
>>> > control:
>>> >
>>> > /def -ag -t'^<loc>.*<\/loc>$' loc_name = \
>>> > /set loc=%{P0} \
>>> > /send say %{loc}
>>> >
>>> > Shouldn't this do the same thing?
>>> >
>>> > I've tried %%{P0} as well and replacing %{loc} with %{P0} in the /send
>>> > command...
>>> >
>>> >
>>> > Thanks everyone.
>>>
>>> >
>>> ------------------------------------------------------------------------------
>>> > Find and fix application performance issues faster with Applications
>>> Manager
>>> > Applications Manager provides deep performance insights into multiple
>>> tiers of
>>> > your business applications. It resolves application problems quickly
>>> and
>>> > reduces your MTTR. Get your free trial!
>>> > https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
>>>
>>> > _______________________________________________
>>> > TinyFugue-discuss mailing list
>>> > Tin...@li...
>>> > https://lists.sourceforge.net/lists/listinfo/tinyfugue-discuss
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Find and fix application performance issues faster with Applications
>>> Manager
>>> Applications Manager provides deep performance insights into multiple
>>> tiers of
>>> your business applications. It resolves application problems quickly and
>>> reduces your MTTR. Get your free trial!
>>> https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
>>> _______________________________________________
>>> TinyFugue-discuss mailing list
>>> Tin...@li...
>>> https://lists.sourceforge.net/lists/listinfo/tinyfugue-discuss
>>>
>>
>>
>>
>> --
>> Film the dead; see how they lie.
>>
>>
>> ------------------------------------------------------------------------------
>> Find and fix application performance issues faster with Applications
>> Manager
>> Applications Manager provides deep performance insights into multiple
>> tiers of
>> your business applications. It resolves application problems quickly and
>> reduces your MTTR. Get your free trial!
>> https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
>> _______________________________________________
>> TinyFugue-discuss mailing list
>> Tin...@li...
>> https://lists.sourceforge.net/lists/listinfo/tinyfugue-discuss
>>
>>
>
>
> ------------------------------------------------------------------------------
> Find and fix application performance issues faster with Applications
> Manager
> Applications Manager provides deep performance insights into multiple
> tiers of
> your business applications. It resolves application problems quickly and
> reduces your MTTR. Get your free trial!
> https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
> _______________________________________________
> TinyFugue-discuss mailing list
> Tin...@li...
> https://lists.sourceforge.net/lists/listinfo/tinyfugue-discuss
>
>
|