Page 1 of 1

I give up!

Posted: Thu Sep 03, 2015 6:31 am
by keevitaja
My idea to start using native linux mud client failed!

I cannot find any documentation on how to create packages or modules. Also no help from IRC channel nor this forum.

While there is lot of documentation on lua functions, there are none on the anatomy of packages. And it is funny, because someone has spent lot of time on wiki, but forgot to add some package developing tutorials for beginners.

http://wiki.mudlet.org/w/Mudlet_Packages

This is the package development documentation?

Re: I give up!

Posted: Thu Sep 03, 2015 7:33 pm
by Belgarath
Hey Keevitaja,

As I said on the IRC channel when you asked, that wiki link is the best method for creating a shareable package in Mudlet. You can also try the Package Exporter (experimental). Another note is that packaged ZIP files cannot be used as modules for syncing across profiles. They will have to be in an XML file.

Is there something specific you're having trouble with that isn't explained in the wiki tutorial?

Re: I give up!

Posted: Fri Sep 04, 2015 7:06 am
by keevitaja
Yes, i have specific questions. How do i create a module? What is the file structure and variable scope?

For instance i could not find any information what is the minimal xml for a package...

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE MudletPackage>
<MudletPackage version="1.0">
    <ScriptPackage>
        <Script isActive="yes">
            <script>
                packagePath = getMudletHomeDir() .. "/../../aardwolf/"

                function loadFile(file)
                    return dofile(packagePath .. file)
                end

                loadFile("plugin.lua")
            </script>
        </Script>
    </ScriptPackage>
</MudletPackage>

Re: I give up!

Posted: Fri Sep 04, 2015 11:06 am
by Belgarath
If you want to create a module out of some Mudlet scripts, you should export them via the Mudlet editor, or use the Package Exporter. You can then load it in via the Module Manager and sync it. The Package Exporter and Module Manager are located under the Toolbox drop-down menu.

If you want to load in a separate Lua script you've written, I'd suggest putting it in a folder inside your getMudletHomeDir() directory, and use require(), not dofile(), since require controls whether a file has already been run to avoid duplicating the work.

Re: I give up!

Posted: Fri Sep 04, 2015 1:50 pm
by keevitaja
require is not working... not sure why

but how can i start a module from scratch? like what is the file structure and how does it work?

is module like collection of packages? what is the variable scope?

and these exporters/generators seem to be useless. well at least for packages as i have no desire to mess with xml.

Re: I give up!

Posted: Fri Sep 04, 2015 6:31 pm
by Belgarath
You can look here for a tutorial on Lua Modules and here for a tutorial on Scope.

require will only work if you set package.path to look in the right directory. Here is an example:
Code: [show] | [select all] lua
-- sysLoadEvent
function load_system (event)
  local _sep = string.char(getMudletHomeDir():byte()) == "/" and "/" or "\\"
  local oldpath = package.path
  local system_path = getMudletHomeDir() .. "/system/"

  package.path = system_path .. "?.lua;"
  local s, m = pcall(require, "init")
  package.path = oldpath

  if not s then
    display(m)
    return
  end

  print "System loaded successfully."
end

Re: I give up!

Posted: Wed Sep 09, 2015 9:29 am
by Zaphob
I asked about related issues in my thread here: import lua?

For the XML structure, just create a few scripts, timers, etc. via the Mudlet GUI. This seems to be the recommended way for most users. You can then export a package and look at the XML structure. I never bothered writing XML from scratch, instead modified only where needed. There are other packages which only have minimal XML and then import most lua logic from other files. Maybe take a look at those. I agree the documentation could be improved more, but it was a one-man-show for quite some time now. Feel free to support.

Re: I give up!

Posted: Wed Sep 09, 2015 9:47 am
by Vadi
http://wiki.mudlet.org/w/Mudlet_Package ... et_package describes how to create a package, try following it and ask if you have any specific questions.

Re: I give up!

Posted: Wed Sep 09, 2015 10:50 am
by keevitaja
OK, tnx guys. I think i am finally getting somewhere. But the link above does not explain much :P