Skip to content

Commit

Permalink
Added plugin Global_Option_Updater to the installer
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgammon committed Mar 20, 2018
1 parent 65a4ff8 commit a8e8065
Show file tree
Hide file tree
Showing 2 changed files with 147 additions and 0 deletions.
2 changes: 2 additions & 0 deletions install/mushclient.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ Section "Plugins"
File "..\plugins\Config_Option_Changer.xml"
File "..\plugins\Current_Output_Window.xml"
File "..\plugins\Gag.xml"
File "..\plugins\Global_Option_Updater.xml"
File "..\plugins\Health_Bar.xml"
File "..\plugins\Hyperlink_URL.xml"
File "..\plugins\InfoBox_Demo.xml"
Expand Down Expand Up @@ -710,6 +711,7 @@ Section Uninstall
Delete "$INSTDIR\worlds\plugins\Config_Option_Changer.xml"
Delete "$INSTDIR\worlds\plugins\Current_Output_Window.xml"
Delete "$INSTDIR\worlds\plugins\Gag.xml"
Delete "$INSTDIR\worlds\plugins\Global_Option_Updater.xml"
Delete "$INSTDIR\worlds\plugins\Health_Bar.xml"
Delete "$INSTDIR\worlds\plugins\Hyperlink_URL.xml"
Delete "$INSTDIR\worlds\plugins\InfoBox_Demo.xml"
Expand Down
145 changes: 145 additions & 0 deletions plugins/Global_Option_Updater.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>

<muclient>
<plugin
name="Global_Option_Updater"
author="Nick Gammon"
id="1204316574ebc1d41d7011b3"
language="Lua"
purpose="Shows / changes global options"
date_written="2010-09-17 08:28:51"
requires="4.50"
version="1.0"
>
<description trim="y">
<![CDATA[
Usage:
list_global_options --> list all valid option names
show_global_option x --> displays value of option
change_global_option x y --> changes value of option x to y
eg.
show_global_option FixedPitchFont
change_global_option FixedPitchFont Dina
After changing an option you should exit the client and re-open it, otherwise
if you use the GUI interface (global preferences) it may put the option back again.
]]>
</description>

</plugin>


<!-- Aliases -->

<aliases>
<alias
match="change_global_option * *"
enabled="y"
send_to="12"
sequence="100"
>
<send>

-- open preferences database
local db = assert (sqlite3.open (GetInfo (82)))
local value = nil

-- see if this key already exists (if not, probably spelling error)
for a in db:nrows "SELECT * FROM prefs WHERE name = '%1'" do
value = a.value
end -- for

-- if found, modify it
if value then

if db:execute ("UPDATE prefs SET value = '%2' WHERE name = '%1'") ~= sqlite3.OK then
ColourNote ("red", "", "Unable to modify preferences: " .. db:errmsg ())
else
if value ~= "%2" then
ColourNote ("cyan", "", "Item '%1' changed from '" .. value .. "' to '%2'")
else
ColourNote ("cyan", "", "No change required, value of '%1' is already '%2'")
end -- if
end -- if updated OK

else
ColourNote ("red", "", "Item '%1' is not in preferences database")
end -- does not exist

db:close()

</send>
</alias>

<alias
match="show_global_option *"
enabled="y"
send_to="12"
sequence="100"
>
<send>

-- open preferences database
local db = assert (sqlite3.open (GetInfo (82)))
local value = nil

-- find the item
for a in db:nrows "SELECT * FROM prefs WHERE name = '%1'" do
value = a.value
end -- for

-- if found, display it
if value then
ColourNote ("cyan", "", "Item '%1' has value '" .. value .. "'")
else
ColourNote ("red", "", "Item '%1' is not in preferences database")
end -- does not exist

db:close()

</send>
</alias>

<alias
match="list_global_options"
enabled="y"
send_to="12"
sequence="100"
>
<send>

-- open preferences database
local db = assert (sqlite3.open (GetInfo (82)))

ColourNote ("cyan", "", "Global Options")
ColourNote ("cyan", "", string.rep ("-", 40))

-- show all
for a in db:nrows "SELECT * FROM prefs ORDER BY name" do
ColourNote ("cyan", "", a.name)
end -- for

ColourNote ("cyan", "", string.rep ("-", 40))

db:close()

</send>
</alias>

</aliases>

<script>

-- show help
ColourNote ("cyan", "", GetPluginInfo (GetPluginID (), 3))

</script>

</muclient>

0 comments on commit a8e8065

Please sign in to comment.