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 ➜ Quest Grab Mini Window

Quest Grab Mini Window

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


Posted by Lilac   (24 posts)  Bio
Date Fri 03 Dec 2021 08:18 PM (UTC)

Amended on Fri 03 Dec 2021 08:36 PM (UTC) by Lilac

Message
I've been researching this for days, and driving myself up a wall, but I'm not a coder and I can't hit upon the magic to make it work as I'd like.

What I want: a mini window to open on my client, with a triggered grab of my quest information.

That's it. Ideally it would perform very similar to the Aardwolf Quest Noter plugin (https://www.gammon.com.au/forum/?id=8814) by Nick, but only in terms of the cute mini window opening on my screen. I want none of the complicated timer stuff, just the information displayed.


The block of text I need to capture is below, with * as the notator for information that changes:

You ask * for a quest.
* says 'Thank you, brave *!'
You have asked to find a lost item.
* says 'Vile thieves have stolen * from the royal treasury!'
* says 'My court wizardess, with her magic mirror, has pinpointed its location.'
* says 'Look in the general vicinity of * for *!'

It doesn't even need the whole block. Just what the thieves have stolen and looking in the vicinity of * for *.

I don't know if this is possible, I just know I have no idea how to make it so if it is.
Top

Posted by Fiendish   USA  (2,533 posts)  Bio   Global Moderator
Date Reply #1 on Fri 03 Dec 2021 08:49 PM (UTC)

Amended on Fri 03 Dec 2021 09:05 PM (UTC) by Fiendish

Message
Is this for Aardwolf? If it is then my answer will be different than if it isn't because I have premade modules for making miniwindows but they're tightly integrated with the Aardwolf MUSHclient package.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Lilac   (24 posts)  Bio
Date Reply #2 on Fri 03 Dec 2021 09:03 PM (UTC)
Message
No, it's not for Aardwolf.
Top

Posted by Fiendish   USA  (2,533 posts)  Bio   Global Moderator
Date Reply #3 on Fri 03 Dec 2021 09:06 PM (UTC)
Message
Alternatively then, can you just use the one from that link and ignore the timer part?

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Lilac   (24 posts)  Bio
Date Reply #4 on Fri 03 Dec 2021 09:16 PM (UTC)

Amended on Fri 03 Dec 2021 09:27 PM (UTC) by Lilac

Message
I've gone through it and all I can figure out is that it confuses the F out of me. I'm not sure exactly what to change to alter it to the key phrases I need.

Would it even still be a plugin? Can I do it with triggers only?

The trigger portion I can remove everything and add the ones I want, which is -- near as I can tell - the following:


<trigger
match="* says 'Vile thieves have stolen * from the royal treasury!'"
name="questor_line"
script="questor_line"
sequence="100"
expand_variables="y"
>
</trigger>

<trigger
enabled="y"
match="You ask * for a quest."
script="start_questor_stuff"
sequence="100"
>
</trigger>

<trigger
match="* says 'Look in the general vicinity of * for *!"
name="questor_end"
script="questor_end"
sequence="10"
expand_variables="y"
>
</trigger>





From there I'm not sure what to edit/remove/add/change in the script portion.

I'm a hot mess when it comes to code.


EDIT TO ADD: Probably not that either, because then how would it know to trigger only on MY quests and not other people's.

Yikes, this is rough.
Top

Posted by Nick Gammon   Australia  (23,121 posts)  Bio   Forum Administrator
Date Reply #5 on Fri 03 Dec 2021 09:52 PM (UTC)
Message
I did a tutorial here: http://www.gammon.com.au/forum/?id=9965

That covers, in some depth, capturing your inventory and showing it in a miniwindow.

Now, capturing quest information is the same concept, except that the words surrounding it will be different. So in your case "You ask * for a quest." could be what starts the capturing process off, and something else (like a prompt) would finish it.

- Nick Gammon

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

Posted by Lilac   (24 posts)  Bio
Date Reply #6 on Fri 03 Dec 2021 10:17 PM (UTC)

Amended on Fri 03 Dec 2021 10:18 PM (UTC) by Lilac

Message
Nick Gammon said:

I did a tutorial here: http://www.gammon.com.au/forum/?id=9965

That covers, in some depth, capturing your inventory and showing it in a miniwindow.

Now, capturing quest information is the same concept, except that the words surrounding it will be different. So in your case "You ask * for a quest." could be what starts the capturing process off, and something else (like a prompt) would finish it.



I can't even see how you would change what that tutorial is building (an alias with the wait function and all that) into something that captures text, as a trigger.


Unfortunately, it seems to be you're driving a Masterati while I'm still getting the hang of how any car drives. LOL

I know how to make a trigger. I know I want to use the following:

1.) * says 'Vile thieves have stolen * from the royal treasury!'

2.) * says 'Look in the general vicinity of * for *!'


I know (think I know) that * is a variable for information.


That's about where I get lost. It seems like this is way too far over my head to attempt.
Top

Posted by Lilac   (24 posts)  Bio
Date Reply #7 on Sat 04 Dec 2021 12:42 AM (UTC)

Amended on Sat 04 Dec 2021 12:46 AM (UTC) by Lilac

Message
Okay. Here are the changes I made. None of it is working. I've been fiddling and playing with this for six hours, now.



<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Tuesday, July 15, 2008, 9:13 AM -->
<!-- MuClient version 4.33 -->

<!-- Plugin "Aardwolf_Quest_Noter" generated by Plugin Wizard -->

<muclient>
<plugin
name="Aardwolf_Quest_Noter_v2"
author="Nick Gammon"
id="76c899eda20ad99787c6b438"
language="Lua"
purpose="Remembers standard quest instructions"
date_written="2008-07-24"
requires="4.34"
version="2.0"
save_state="y"
>
<description trim="y">
<![CDATA[
Remembers what a quest-giver told you to do.
]]>
</description>

</plugin>


<!-- Triggers -->

<triggers>

<trigger
match="* says 'Thank you, brave *!'"
name="questor_line"
script="questor_line"
sequence="100"
expand_variables="y"
>
</trigger>

<trigger
enabled="y"
match="You have asked to find a lost item. "
script="start_questor_stuff"
sequence="100"
>
</trigger>

<trigger
match="* says 'Congratulations on completing the quest!'"
name="questor_end"
script="questor_end"
sequence="10"
expand_variables="y"
>
</trigger>

<trigger
enabled="y"
match="QUEST: You have almost completed your QUEST!"
sequence="100"
script="quest_done"
>
</trigger>

<trigger
enabled="y"
match="* 'Congratulations on completing the quest!'"
sequence="100"
script="quest_handed_in"
>
</trigger>

<trigger
enabled="y"
match="There are * minutes remaining until you can go on another quest."
sequence="100"
script="quest_time_to_go"
>
</trigger>

<trigger
enabled="y"
match="You may now quest again."
sequence="100"
script="quest_available"
>
</trigger>

<trigger
enabled="y"
match="You aren't currently on a quest."
sequence="100"
script="quest_available"
>
</trigger>

</triggers>

<!-- Timers -->


<timers>
<timer
script="show_quest_text"
enabled="y"
second="30.00"
>
</timer>
</timers>
Top

Posted by Lilac   (24 posts)  Bio
Date Reply #8 on Sat 04 Dec 2021 12:42 AM (UTC)
Message
<!-- Script -->


<script>
<![CDATA[

background_colour = 0xE7FFFF
text_colour = 0x000000
heading_colour = 0x800080
time_colour = 0x82004B


quest_info = {}

require "serialize"
require "commas"
require "var"

function quest_handed_in (name, line, wildcards)
Send "pq time"
next_quest_time = os.time () + (30 * 60) -- 30 mins to go
quest_info = {}
show_quest_text ()
end -- quest_handed_in

function quest_time_to_go (name, line, wildcards)
local mins = tonumber (wildcards [1])
if mins then
next_quest_time = os.time () + mins * 60
else
next_quest_time = nil
end -- if
quest_info = {}
show_quest_text ()
end -- quest_time_to_go

function quest_available (name, line, wildcards)
next_quest_time = os.time ()
quest_info = {}
show_quest_text ()
end -- quest_available

function quest_done (name, line, wildcards)
quest_info = { "Quest complete - go hand it in." }
max_width = WindowTextWidth (win, font_id, quest_info [1])
show_quest_text ()
end -- quest_done

function start_questor_stuff (name, line, wildcards)
check (EnableTrigger ("questor_line", true))
check (EnableTrigger ("questor_end", true))
quest_info = {}
max_width = 0
var.questor = wildcards [1]
end -- start_questor_stuff

function questor_line (name, line, wildcards)
local text = wildcards [1]

if string.match (text, "* says 'Thank you, brave *!' ") then
return
end -- if

if string.match (text, "May the gods go with you! ") then
return
end -- if

table.insert (quest_info, text )
max_width = math.max (max_width, WindowTextWidth (win, font_id, text))

end -- questor_line

function Display_Line (line, text, id, colour)

local left = 5
local top = (line - 1) * font_height

WindowText (win, id, text, left, top, 0, 0, colour)

end -- Display_Line

function show_when_quest_available ()

local time_to_go = next_quest_time - os.time ()

if time_to_go <= 0 then
text = "You are not currently on a quest!"
else
text = string.format ("Time until next quest: %s", convert_time (time_to_go))
end -- if

max_width = WindowTextWidth (win, font_id, text)

-- recreate the window the correct size
WindowCreate (win,
0, 0, -- left, top (auto-positions)
max_width + 10, -- width
font_height + 5, -- height
7, -- auto-position: top middle
0, -- flags
0xE7FFFF)

Display_Line (1, text, font_id, time_colour)

WindowShow (win, true)

end -- show_when_quest_available

function show_quest_text ()

if #quest_info == 0 and
next_quest_time then
show_when_quest_available ()
return
end -- one available now/soon

-- do nothing if no quest
if #quest_info == 0 or when_required == nil then
return
end -- if

-- recreate the window the correct size
WindowCreate (win,
0, 0, -- left, top (auto-positions)
max_width + 10, -- width
(#quest_info + 2) * font_height + 5, -- height
7, -- auto-position: top middle
0, -- flags
0xE7FFFF)

-- heading
local text = "Current quest."
Display_Line (1, text, font_id, heading_colour)

-- list of mobs
for i, v in ipairs (quest_info) do
Display_Line (i + 1, v, font_id, text_colour)
end -- for

-- how long to go
local time_to_go = when_required - os.time ()

if time_to_go < 0 then
return
end -- if

text = string.format ("Time to go: %s", convert_time (time_to_go))
Display_Line (#quest_info + 2, text, font_id, time_colour)

WindowShow (win, true)

end -- show_quest_text

function questor_end (name, line, wildcards)

local text = wildcards [1]

-- work out when quest ends

when_required = os.time ()

local days = string.match (text, "(%d+) days?")
if days then
when_required = when_required + tonumber (days) * 60 * 60 * 24
end -- some days left

local hours = string.match (text, "(%d+) hours?")
if hours then
when_required = when_required + tonumber (hours) * 60 * 60
end -- some days left

local minutes = string.match (text, "(%d+) minutes?")
if minutes then
when_required = when_required + tonumber (minutes) * 60
end -- some days left

check (EnableTrigger ("questor_line", false))
check (EnableTrigger ("questor_end", false))
show_quest_text ()
end -- questor_end

function OnPluginSaveState ()
SetVariable ("enabled", tostring (GetPluginInfo (GetPluginID (), 17)))
end -- function OnPluginSaveState

function OnPluginInstall ()

win = GetPluginID ()
font_id = "fn"

font_name = "Comic Sans MS" -- the actual font

-- make win so I can grab the font info
WindowCreate (win,
0, 0, 1, 1, -- 1 x 1 pixel
1, -- position - irrelevant
0, -- flags
0) -- background colour

check (WindowFont (win, font_id, font_name, 13)) -- normal
font_height = WindowFontInfo (win, font_id, 1) -- height

if GetVariable ("enabled") == "false" then
ColourNote ("yellow", "", "Warning: Plugin " .. GetPluginName ().. " is currently disabled.")
check (EnablePlugin(GetPluginID (), false))
return
end -- they didn't enable us last time

end -- OnPluginInstall

function OnPluginDisable ()
WindowShow (win, false)
end -- OnPluginDisable


]]>
</script>

</muclient>
Top

Posted by Nick Gammon   Australia  (23,121 posts)  Bio   Forum Administrator
Date Reply #9 on Sat 04 Dec 2021 01:48 AM (UTC)

Amended on Sat 04 Dec 2021 04:21 AM (UTC) by Nick Gammon

Message
All that looks rather complex. My tutorial, adapted slightly, is much easier to follow. Make a single trigger, as below (you don't need a plugin, however you could put the trigger in a plugin if you wanted):


<triggers>
  <trigger
   enabled="y"
   match="You have asked to find a lost item."
   send_to="12"
   sequence="100"
  >
  <send>

require "wait"

wait.make (function ()  -- coroutine starts here


local win = GetPluginID () .. "_quest"
local font = "f"

if not WindowInfo (win, 1) then
  WindowCreate (win, 0, 0, 0, 0, miniwin.pos_top_right, 0, 0)
  WindowFont (win, font, "Lucida Console", 9)  
end -- if

local inv = {}
local max_width = WindowTextWidth (win, font, "Current quest")

-- loop until end of quest info

while true do
  local line, wildcards, styles = wait.match ("*")


  -- save quest line
  table.insert (inv, styles)
  -- work out max width
  max_width = math.max (max_width, WindowTextWidth (win, font, line))

  -- see if end of quest instructions

  if string.match (line, "says 'Look in the general vicinity of") then
    break
  end -- if

end -- while loop

local font_height = WindowFontInfo (win, font, 1)

local window_width = max_width + 10
local window_height = font_height * (#inv + 2) + 10

-- make window correct size

WindowCreate (win, 0, 0, window_width, window_height, miniwin.pos_top_right, 0, ColourNameToRGB "#373737")
WindowRectOp (win, miniwin.rect_draw_edge, 0, 0, 0, 0, 
              miniwin.rect_edge_raised, miniwin.rect_edge_at_all + miniwin.rect_option_softer_buttons)

-- heading line

WindowText (win, font, "Current quest", 5, 5, 0, 0, ColourNameToRGB  "yellow")

-- draw each quest line

local y = font_height * 2 + 5

for i, styles in ipairs (inv) do

  local x = 5
  for _, style in ipairs (styles) do
    x = x + WindowText (win, font, style.text, x, y, 0, 0, style.textcolour)
  end -- for
  y = y + font_height

end -- for each quest item

WindowShow (win, true)


end)   -- end of coroutine

</send>
  </trigger>
</triggers>



Template:pasting For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.


I tested with the following text:


You have asked to find a lost item.
Nick says 'Vile thieves have stolen a widget from the royal treasury!'
Nick says 'My court wizardess, with her magic mirror, has pinpointed its location.'
Nick says 'Look in the general vicinity of the pond for a widget !'


The quest appeared in a miniwindow in the top RH corner, as expected.

To get rid of it (eg. when you have done the quest) you can add an alias:


<aliases>
  <alias
   match="quest done"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

local win = GetPluginID () .. "_quest"

WindowShow (win, false)

</send>
  </alias>
</aliases>

- Nick Gammon

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

Posted by Lilac   (24 posts)  Bio
Date Reply #10 on Sat 04 Dec 2021 01:55 AM (UTC)

Amended on Sat 04 Dec 2021 01:59 AM (UTC) by Lilac

Message
YAY! This is fantastic! Thank you so much for your assistance!

I spent a lot of time futzing around and trying to make different things work. Lots of Googling and lots of searching these forums to figure out what I was missing and the information I needed.

You are a peach and I appreciate you!
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.


19,310 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.