Lesson 8: Convert a simple mIRC script
Goal: convert this mIRC script:
on *:TEXT:!hello*:#:{ msg $chan Hello, $nick! (you said: $1-)}Option 1: let SwizzinIRC translate it
Section titled “Option 1: let SwizzinIRC translate it”Save it as a .mrc file. SwizzinIRC translates this pattern to SwizzScript when it loads and lists any problems with line numbers. It stays Off until you review it and approve its permissions. Edit the .mrc file, not the translation. See mIRC compatibility for the supported events, commands and identifiers.
Option 2: write it in Luau
Section titled “Option 2: write it in Luau”--! name: Hello trigger--! description: Answers !hello in channels--! api: 1--! permissions: sendswizzin.on("message", function(e) local inChannel = string.sub(e.target, 1, 1) == "#" if inChannel and swizzin.wildmatch("!hello*", e.text) then swizzin.send(e.target, `Hello, {e.nick}! (you said: {string.sub(e.text, 1, 200)})`) endend)How the parts map
Section titled “How the parts map”| mIRC | SwizzScript |
|---|---|
on *:TEXT:!hello*:#: |
swizzin.on("message", …) plus swizzin.wildmatch("!hello*", e.text) and a channel check |
$chan |
e.target |
$nick |
e.nick |
$1- |
the message text, e.text |
msg $chan … |
swizzin.send(e.target, …) |
Expected result
Section titled “Expected result”Someone typing !hello there in a channel gets Hello, <their nick>! (you said: !hello there).
Common mistakes
Section titled “Common mistakes”- Expecting mIRC variables,
if/while,timer, files or sockets to translate: they are refused. Use Luau locals,swizzin.data, andswizzin.timer. - Forgetting the channel check: in mIRC the
#in the event restricts it to channels.
Troubleshooting
Section titled “Troubleshooting”- The editor lists unsupported lines (up to 20) with line numbers. See Coming from mIRC.