Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ General ➜ Find the red Asterisk

Find the red Asterisk

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


Posted by Fletchling   Australia  (54 posts)  Bio
Date Fri 22 Dec 2006 10:14 PM (UTC)

Amended on Sat 23 Dec 2006 12:37 AM (UTC) by Nick Gammon

Message
On the multi-line graphic below there is a character I am trying find the coordinates of a bold-red asterisk on black background,

Example 1. In the case below it is;

+------------------------------+                  
|      *    ?                  |
|                *.            | <
|             *   .         .. |
+------------------------------+
                 ^
X = 17
Y = 2


Example 2. In this case it is;
+------------------------------+
| .     .  .       .           |
|        .            .       .|
|                              |
|       .          *           |
|             .                |
|        .                     |
|          .     *            .|
|    *   *     ?               | <
|        .                 .   |
+------------------------------+
         ^
X = 9
Y = 8



Notes:
1. The ^ and < around the graphic are mine added for clarity.
2. In all cases, the first and last lines are +---------+ as indicated.
3. Only one asterisk on the graphic is red.

This has turned out more complex than I'd thought, I'm thinking some mix of gsub.find and triggers... Any clues to point me in the right direction appreciated very much.
Top

Posted by Fletchling   Australia  (54 posts)  Bio
Date Reply #1 on Fri 22 Dec 2006 10:15 PM (UTC)
Message
Akk, the graphics above are screwed up, I'll repost later with spaces in the right spots to make sense of it all.

Sorry.
Top

Posted by Fletchling   Australia  (54 posts)  Bio
Date Reply #2 on Fri 22 Dec 2006 10:17 PM (UTC)
Message
+------------------------------+
|.................*....... ?.. |
|.........*....................| <
|....*.........................|
+------------------------------+
..........^
X = 10
Y = 2

spaces replaced with "."s
Top

Posted by Nick Gammon   Australia  (23,094 posts)  Bio   Forum Administrator
Date Reply #3 on Sat 23 Dec 2006 12:37 AM (UTC)
Message
Use the [code] tag - I've fixed up your original post.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Fletchling   Australia  (54 posts)  Bio
Date Reply #4 on Sat 23 Dec 2006 12:39 AM (UTC)
Message
Thank you Nick.
Top

Posted by Nick Gammon   Australia  (23,094 posts)  Bio   Forum Administrator
Date Reply #5 on Sat 23 Dec 2006 12:40 AM (UTC)
Message
I would first build up the graphic into a series of lines in a table. You could make a trigger to capture lines that are | <something> |.

Then iterate through the lines (each line represents a y coordinate). Inside each line use string.sub iteratively to look at each individual character, that will be your x coordinate.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #6 on Sat 23 Dec 2006 12:42 AM (UTC)
Message
You could basically think of this as a 2D array, correct? Shouldn't be too hard.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Fletchling   Australia  (54 posts)  Bio
Date Reply #7 on Sat 23 Dec 2006 12:48 AM (UTC)
Message
Hrmm, that makes sense. I'll have a go at this over the next week.

Thank you.
Top

Posted by Onoitsu2   USA  (248 posts)  Bio
Date Reply #8 on Sat 23 Dec 2006 08:05 AM (UTC)
Message
Good luck to you on this, as this will reduce the pain in the neck that navigating Vidblain causes, or at least for those that don't use a portal. If you DO get this functioning, then one could ALWAYS determine SW's to ANY area accessable from the Vidblain Continent.

BTW, this is being made for Aardwolf MUD, for those that don't already know of the MUD this is to be used on.

Laterzzz,
Onoitsu2
Top

Posted by Nick Gammon   Australia  (23,094 posts)  Bio   Forum Administrator
Date Reply #9 on Sat 23 Dec 2006 07:08 PM (UTC)
Message
Of course, you are looking for the red asterisk, not just any one, so I would first process each line as it arrived in my trigger. Using the style runs that you get in Lua I would gradually build up the text of the line by appending the text of each style run to the previous one.

Then, if a style run had a red asterisk in it, I would change the asterisk to some other character which doesn't occur elsewhere. Then when going through that line character-by-character you could tell when you had hit the asterisk.

Another approach is to simply look at each style run, and if you get (say) a run of 6, which is not the red asterisk, add 6 to the x-coordinate, and repeat until you reach the red asterisk.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Onoitsu2   USA  (248 posts)  Bio
Date Reply #10 on Thu 28 Dec 2006 10:31 AM (UTC)
Message
I have a VERY junky bit of code, I am half asleep as I code it, as I am 99% of the time when I get a hit of inspiration. It will put a Note of your X coord, then Y coord, it is shown WITHIN the map, but you can make it do whatever you want it to do ... and hopefully improve upon its design. And YES Nick I know that this is about as sloppy as coding can be, but as previously stated I am dead asleep, after having been up for about 24 hours...

If someone would be so kind as to try this code, and if so improve upon it, then we Mushclient users on Aardwolf will have the ONLY Vidblain speedwalker, that is completely flexible.

My trigger matches on this ...
<triggers>
  <trigger
   enabled="y"
   keep_evaluating="y"
   match="^(\+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\+)|(\|(.*){30}\|)$"
   regexp="y"
   script="VidblainBigMap"
   sequence="100"
  >
  </trigger>
</triggers>



function VidblainBigMap(sName,sLine,wildcards,STYLES)
if sLine ~= "+------------------------------+" then
local line
line = tonumber(GetVariable("Vidblain_Line"))
if line == nil or line > 30 then line = 0 end
local col
col = 0
local str = {}
local linestyles = table.getn(STYLES)
for style = 1, linestyles do
  if RGBColourToName(STYLES[style]["textcolour"]) == "red" and string.sub(STYLES[style]["text"],1,1) == "*" then
  SetVariable("Vidblain_Line", line)
  --Note(tonumber(STYLES[style]["offset"]) - 1)
  for stylenum = 1, style - 1 do
    col = col + tonumber(STYLES[stylenum]["length"]) -- STYLES[style]["length"]
  end -- for
  col = col - 1
  Note(col)
  Note(line)
  DoAfterSpecial(0.1,'DeleteVariable("Vidblain_Line")',12)
  
  --Note(string.find(sLine,"*"))
  end -- if
  --table.insert (str, RGBColourToName(STYLES[style]["textcolour"]))
  --table.insert (str, RGBColourToName(STYLES[style]["backcolour"]))
  --table.insert (str, STYLES[style]["text"])
end -- for
line = tonumber(line) + 1
SetVariable("Vidblain_Line", line)
end -- if
end -- VidblainBigmap


Take care, I am going to go pass out, and prolly end up working this over in my sleeping mind, as I do MANY MANY nights, and causes TERRIBLE sleeplessness, even when on the brink of passing out.

Enjoy :)
Top

Posted by Onoitsu2   USA  (248 posts)  Bio
Date Reply #11 on Sat 30 Dec 2006 11:13 AM (UTC)

Amended on Sat 30 Dec 2006 11:14 AM (UTC) by Onoitsu2

Message
Here is the "Finished" set of triggers, aliases, and functions ....

<triggers>
  <trigger
   enabled="y"
   match="^Minor Celestial Antipode$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>Note("")
ColourNote("white","blue","Vidblain SW's are as follows:")
ColourNote("lime","black","Darklight      = run 7n14edn2e3nd")
ColourNote("lime","black","Doom and Gloom = run 4n11eu")
ColourNote("lime","black","Dune           = run 8s11e")
ColourNote("lime","black","Galaxy         = run 7n14ed")
ColourNote("lime","black","Mega-City One  = run 3n11e")
ColourNote("lime","black","Star Wars      = run 7w4s")
ColourNote("lime","black","ST:TNG         = run 14s9e")
ColourNote("lime","black","Ultima         = run 5e6s;enter moongate")</send>
  </trigger>
  <trigger
   enabled="y"
   name="Vidblain_Enter_Hole"
   match="^Into the dark \(G\)$"
   regexp="y"
   send_to="10"
   sequence="100"
  ><send>vidbigmap</send>
  </trigger>
  <trigger
   name="Vidblain_Bigmap_Start"
   keep_evaluating="y"
   match="^\+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\+$"
   regexp="y"
   script="Vidblain_Bigmap_Start"
   sequence="100"
  >
  </trigger>
  <trigger
   name="Vidblain_Bigmap"
   keep_evaluating="y"
   match="^(\+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\+)|(\|(.*?)\|)$"
   regexp="y"
   script="VidblainBigMap"
   sequence="100"
  >
  </trigger>
</triggers>

<aliases>
<alias
   match="^vidbigmap$"
   enabled="y"
   regexp="y"
   script="Vidblain_Bigmap_Enable"
   send_to="12"
   ignore_case="y"
   sequence="100"
  >
  </alias>
</aliases>


--===========================================
-- Put OUTSIDE ALL Functions, within script section
line_count = nil
x = 0
y = 0
--===========================================

function Vidblain_Bigmap_Enable(sName,sLine,wildcards)
Send("bigmap")
EnableTrigger("Vidblain_Bigmap_Start",1)
end -- Vidblain_Bigmap_Enable

function Vidblain_Bigmap_Start(sName,sLine,wildcards)
EnableTrigger("Vidblain_Bigmap_Start",0)
EnableTrigger("Vidblain_Bigmap",1)
end -- Vidblain_Bigmap_Start

function VidblainBigMap(sName,sLine,wildcards,STYLES)
if sLine ~= "+------------------------------+" then
line = line_count
if line == nil then line = 0 end
col = 0
local linestyles = table.getn(STYLES)
for style = 1, linestyles do
  if RGBColourToName(STYLES[style]["textcolour"]) == "red" and string.sub(STYLES[style]["text"],1,1) == "*" then
  SetVariable("Vidblain_Line", line)
  for stylenum = 1, style - 1 do
    col = col + tonumber(STYLES[stylenum]["length"])
  end -- for
  col = col - 1
  x = col
  y = line
  end -- if
end -- for
line = tonumber(line) + 1
line_count = line
else
EnableTrigger("Vidblain_Bigmap",0)
Note("X: " .. x .. " Y: " .. y)
line_count = nil

if (y >=0 and y < 4) or (y > 4 and y < 8) or (y > 8 and y < 13) or (y > 13 and y < 23) or (y > 23 and y < 26) or (y > 27 and 

y < 30) then
	if y > 15 then
	  if x > 15 then
	    Send("run " .. 30 - x .. "e" .. 30 - y .. "s")
	  else
	    Send("run " .. x .. "w" .. 30 - y .. "s")
	  end -- if
	else
	  if x > 15 then
	    Send("run " .. 30 - x .. "e" .. y .. "n")
	  else
	    Send("run " .. x .. "w" .. y .. "n")
	  end -- if
	end -- if
    --Send("run " .. x .. "w" .. y .. "n")
else
	if y > 15 then
	  if x > 15 then
	    Send("run " .. 30 - y .. "s" .. 30 - x .. "e")
	  else
	    Send("run " .. 30 - y .. "s" .. x .. "w")
	  end -- if
	else
	  if x > 15 then
	    Send("run " .. y .. "n" .. 30 - x .. "e")
	  else
	    Send("run " .. y .. "n" .. x .. "w")
	  end -- if
	end -- if
  --Send("run " .. y .. "n" .. x .. "w")
end -- if
end -- if
end -- VidblainBigmap


This will, upon speed walking to vidblain, find your X and Y coordinate, and find and run the shortest route to 0,0 (top left room), then present the list of SW's from that room...

I do hope that this can help someone in some way.

Also there is an alias vidbigmap, so that if you want to use THAT instead of having it be automatic, then do not include the "Vidblain_Enter_Hole" trigger, or just make the enabled="n"

Laterzzz,
Onoitsu2
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.


27,632 views.

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

Go to topic:           Search the forum


[Go to top] top

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