All I want to do is be able to set a variable in the example:
*playername* says 'iceshield'
so I can then have my mage triggered to cast iceshield on *playername*
I for the life of me can not figure this very simple thing out Thanks
How do I specify a variable?
Re: How do I specify a variable?
This sort of thing is pretty easy. I'm guessing your example is a trigger, so I would make a new trigger to look like:
From there, you make a variable from the regex wildcard by doing:(\w+) says\: "Iceshield."
(Notice that I used local. If you're only going to be using a variable in one place for one script, it's generally better to use a local variable, and not clog up the global variable namespace. From there, you'd just send the command:
Even though it's kind of a cluster, I'd really read through the Mudlet manual and absorb as much as you can. Afterwards, read through a Lua tutorial or something to learn the ins-and-outs of Lua. You'll be very thankful when you're done!
Re: How do I specify a variable?
Thanks...
Obviously I am not a scripter I've tried following along in the manual but I'm just even more confused.
I really like Mudlet (especially because it is basically the only real option for mudding on older non-Intel macs/osx) but I just don't understand why it seems to take so much to do so little.
I can appreciate that Mudlet is "better" because it is more efficient and elegant etc etc from a coding point of view. But as someone who doesn't know how to code and just wants something that works easily, I'm quite frustrated by the above example, which in zmud/cmud I would just specify as:
(%1) says 'iceshield'
cast iceshield (%1)
So simple that even I can understand it!
Obviously I am not a scripter I've tried following along in the manual but I'm just even more confused.
I really like Mudlet (especially because it is basically the only real option for mudding on older non-Intel macs/osx) but I just don't understand why it seems to take so much to do so little.
I can appreciate that Mudlet is "better" because it is more efficient and elegant etc etc from a coding point of view. But as someone who doesn't know how to code and just wants something that works easily, I'm quite frustrated by the above example, which in zmud/cmud I would just specify as:
(%1) says 'iceshield'
cast iceshield (%1)
So simple that even I can understand it!
Re: How do I specify a variable?
It's just by the way Lua works and is designed. All wildcards are found using the Perl RegExp engine, with which there's a ton of documentation about. It's a bit more robust than Zugg's implimentation of wildcards, in that it can handle more things, faster. When you learn the secrets of discerning RegExp, you just have to remember that all of those are stored in the matches[] table within Mudlet, and you just pull the captured strings from there.
It just takes practice. Lua might not be as easy to learn at first, compared to ZScript, but it's much more complete and better all around. Just keep at it!
It just takes practice. Lua might not be as easy to learn at first, compared to ZScript, but it's much more complete and better all around. Just keep at it!
-
- Posts: 186
- Joined: Sun Nov 14, 2010 5:57 am
Re: How do I specify a variable?
FYI you don't need to use the local variable here unless you need to manipulate it for some reason:
Programming in Lua
Lua 5.1 Reference Manual
RegEx Tester they have a nice reference card and a near complete reference for wild card matching
Reading the Mudlet manual will help don't get me wrong, but learning about Lua is going to be necessary also:
Programming in Lua
Lua 5.1 Reference Manual
RegEx Tester they have a nice reference card and a near complete reference for wild card matching
-
- Posts: 186
- Joined: Sun Nov 14, 2010 5:57 am
Re: How do I specify a variable?
Another regex site: www.regular-expressions.info/