Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ hp trigger
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Hattrick
(1 post) Bio
|
Date
| Sat 04 Oct 2003 08:15 AM (UTC) |
Message
| how would i be able to create a trigger which makes me "rub oil" (salve) whenever my hp drops below 100.
the syntax is
hp: 220|sp: 167|mp: 290 >
and this is displayed in EVERY round of combat and every time i change rooms. the oil takes about 4 seconds to take affect while each combat round is about 2s. so if my hp, drops below 100, a standard trigger will send rub oil twice (since a round goes by after rub oil is sent and this inturn triggers rub oil again since my hp is still below 100).
how can i write a script to rub oil and also to have about a 3 second delay if the trigger after fired once so i dont waste oil?
thanks in advance | Top |
|
Posted by
| Poromenos
Greece (1,037 posts) Bio
|
Date
| Reply #1 on Sat 04 Oct 2003 09:44 AM (UTC) |
Message
| Make the trigger a regular expression, and put this in the "match" box:
hp: \d\d|sp: .*|mp: .* >
then, make it send to scripting, and write that in the send box:
DoAfter 4, "rub oil"
It should work. |
Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it! | Top |
|
Posted by
| Magnum
Canada (580 posts) Bio
|
Date
| Reply #2 on Sat 04 Oct 2003 02:09 PM (UTC) |
Message
| No, that won't work. You'll just stack multiple doafter's with each health bar that is received.
I would do something along the lines of:
If SalveTimer exists, do nothing,
else create 4 second SalveTimer and apply the salve.
Another option would be to set a boolean variable:
If NOT ApplyingSalve then
ApplyingSalve = True,
Send the line to apply salve
...but this requires a second trigger on the line where you actually apply the salve, to set ApplyingSalve = False. |
Get my plugins here: http://www.magnumsworld.com/muds/
Constantly proving I don't know what I am doing...
Magnum. | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #3 on Sat 04 Oct 2003 07:42 PM (UTC) Amended on Sat 04 Oct 2003 07:52 PM (UTC) by Flannel
|
Message
| How about you have the trigger disable itself, with a Doafter to reenable it?
(ie, triggers have a built in boolean, its the enabled flag)
Err, Apparently Doafter doesnt get parsed (the next thread told me!) So, just use Createtimer.
|
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| Poromenos
Greece (1,037 posts) Bio
|
Date
| Reply #4 on Sun 05 Oct 2003 12:55 AM (UTC) |
Message
| Ah, right, missed that, sorry. You should be able to disable it and create a timer to reenable it after a few seconds from within the trigger... |
Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it! | Top |
|
Posted by
| Ked
Russia (524 posts) Bio
|
Date
| Reply #5 on Wed 08 Oct 2003 12:45 PM (UTC) Amended on Wed 08 Oct 2003 12:48 PM (UTC) by Ked
|
Message
| I prefer using what I call "scripted timers" for that sort of thing. This means measuring the time between trigger calls of the script routine to figure out if a certain time period has elapsed. I find that to be more convenient than adding/deleting mushclient timers all the time, especially if you want to queue several jobs like that. The template for a "scripted timer" involves:
1. A trigger subroutine
2. A "balance" variable - this is a flag which defines whether you can or not perform a certain queued task.
3. A "time stamp" variable - this stores the exact time when the balance variable was set to false (the task was performed) last.
4. A "time setting" subroutine - sets the value of the time stamp variable (3); is called everytime the balance variable (2) is set to false - the corresponding task is performed
5. A "time check" function - subtracts the time stamp from the time of the current call, then compares the result to the specified time period for a specific balance variable. Returns vbTrue if the time period has elapsed, vbFalse - if it's still too early to perform the task again.
The entire setup makes sure you perform a specific task no more often than over a specific interval of time, which is what is achieved with MC timers. However, I find this approach to be a lot cleaner than fiddling around with multiple MC timers, and com calls associated with them. It is also very simple to expand to add new tasks - you just have to add new balance/time-stamp variable pairs for each task and include them in your subs and function.
Here's an example script in vbs:
'This is the balance/time-stamp pair for the "oil" task
dim oilBalance, oilTimestamp
oilBalance = vbTrue
'This is the sub called by your prompt trigger
'
sub CheckPrompt(name, output, wildcs)
'code to extract and store the values from the prompt goes
'somewhere around here
'and here's the timer-related code
if oilBalance then
world.send "rub oil"
SetTimeStamp "oil"
oilBalance = vbFalse
else
if TimingExpired("oil") then
world.send "rub oil"
SetTimeStamp "oil"
oilBalance = vbFalse
end if
end if
end sub
'This sets the time stamp
'
sub SetTimeStamp(task)
select case task
case "oil"
oilTimeStamp = Timer
end select
end sub
'This checks if the timing for a certain task has expired
'
function TimingExpired(task)
dim timeNow, timeDiff
timeNow = Timer
select case task
case "oil"
timeDiff = timeNow - oilTimestamp
if (timeDiff < 0) then
timeDiff = timeNow + (86400 - oilTimestamp)
end if
if (timeDiff < 4.0) then 'here 4.0 denotes the delay between oil rubs
TimingExpired = vbFalse
else
oilBalance = vbTrue
TimingExpired = vbTrue
end if
end select
end function
For fool-proofness' sake you can add a 1 sec timer to the prompt trigger to check for the expiration of the balance time - that offers enough protection against lag, from my experience. | Top |
|
Posted by
| Poromenos
Greece (1,037 posts) Bio
|
Date
| Reply #6 on Wed 08 Oct 2003 01:05 PM (UTC) |
Message
| I prefer to just send a command to the mud that doesn't give you lag and that won't be seen by other players, such as "Dgdsgdf", which produces "Huh?". That way i can match on Huh and i don't need timers, and i also know exactly when the previous action finished. |
Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it! | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #7 on Wed 08 Oct 2003 10:50 PM (UTC) |
Message
| So, if the MUD logs mis-typed commands (as some do) then the admins will say to themselves, "there goes Poremenos, trying that "Dgdsgdf" command again - he never seems to get it right.".
:) |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Poromenos
Greece (1,037 posts) Bio
|
Date
| Reply #8 on Thu 09 Oct 2003 12:00 PM (UTC) |
Message
| lol, didn't know they logged that... Anyway, the mud i'm in allows triggers, so it's a nice way to do it :) |
Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it! | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
23,127 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top