mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Apr 2010
Posts: 969
F
Hoopy frood
OP Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
The ability to be able to call an alias from a specific loaded script would benefit mSL greatly; especially when it comes to modular systems, I suggest the following:


$scriptcall(@ScriptFile, @Switches:c|i[p], @AliasName, [@Parameter, ...] [@Prop])

@ScriptFile - Required
The scriptfile of which to call the alias from

@Switches - Required
c: The alias is to be called as a command
i: The alias is to be called as an identifier
p: The last parameter is the prop to use when calling the alias as an identifier; only applicable if the i switch is used

@AliasName - Required
The alias to call within the specified scriptfile

@Parameter - Optional
A list of comma delimited parameters to pass the to alias when called
For commands these will be delimited by space($chr(32)) prior to tokenization
For identifiers, each delimited parameter is a token

@Prop - Optional
The prop to use when calling the identifier as an alias
Only applicable if the ip switches have been specified



Use case: Currently I'm working on a modular system and want to extract some script-specific information from the script. With the above it would be fairly simple
Code:
;; module.mrc
on *:START: modreg $script

;; modular_manager.mrc
alias modreg {
  ; calls $modinfo() from the script
  var %name = $scriptcall($1, i, modinfo, name)
  var %desc = $scriptcall($1, i, modinfo, desc)
  var %author = $scriptcall($1, i, modinfo, author)
  var %version = $scriptcall($1, i, modinfo, version)
  var %license = $scriptcall($1, i, modinfo, license)

  ;; do stuff

  ; calls /modinit within the script
  noop $scriptcall($1, c, modinit)
}


It also allows for the modular system to be more generic thus easier for 3rd parties to create script modules.

Last edited by FroggieDaFrog; 25/09/17 06:28 PM.

I am SReject
My Stuff
Joined: Apr 2010
Posts: 969
F
Hoopy frood
OP Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
to fix/expand my example:

Code:
;;module.mrc
on *:START: modreg $script

alias modinfo {
  if ($1 == name) return Example Module
  if ($1 == desc) return An example module to show my point
  if ($1 == author) return SReject
  if ($1 == version) return 0.1
  if ($1 == license) return Public Domain
}

alias modinit {
  ;; do stuff
}


Code:
;; modular_manager.mrc
alias modreg {
  ; calls $modinfo() from module.mrc
  var %name = $scriptcall($1, i, modinfo, name)
  var %desc = $scriptcall($1, i, modinfo, desc)
  var %author = $scriptcall($1, i, modinfo, author)
  var %version = $scriptcall($1, i, modinfo, version)
  var %license = $scriptcall($1, i, modinfo, license)

  ;; do stuff

  ; calls /modinit from module.mrc
  noop $scriptcall($1, c, modinit)
}


I am SReject
My Stuff

Link Copied to Clipboard