ULX

Author Topic: ULib v1.01 Modules Loader  (Read 6317 times)

0 Members and 1 Guest are viewing this topic.

Offline fackelkind

  • Newbie
  • *
  • Posts: 24
  • Karma: 4
ULib v1.01 Modules Loader
« on: August 20, 2006, 09:44:59 PM »
Okay, this is nothing big, but perhaps usefull. I added the old module function to ULib, allows you to execute scripte after ULib has loaded.

Code: [Select]
if not ULib then
        _OpenScript ("lua/ULib/init.lua")
end

if ULib then
        if _file.Exists ("lua/ULib/modules") then
                local files = _file.Find ("lua/ULib/modules/ulx_*.lua")

                _Msg ("=== ULX Modul Loader =================================================\n")
                _Msg ("=                                                                    =\n")
                for v in files do
                        _Msg ("= " .. files[v] .. string.rep (" ", 67 - string.len (files[v])) .. "=\n");
                        _OpenScript ("lua/ULib/modules/" .. files[v])
                end
                _Msg ("=                                                                    =\n")
                _Msg ("======================================================================\n")
        end
end

Put this into your lua/init folder (I called it ulx_modules.lua)



Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: ULib v1.01 Modules Loader
« Reply #1 on: August 27, 2006, 05:15:42 PM »
Nice job fackelkind! I was just wondering to myself last week that there was no similiar function for ULib
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline spbogie

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 456
  • Karma: 41
Re: ULib v1.01 Modules Loader
« Reply #2 on: August 28, 2006, 01:51:18 PM »
There is a reason that there is no modules loader function in ULib. It's because you simply use _OpenScript("ULib/init.lua") at the begining of your script instead. ULib automaticly checks to make sure it doesn't get loaded a second time.
I have not failed. I've just found 10,000 ways that won't work. - Thomas A. Edison
I reject your reality and substitute my own. - Adam Savage

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: ULib v1.01 Modules Loader
« Reply #3 on: August 29, 2006, 08:23:39 PM »
Spbogie,
 True, but I hate loading my init folder full of scripts, ULX related or not.
This way, I can put the scripts related to ULX into a subfolder of Ulib (or wherever else I might like and edit the original loader script)
But, I like to keep things as neat as possible, easier to know where stuff is
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming