>Trigger: You see *
>Send: %1
>Send to: Variable (label is name)
>Label: mobname
Hmm. Yes, but this won't -
Trigger: You see *
Send: follow %1
Send to: ??? (Oops...)
Label: mobname
You see the problem, you can't send it to more than one place, so you can't A) perform an immediate action and store it at the same time without scripting. and B) this was a simple example and thus doesn't take into account multiple variables in the trigger string and the need to differentiate what 'kind' they are. Of course scripting it is not that big a problem, since things like the status line do not 'as far as I am aware' act as self updating trigger (or maybe it is more like a timer...) in MUSHclient. In zmud they do and thus you can create a status line like:
#setstatus, You are carrying %ston stones and %sor sorcen *
(not sure of the exact syntax..)
and create a single trigger that does nothing more than:
Trigger: You are carrying %d(ston) and %d(sor) *
Send: nothing
Since MUSHclient's status line probably doesn't work this way it isn't as helpful to be able to use a simple trigger without a script. However, you could create a timer to update it the status, in which case it is still nice to do without the extra script code, which does nothing functionally different that Sendto: Variable, save allowing multiple variables and send a command.
It is not necessary to have such function with scripting, but it does provide the means to do without scripts in some cases, such as with following the bunny. In which case you could later use an alias to attack or spellcast on it without needing to enter the name. You can send a more than one variable to the mud in a trigger/alias it is sort of odd that you can only set one at a time and then only if you don't plan to also execute a command using that trigger.
>You have a minor coding bug there. You mean "for each b in >a" - a is the array, not data. It should read like this:
>dim a, b
>a = split(data," ",-1,1)
>for each b in a
> ...do stuff...
>next
>I tried that in immediate mode and it worked. :)
Trust me to type from memory...
The original test code got deleted, but it was more like the following:
sub SetReb (TrigName, Output, Wildcards)
dim sGrab, sOut
dim sMatch
int tim
tim = 0
sMatch = split(wildcards(4),"; ",-1,1)
for each sGrab in sMatch
select case right(sGrab,1)
case "d"
tim = tim + 1440
case "h"
tim = tim + CInt(left(sGrab, b-1)) * 60
case "m"
tim = tim + CInt(left(sGrab, b-1))
case "s"
b = CInt(left(sGrab, b-1))
if b > 30 then
tim = tim + 1
end if
end select
next
world.setvariable "TTRB", CStr(tim)
world.addtimer "RebootTimer", 0, 1, 0, "", 1, "RepReboot"
world.enabletimer "RebootTimer", 1
sOut = Rttt(tim)
world.note "Reboot timer set."
world.setstatus "Reboot is in " & sOut
end sub
function Rttt(tim)
dim sRet, sOut
int temp
int temp2
temp = tim
if temp > 1440 then
sOut = " 1d "
temp = temp - 1440
end if
if temp >= 60 then
temp2 = Int(temp/60)
temp = temp - (temp2 * 60)
sOut = sOut & CStr(temp2) & "h "
end if
sOut = sOut & temp & "m."
Rttt = sOut
end function
The 4th wildcard contained something like '1d 8h 43m 6s' or '33m 5s', etc. depending on the actual time to reboot. I ended up using a slightly more complex 'for 1 to ubound(sMatch)' loop instead. Could be I did mess up the way you suggest though, but I was fairly sure that I hadn't made such a dumb mistake. :p
Note that with self updating status and the ability to treat variables as something other than strings the code would have been more like:
sub SetReb (TrigName, Output, Wildcards)
dim sGrab, sMatch
sMatch = split(wildcards(4)," ",-1,1)
for each sGrab in sMatch
select case right(sGrab,1)
case "d"
tday = 1
case "h"
thr = thr + CInt(left(sGrab, b-1))
case "m"
tmin = tmin + CInt(left(sGrab, b-1))
case "s"
if CInt(left(sGrab, b-1)) > 30 then
tmin = tmin + 1
end if
end select
next
world.addtimer "RebootTimer", 0, 1, 0, "", 1, "RepReboot"
world.enabletimer "RebootTimer", 1
end sub
Which is significantly shorter and nearly identical to what I used in the zmud version. Though I have found that things like 'if CInt(left(sGrab, b-1)) > 30 then' often cause odd errors in vbscript... Seems a variable it ok, but in some cases imbedding a function inside of a command causes it to generate errors... Bloody annoying. Obviously if this was not the case, then I could also eliminate the need to put the contents of the split into a variable. This sort of bug also appears in zmud's scripting in a quite a few places.
Note: In both cases a timer calls Rttt every minute, but in this modified version it does not build the string, but just decrements variables.
Anyway.. Maybe I will try again with something else (or maybe rewrite what I am using), but for now it is a bit of a null issue, since what I am using works, even if it is slightly more complex than it really needed to be. ;) |