[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Using somthing to display information below a trigger?

Using somthing to display information below a trigger?

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Dphyre   (2 posts)  [Biography] bio
Date Tue 10 Jan 2023 09:42 AM (UTC)

Amended on Tue 10 Jan 2023 09:46 AM (UTC) by Dphyre

Message
So I'm trying to drive a boat, but the directions are confusing me. I'll try and explain. At the start of the voyage, the ship is facing completely hubwards. Thus, when looking at the ocean at the start you would position yourself like this:

------ ---------------hubwards
-turnwise-hubwards ^ widdershins-hubwards
-----------------------\ | /
---------turnwise <- ship -> widdershins
-----------------------/ | \
-turnwise-rimwards v widdershins-rimwards
-----------------------rimwards

You're always trying to go Hubwards, toward City A. A skilled sailor can look at the sun if its daylight, or the stars if its nighttime, and if they pass the check, the'll get a message similar to these:

"Squinting up at the sun, you determine that the ship is heading hubwards and that you're three hundred and eighty-seven miles rimwards and nine miles widdershins of City A."

"Squinting up at the sun, you determine that the ship is heading widdershins-hubwards and that you're two hundred and ninety-one miles rimwards and fifty-seven miles widdershins of City A."

"Squinting up at the sun, you determine that the ship is heading widdershins-rimwards and that you're two hundred and forty-nine miles rimwards and sixty-three miles widdershins of City A."

So with those messages in mind, and knowing that you're always trying to go toward city A, it can get confusing. If the ship is already going straight Hubwards, well that's great, but sometimes its not. If a sailor gets turned around or in a whirlpool, it can be going any direction.

I understand that I can use regular expression to capture the directions, I think, and even the numbers (not as important to me) when I trigger that message and use the ColourNote function to print out below the message I triggered to tell me the actual way to go.

So for the first trigger, ideally it would print below it: '87 miles Hubwards to City A, Adjust heading turn-hub for 9 miles'

For the second trigger it would ideally print below it: "291 miles away from city A, adjust heading turn-hub for 57 miles"

For the third trigger it would ideally print below it: "249 miles away from city A, adjust heading turn-hub for 63 miles"

Now I realize since I got confused typing that up, it might not make since. I'd

^((Squinting up at the sun|Gazeing up at the stars), you determine that the ship is heading (?<direction>.*?)( and that you're (?<miles_y>.*?) miles? (?<rim_or_hub>rimwards|hubwards)( and (?<miles_x>.*?) miles? (?<turn_or_wid>turnwise|widdershins))? of .*?)?\.$

I was hoping I could use something like that to capture the miles, and the directions, store them in a variable maybe, and have it transpose the directions for me. I'm not looking for anything that inputs commands to the mud itself, obviously, but something that inserted information next the triggered line itself would be helpful.

so anytime the mud seen "widdershins-rimwards" it would spit out (TH) or anytime the mud seen"turnwise-rimwards" it would spit out (WH) in bright colors to make it easier to see.

If anyone could provide any help or guidance, I would be much appreciated.


Thank you.
[Go to top] top

Posted by Fiendish   USA  (2,513 posts)  [Biography] bio   Global Moderator
Date Reply #1 on Tue 10 Jan 2023 05:10 PM (UTC)

Amended on Wed 11 Jan 2023 09:19 AM (UTC) by Fiendish

Message

First lets get your trigger pattern to work…

^((Squinting up at the sun|Gazeing up at the stars), you determine that the ship is heading (?<direction>.*?)( and that you're (?<miles_y>.*?) miles? (?<rim_or_hub>rimwards|hubwards)( and (?<miles_x>.*?) miles? (?<turn_or_wid>turnwise|widdershins))? of .*?)?\.$

Looks slightly wrong to me. I think you’ll want ?P to start your named captures, not just ?.

Also make your trigger send to Script, since you’ll need to do some script functions to convert some words to numbers (“fifty-seven” to 57).

Once your trigger matches on your line, you should be able to access the named captures with “%” in your code.

The hardest part of this is going to be converting the words to numbers, but MUSHclient does already have some code that will almost do exactly what you need for that, but it expects slightly different formatting (no dashes), so I think first you’ll want to replace “-” with " " in the “%” variable.

Maybe try something like…

so anytime the mud seen “widdershins-rimwards” it would spit out (TH) or anytime the mud seen“turnwise-rimwards” it would spit out (WH) in bright colors to make it easier to see.

For this part it sounds like you’ll want either a series of conditions “if it’s this then do that, else if it’s this then do that, else …” or a lookup table. Maybe something like


https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Nick Gammon   Australia  (22,966 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Tue 10 Jan 2023 07:37 PM (UTC)
Message
@Fiendish - in markdown quotes are a line starting with ">" not [quote] ... [/quote].

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Fiendish   USA  (2,513 posts)  [Biography] bio   Global Moderator
Date Reply #3 on Wed 11 Jan 2023 09:18 AM (UTC)
Message
Nick Gammon said:

@Fiendish - in markdown quotes are a line starting with ">" not [quote] ... [/quote].

Heh. I didn't realize I couldn't mix!

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


3,270 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]