I need a script that when it sees a number in a certain range at a certain place in a line, it executes the roll command. The user needs to be able to set this variable. I know nothing of lua, but from my reading the guides I would think I'd want to use a for...but don't know how to do ranges in for statements in lua.
Maybe something like...
for roll = [1..$target]
send("Roll")
echo("Rolling")
else
break
end
But I know that's not right...can someone help me?
Someone help me with a very simple script?
Re: Someone help me with a very simple script?
See http://www.youtube.com/watch?v=URbwW41LBcQ and http://lua-users.org/wiki/ForTutorial, along with http://www.youtube.com/view_play_list?p ... xt_from=PL on how to use the equivalent of $target in mudlet
Does that help?
Does that help?
Re: Someone help me with a very simple script?
If you want help you to provide more details on the exact MUD output and what you want to do in which cases and which variables you want to set and how you'd like them to be set i.e. automatically (trigger/system variables) or by user interaction (alias/button).
Re: Someone help me with a very simple script?
I'm going to watch both videos and start trying to write one, but I'll post here while I do.
My line is: [45] Cmds: help, end, roll, add, rem>
I need if 45 is below the variable set by the user, then the script executed the "roll" command. Eventually, I'd like it to tally how many times it has executed the roll command, and what the highest value of [X] that has been achieved is. But the first and most basic thing is to.
1. Have a way for the user to set the variable.
2. Make it so the mud executed roll when it is less than the variable.
My line is: [45] Cmds: help, end, roll, add, rem>
I need if 45 is below the variable set by the user, then the script executed the "roll" command. Eventually, I'd like it to tally how many times it has executed the roll command, and what the highest value of [X] that has been achieved is. But the first and most basic thing is to.
1. Have a way for the user to set the variable.
2. Make it so the mud executed roll when it is less than the variable.
Re: Someone help me with a very simple script?
1. trigger that parses the number in your line: "[45] Cmds: help, end, roll, add, rem>"
trigger pattern: \[(\d+)\] Cmds: .*roll.*>
pattern type regex
script:
2. alias to set the variable maxRolls interactively
alias pattern:^maxRolls (\d+)
script:
3. alias to see the current value of maxRolls:
alias pattern:^maxRolls show"
script:
4. triggers or aliases to define your variable "target" that is being used in your roll script
That's it.
trigger pattern: \[(\d+)\] Cmds: .*roll.*>
pattern type regex
script:
Code: Select all
local rMax = maxRolls or 0
local t = target or "no target defined"
local r = tonumber( matches[2] )
if r < rMax then
send("roll" .. t )
end
alias pattern:^maxRolls (\d+)
script:
Code: Select all
maxRolls = tonumber( matches[2] )
echo("setting variable maxRolls=" .. maxRolls .. " OK\n")
alias pattern:^maxRolls show"
script:
Code: Select all
echo("The current value of maxRolls=" .. maxRolls .."\n")
That's it.
Re: Someone help me with a very simple script?
The aliases seem to work fine, but the trigger doesn't.
Not positive I'm entering it right, so I've included a screenshot. In the back is the pattern I'm trying to match.
http://img121.imageshack.us/img121/1070 ... shotrn.png
It seems to me the trigger isn't matching. It just isn't doing anything.
Not positive I'm entering it right, so I've included a screenshot. In the back is the pattern I'm trying to match.
http://img121.imageshack.us/img121/1070 ... shotrn.png
It seems to me the trigger isn't matching. It just isn't doing anything.
Re: Someone help me with a very simple script?
remove the space from the beginning of your pattern
Re: Someone help me with a very simple script?
Also enable anti-aliasing in the main display tab of settings to make fonts look nicer.
Re: Someone help me with a very simple script?
Okay, so...I changed it up a bit.
It works fine...I had it working...but then I restarted my client, and now it won't work at all...any idea why?
I'm guessing something to do with variables?
Code: Select all
local rMax = maxRolls or 0
local r = tonumber( matches[2] )
rHigh = rHigh or 0
if r > rHigh then
rHigh = r
end
if r < rMax then
rTot = rTot + 1 or 0
send("roll")
echo("You have rolled ".. rTot .." times with a highest roll of "..rHigh..",")
end
I'm guessing something to do with variables?
Re: Someone help me with a very simple script?
No one have any idea why the script would stop working upon restart of the client?