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

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Miniwindows
. . -> [Subject]  Prompt to miniwindow?
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Prompt to miniwindow?

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


Posted by Zirix   (6 posts)  [Biography] bio
Date Sun 10 Apr 2016 03:32 PM (UTC)

Amended on Wed 27 Apr 2016 02:31 AM (UTC) by Zirix

Message
How would I go about creating a trigger that sends my prompt into a miniwindow each time it pops up? I checked the inventory to miniwindow tutorial but I don't have a clue about how I would edit it to work as a trigger. I play Icesus and I've modified my prompt to look like this. I would like to send this to a miniwindow and omit it from the output.

Prompt start
HP       = 727 / 727 100%
SP       = 441 / 441 100%
EP       = 664 / 664 100%
Fury     = 0
EXP      = 591699
  to lvl = -128730
  to adv = -556713
Money    = 0
Time     = night
Hour     = Deepnight (1st)
Phase of magic
Prompt end


Update!
Got it to work by adding line "Stats" to the prompt and recalling that with the inventory miniwindow script.

require "wait"

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


local win = GetPluginID () .. ":inventory"
local font = "f"

if not WindowInfo (win, 1) then
  WindowCreate (win, 0, 0, 0, 0, 6, 0, 0)
  WindowFont (win, font, "Consolas", 14)  
end -- if

-- request inventory


-- wait for inventory to start

local x = wait.match ("Stats", 10, trigger_flag.OmitFromOutput)

if not x then
  ColourNote ("white", "blue", "No inventory received within 10 seconds")
  return
end -- if

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

-- loop until end of inventory

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

  -- see if end of inventory

  if string.match (line, "Prompt end") then
    break
  end -- if

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

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, 6, 0, ColourNameToRGB "black")
WindowRectOp (win, 5, 0, 0, 0, 0, 5, 15 + 0x1000)

-- heading line

WindowText (win, font, "Stats", 5, 5, 0, 0, ColourNameToRGB  "white")

-- draw each inventory 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 inventory item

WindowShow (win, true)


end)   -- end of coroutine


Update 2! Realized I didn't actually need the stats line in the prompt since I was already starting the matching with the trigger so I ended up with a slightly shorter code.
require "wait"

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


local win = GetPluginID () .. ":prompt"
local font = "f"

if not WindowInfo (win, 1) then
  WindowCreate (win, 0, 0, 0, 0, 4, 0, 0)
  WindowFont (win, font, "Consolas", 9)  
end -- if

-- request prompt

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

-- loop until end of prompt
while true do
  local line, wildcards, styles = wait.match ("*", 0, trigger_flag.OmitFromOutput)

  -- see if end of prompt

  if string.match (line, "Prompt end") then
    break
  end -- if

  -- save inventory line
  table.insert (inv, styles)

end -- while loop

local font_height = WindowFontInfo (win, font, 1)

local window_width = 290
local window_height = 305

-- make window correct size

WindowCreate (win, 850, 0, window_width, window_height, 0, 2, ColourNameToRGB "black")
WindowRectOp (win, 5, 0, 0, 0, 0, 5, 15 + 0x1000)

-- draw each inventory line

local y = 10

for i, styles in ipairs (inv) do

  local x = 10
  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 inventory item

WindowShow (win, true)


end)   -- end of coroutine
[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.


1,154 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 FutureQuest]