moo.mrc detection / loader

By knoeki on Dec 15, 2008

This little snippet was taken from zOWBscript, thought that maybe somebody might find it useful.

What does it do?
It detects if moo.mrc (sysinfo script) was found, and loads that if plugin loading is enabled.

Why/where would I want to use this?
If you're developing a script (such as zOWBscript) that also does sysinfo, you might want to give your users the choice between your sysinfo, and another sysinfo script (such as moo.mrc, in this case). also useful if you're an idiot like me who puts a half-working sysinfo script in his script ;_)

You can easily modify it to detect other (sysinfo) scripts with it. If you don't know how, you might want to dive into the mIRC manual and other various script-help resources. if you then still don't know, you probably shouldn't be scripting in the first place ;_)

Variables
(lines marked with a * are zOWBscript specific, you can remove them if you like, but be sure that all brackets still match when you do).

%z.sys.moo - availablity status, returns 'Available' when found, 'Unavailable' if not found.
%z.load.plugns - whether or not to load plugins
%z.sys.moo.loaded - loaded status, returns either 'loaded', 'not loaded' or 'failed to load'.
%z.set.sysinfo.moo - whether or not to use moo.mrc as sysinfo replacement

%z.pr - Line prefix
%z.col.hi - text hilight colour

%z.col.txt - text colour *

Notes
you might want to remove the comments before using, for some reason it parses the comments as something that has to be /set on a variable... no idea why.

      if ($exists(scripts\moo.mrc) == $true) {           ;if moo.mrc exists...
         /set %z.sys.moo Available                       ;...set it as available.
         if ($script(moo.mrc) == $null) {                ;if it's not loaded...
            if (%z.load.plugins == 1) {                  ;...and plugin loading is enabled...
               .load -rs scripts\moo.mrc                 ;...try to load it...
               if ($script moo.mrc) == $null) {          ;...if it's still not loaded...
                  /set %z.sys.moo.loaded failed to load  ;...set status to 'failed to load'
               }
               else {                                    ;if it was loaded successfully...
                  /set %z.set.sysinfo.moo 1              ;...make moo.mrc do the sysinfo...
                  /set %z.sys.moo.loaded loaded          ;...and make moo.mrc show up as loaded.
               }
            }
            else {                                       ;if we don't want to load plugins at start..
               /set %z.set.sysinfo.moo 0                 ;...do not use moo.mrc for sysinfo...
               /set %z.sys.moo.loaded not loaded         ;...and make it show up as 'not loaded'.
            }
         }
         else {
            /set %z.set.sysinfo.moo 1                    ;if the script is already loaded...
            /set %z.sys.moo.loaded loaded                ;...make it show up as such.
         }
      }
      else {
         /set %z.sys.moo Unavailable                     ;if moo.mrc doesn't exist...
         /set %z.set.sysinfo.moo 0                       ;...disable moo.mrc sysinfo...
         /set %z.sys.moo.loaded not loaded               ;...set it as 'not loaded'...
         /set %z.sys.moo Unavailable                     ;...and as 'unavailable'.
      }
      /echo %z.pr %z.col.hi $+ moo.mrc %z.col.txt $+ is %z.col.hi $+ %z.sys.moo $+ %z.col.txt $+ , %z.sys.moo.loaded
                                                         ; the line above this shows status, if it's available and/or loaded.

Comments

Sign in to comment.
knoeki   -  Jan 21, 2009

Typo: I think you missed the point here.. (or maybe I'm missing yours, I'm really tired right now..)

this snippet isn't meant to be an alias or something. it's just a little bit of code to use in a script yourself. This might have caused the bracket mismatches.

I found out about the comments... I should have known that.

I use the /'s in front of my commands anyways, since I'm used to that, and adds readability, imho.

correct me if I'm wrong :_)

 Respond  
Typo   -  Dec 15, 2008

This isnt even usable in its current form. It isn't an alias or anything, it's just code looking for a home and cannot be used as-is.
Your comments need to be on seperate lines to avoid them being processed.
You have bracket mismatches.
You do not need to use "/" in front of commands inside of scripts.
Here is the code with the items above fixed.

alias NAME_ME {
  if ($exists(scripts\moo.mrc) == $true) {           
    ;if moo.mrc exists...
    set %z.sys.moo Available                       
    ;...set it as available.
    if ($script(moo.mrc) == $null) {               
      ;if it's not loaded...
      if (%z.load.plugins == 1) {                  
        ;...and plugin loading is enabled...
        .load -rs scripts\moo.mrc                 
        ;...try to load it...
        if ($script moo.mrc) == $null) {          
          ;...if it's still not loaded...
          set %z.sys.moo.loaded failed to load  
          ;...set status to 'failed to load'
        }
        else {                                    
          ;if it was loaded successfully...
          set %z.set.sysinfo.moo 1              
          ;...make moo.mrc do the sysinfo...
          set %z.sys.moo.loaded loaded          
          ;...and make moo.mrc show up as loaded.
        }
      }
      else {                                       
        ;if we don't want to load plugins at start..
        set %z.set.sysinfo.moo 0                 
        ;...do not use moo.mrc for sysinfo...
        set %z.sys.moo.loaded not loaded         
        ;...and make it show up as 'not loaded'.
      }
    }
    else {
      set %z.set.sysinfo.moo 1                    
      ;if the script is already loaded...
      set %z.sys.moo.loaded loaded                
      ;...make it show up as such.
    }
  }
  else {
    set %z.sys.moo Unavailable                     
    ;if moo.mrc doesn't exist...
    set %z.set.sysinfo.moo 0                       
    ;...disable moo.mrc sysinfo...
    set %z.sys.moo.loaded not loaded               
    ;...set it as 'not loaded'...
    set %z.sys.moo Unavailable                     
    ;...and as 'unavailable'.
  }
  echo %z.pr %z.col.hi $+ moo.mrc %z.col.txt $+ is %z.col.hi $+ %z.sys.moo $+ %z.col.txt $+ , %z.sys.moo.loaded                       
  ; the line above this shows status, if it's available and/or loaded.
}

Good luck.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.