I give up!

Post Reply
keevitaja
Posts: 21
Joined: Mon Aug 31, 2015 12:29 am

I give up!

Post 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?

User avatar
Belgarath
Posts: 232
Joined: Fri Jul 26, 2013 7:19 am
Discord: macjabeth#7149

Re: I give up!

Post 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?

keevitaja
Posts: 21
Joined: Mon Aug 31, 2015 12:29 am

Re: I give up!

Post 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>

User avatar
Belgarath
Posts: 232
Joined: Fri Jul 26, 2013 7:19 am
Discord: macjabeth#7149

Re: I give up!

Post 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.

keevitaja
Posts: 21
Joined: Mon Aug 31, 2015 12:29 am

Re: I give up!

Post 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.

User avatar
Belgarath
Posts: 232
Joined: Fri Jul 26, 2013 7:19 am
Discord: macjabeth#7149

Re: I give up!

Post 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

User avatar
Zaphob
Posts: 180
Joined: Wed May 09, 2012 8:07 am
Location: mg.mud.de

Re: I give up!

Post 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.

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: I give up!

Post 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.

keevitaja
Posts: 21
Joined: Mon Aug 31, 2015 12:29 am

Re: I give up!

Post by keevitaja »

OK, tnx guys. I think i am finally getting somewhere. But the link above does not explain much :P

Post Reply