Difference between revisions of "GrowlNotify Mac"

From Mudlet
Jump to navigation Jump to search
(Created page with "This script is made by ThePhoenix to work with the Mac app, Growl. It requires an additional bit that allows growl from terminal, called growlNotify. <lua> ----...")
 
m (Correcting bug remark)
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This script is made by [[user:phoenix|ThePhoenix]] to work with the Mac app, Growl. It requires an additional bit that allows growl from terminal, called growlNotify.
+
[[Category:Mudlet Package Listing]]
 +
{| class="wikitable" style="width: 70%;"
 +
|-
 +
| style="width: 10%" | Game || non-mud specific
 +
|-
 +
| By || <!-- handle|alias|name --> [[User:Phoenix|Phoenix]]
 +
|-
 +
| Download || none, see usage
 +
|-
 +
| Dependencies || <!-- any package dependencies|mudlet version requirements --> Mudlet 4.17, MacOS, growlNotify
 +
|}
  
<lua>
+
= Description = 
 +
<!-- A description about what your script accomplishes. -->
 +
 
 +
Create a [https://en.wikipedia.org/wiki/Growl_(software) growl] notification from Mudlet.
 +
 
 +
= Usage =
 +
<!-- include function parameters and some usage details (either screenshots or <code>preformatted script output</code> so players can understand how to use your script -->
 +
 
 +
<syntaxhighlight lang="lua">
 
-------------------------------------------------
 
-------------------------------------------------
 
--    This script works with Growl for Mac    --
 
--    This script works with Growl for Mac    --
Line 30: Line 48:
  
 
         sticky = sticky and "-s" or ""
 
         sticky = sticky and "-s" or ""
         message = string.gsub(message,[["]], "'") or ""
+
         message = string.gsub(message, [["]], "'") or ""
 
         priority = priority or false
 
         priority = priority or false
 
         title = title or "Mudlet"
 
         title = title or "Mudlet"
 
   if not priority and not hasFocus() then
 
   if not priority and not hasFocus() then
--       playSoundFile(soundNotify) --playSoundFile is buggy on a mac, and will crash you eventually.
+
        --playSoundFile(soundNotify)
-- use a beep along with the notification for the appropriate program inside Growl itself.
+
--use a beep along with the notification for the appropriate program inside Growl itself.
 
         os.execute( path .. " ".. sticky .. " " .. icon .. [[ -m " ]] ..
 
         os.execute( path .. " ".. sticky .. " " .. icon .. [[ -m " ]] ..
 
         message .. [[ " " ]]..title..[[ "]])
 
         message .. [[ " " ]]..title..[[ "]])
 
   end
 
   end
 
   if priority then
 
   if priority then
--       playSoundFile(soundAlert) --playSoundFile is buggy on a mac, and will crash you eventually.
+
--     --playSoundFile(soundAlert)
-- use a beep along with the notification for the appropriate program inside Growl itself.
+
--use a beep along with the notification for the appropriate program inside Growl itself.
 
         os.execute( path .. " ".. sticky .. " " .. icon .. [[ -p 2 -m " ]] ..
 
         os.execute( path .. " ".. sticky .. " " .. icon .. [[ -p 2 -m " ]] ..
 
         message .. [[ " " ]]..title..[[ "]])
 
         message .. [[ " " ]]..title..[[ "]])
 
   end
 
   end
 
end
 
end
</lua>
+
</syntaxhighlight>
 +
 
 +
= Examples =
  
=Example Script from Trigger=
 
 
Exact match trigger<br>
 
Exact match trigger<br>
<code>A soulmaster entity lets loose a horrible scream as a dark stream of primal chaos flows from it and into your very being.</code>
+
::<code>A soulmaster entity lets loose a horrible scream as a dark stream of primal chaos flows from it and into your very being.</code>
<lua>
+
::<code>growlNotify("ANTITHEFT!", "A soulmaster has taken possesion of you!", true,true)</code>
growlNotify("ANTITHEFT!", "A soulmaster has taken possesion of you!", true,true)
+
 
</lua>
+
 
 
It will pop up whether or not your mudlet window has focus - first true makes it priority, and therefor something that will always show.<br>
 
It will pop up whether or not your mudlet window has focus - first true makes it priority, and therefor something that will always show.<br>
 
This will pop up a sticky alert - second true makes it sticky.<br>
 
This will pop up a sticky alert - second true makes it sticky.<br>

Latest revision as of 14:42, 15 September 2024

Game non-mud specific
By Phoenix
Download none, see usage
Dependencies Mudlet 4.17, MacOS, growlNotify

Description

Create a growl notification from Mudlet.

Usage

-------------------------------------------------
--     This script works with Growl for Mac    --
--   Must have growlnotify installed as well   --
-------------------------------------------------



function growlNotify(title, message, priority, sticky)
--sounds
--Change these sounds to what you want, and have. --playSoundFile is buggy on a mac, and will crash you eventually.
-- use a beep along with the notification for the appropriate program inside Growl itself.
 local  soundAlert = "/System/Library/Sounds/Indigo.aiff"
 local  soundNotify = "/System/Library/Sounds/Temple.aiff"

local path, icon -- Do not touch this line

--Path: This is the default path, change it if you have it somewhere else.
        path = "/usr/local/bin/growlnotify"
--Icon: This is an advanced change, try it if you want.
        icon = "-a Mudlet.app"


        assert(type(priority)=="boolean" or type(priority)=="nil",
         "Wrong type for the priority!")
        assert(type(sticky)=="boolean" or type(sticky)=="nil",
         "Wrong type for the priority!")

        sticky = sticky and "-s" or ""
        message = string.gsub(message, [["]], "'") or ""
        priority = priority or false
        title = title or "Mudlet"
   if not priority and not hasFocus() then
        --playSoundFile(soundNotify)
--use a beep along with the notification for the appropriate program inside Growl itself.
        os.execute( path .. " ".. sticky .. " " .. icon .. [[ -m " ]] ..
         message .. [[ " " ]]..title..[[ "]])
   end
   if priority then
--      --playSoundFile(soundAlert)
--use a beep along with the notification for the appropriate program inside Growl itself.
        os.execute( path .. " ".. sticky .. " " .. icon .. [[ -p 2 -m " ]] ..
         message .. [[ " " ]]..title..[[ "]])
   end
end

Examples

Exact match trigger

A soulmaster entity lets loose a horrible scream as a dark stream of primal chaos flows from it and into your very being.
growlNotify("ANTITHEFT!", "A soulmaster has taken possesion of you!", true,true)


It will pop up whether or not your mudlet window has focus - first true makes it priority, and therefor something that will always show.
This will pop up a sticky alert - second true makes it sticky.