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.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Plugins
➜ Aardwolf create-a-world plugin
|
Aardwolf create-a-world plugin
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Nick Gammon
Australia (23,166 posts) Bio
Forum Administrator |
| Date
| Sun 13 Jul 2008 01:58 AM (UTC) |
| Message
| Some of the plugins I wrote for Aardwolf rely on having another dummy world file to display their output. To simplify creating this world file, I made the plugin below. This creates a world file if needed using the "make_world" which ships in the getworld.lua module, which has been in recent releases of MUSHclient.
The point of this plugin is to centralize world-file creation, and also to only need one "trusted" plugin, that is allowed to do an io.open (to make a file).
To use it, download the code below and save as Create_World_File.xml in the Aardwolf subdirectory below your Plugins directory. If you haven't used any Aardwolf plugins before you may need to make the Aardwolf directory.
Alternatively, RH click the link below and choose "Save Link As" (or "Save Linked File As") to save the linked file.
http://www.gammon.com.au/mushclient/plugins/Aardwolf/Create_World_File.xml
In a standard MUSHclient installation these two files should to into this directory:
C:\Program Files\MUSHclient\worlds\plugins\Aardwolf\
Lua "sandbox" configuration
A default MUSHclient installation has a Lua "sandbox" that prevents plugins from doing things like creating files. For this plugin to work you need to "trust" it. To do this go to the File menu -> Global Preferences -> Lua and edit the Lua sandbox code. The first few lines should now read:
trust_all_worlds = true -- change to true to trust all the worlds
trust_all_plugins = false -- change to true to trust all the plugins
warn_if_not_trusted = false -- change to true to show warnings
Further down you will see these lines:
-- Plugin IDs of plugins we trust - add your plugins to the table
local trusted_plugins = {
[""] = "", -- trust main script (ie. if no plugin running)
["03ca99c4e98d2a3e6d655c7d"] = "Chat",
["982581e59ab42844527eec80"] = "Random_Socials",
["4a267cd69ba59b5ecefe42d8"] = "Installer_sumcheck",
["83beba4e37b3d0e7f63cedbc"] = "Reconnecter",
} -- end of trusted_plugins
Add one more line so it looks like this:
-- Plugin IDs of plugins we trust - add your plugins to the table
local trusted_plugins = {
[""] = "", -- trust main script (ie. if no plugin running)
["03ca99c4e98d2a3e6d655c7d"] = "Chat",
["982581e59ab42844527eec80"] = "Random_Socials",
["4a267cd69ba59b5ecefe42d8"] = "Installer_sumcheck",
["83beba4e37b3d0e7f63cedbc"] = "Reconnecter",
["35dfdbf3afc8cbf60c91277c"] = "xCreate_World_File",
} -- end of trusted_plugins
Now the xCreate_World_File plugin is trusted, and it will be able to create world files when needed by other plugins.
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
name="xCreate_World_File"
author="Nick Gammon"
id="35dfdbf3afc8cbf60c91277c"
language="Lua"
purpose="Creates a world file."
date_written="2008-07-01"
requires="4.30"
version="1.0"
>
<description trim="y">
<![CDATA[
Implements an interface for other plugins, or triggers etc. to create a world file.
Example of use:
-- Create world file Spells in folder Aardwolf
check (CallPlugin ("35dfdbf3afc8cbf60c91277c", "CreateWorldFile", "Aardwolf,Spells"))
]]>
</description>
</plugin>
<!-- Script -->
<script>
<![CDATA[
require "getworld"
require "commas"
-- args are: folder,file
function CreateWorldFile (args)
local folder, filename = string.match (args,
"^([%w ]+),%s*([%w ]+)$")
if not folder then
error ("Arguments to CreateWorldFile are: folder,file. You supplied: " .. args)
end -- if
folder = trim (folder)
if folder == "" then
folder = nil
end -- no folder
filename = trim (filename)
local pathname = GetInfo (57)
if folder then
pathname = pathname .. folder .. "\\"
end -- if folder wanted
t, err = utils.readdir (pathname .. "*")
if not t then
ColourNote ("red", "", "Directory " .. pathname .. " does not exist.")
ColourNote ("silver", "", "Please create it and reinstall plugins.")
end -- if
-- ensure world file exists
make_world (filename, [[
<!-- plugins -->
<include name="Send_Input_To_Main_World.xml" plugin="y" />
<include name="Copy_Output.xml" plugin="y" />
<include name="Restore_On_Activate.xml" plugin="y" />
]], folder)
end -- function CreateWorldFile
]]>
</script>
</muclient>
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | 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.
7,041 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top