<triggers>
<trigger
enabled="y"
group="olc"
match="Mobile * Created"
send_to="12"
sequence="100"
>
<send>require "var"
var.mvnum = var.mvnum + var.one</send>
</trigger>
</triggers>
This is what I have and when it executes it doesn't add the one to mvnum.
<triggers>
<trigger
enabled="y"
group="olc"
match="Room * created."
send_to="12"
sequence="100"
>
<send>require "var"
var.rvnum = var.rvnum + var.one
</send>
</trigger>
</triggers>
I also have this one. It works and is exactly the same as the other one. I'm a little confused so if anyone can shed some light on it for me I would be very thankful.
Can you display the contents of the "var.lua" file? I have this feeling that you are just reloading the initial values, but you haven't really given a lot of information to go by here.
Quote:
var.mvnum = var.mvnum + var.one
This is what I have and when it executes it doesn't add the one to mvnum.
Why don't you just add one?
eg.
var.mvnum = var.mvnum + 1
Because it didn't work that way first so I tried it as a variable equal to one to see if it would work.
-- var.lua
var = {} -- variables table
setmetatable (var,
{
-- called to access an entry
__index =
function (t, name)
return GetVariable (name)
end,
-- called to change or delete an entry
__newindex =
function (t, name, val)
local result
if val == nil then -- nil deletes it
result = DeleteVariable (name)
else
result = SetVariable (name, tostring (val))
end
-- warn if they are using bad variable names
if result == error_code.eInvalidObjectLabel then
error ("Bad variable name '" .. name .. "'", 2)
end
end
})
return var
There's my var.lua.
Variables are nil if they don't exist, so your line is effectively:
This will give an error.
There are a few ways around this.
- Simply use the MUSHclient variables configuration window to add the variable mvnum with a value of zero. Then the add will work. You only need to do this once (per variable) as presumably they then get more than one.
- Somewhere in your script initialize the variables, eg. something like this:
if var.mvnum == nil then
var.mvnum = 0
end -- if
This makes it clear that if the variable doesn't exist, you are initializing it.
- Change your add to look like this:
var.mvnum = (var.mvnum or 0) + 1
By saying "or 0" your are effectively saying "if it is nil, use zero instead".
I certainly would stop using var.one - after all then you have the problem of making sure that var.one is actually 1. And are you going to use var.two if you want to add 2? That is just confusing.
Never mind. It doesn't, it just looked like it did at first.
<variables>
<variable name="mvnum">500785</variable>
</variables>
Theres my variable.
<triggers>
<trigger
enabled="y"
group="olc"
match="Mobile * Created"
send_to="12"
sequence="100"
>
<send>
if var.mvnum == nil then
var.mvnum = 0
end -- if
require "var"
var.mvnum = (var.mvnum or 0) + 1</send>
</trigger>
</triggers>
Theres my trigger.
I'm just really confused because the other trigger I have that uses the exact same stuff works and this one doesn't.
Check the trigger is actually firing. If not, it won't add 1 to anything.

When I tested that, by sending through "Mobile nick Created" - the trigger fired and added one.
Add some debugging into your script like this:
require "var"
if var.mvnum == nil then
var.mvnum = 0
end -- if
var.mvnum = (var.mvnum or 0) + 1
Note ("trigger fired, var.mvnum is now ", var.mvnum)
Note that you need to put the "require" before the first line that uses "var". You didn't do that, which makes me suspect the trigger did not even fire.
You don't need to do both my suggestions, that is just wasting space. Either have the "if" test, or do the "or 0" stuff. Don't do both.
Okay. It works now and all that great stuff. You where right, the trigger wasn't firing at all.
I was checking everything except one tiny thing that would have fixed everything without ever posting on here. I hadn't changed what the trigger was supposed to match for the new olc output.
Thanks a lot. Still learned some nifty stuff.