A really stupid question about Triggers..

Posted by Elric on Sat 22 Dec 2001 07:15 AM — 11 posts, 36,492 views.

USA #0
Can one set a trigger so that when someone reaches a certain amount of Mana, they will trance?

Like so:

Prompt1
(32715/32715hp|29075m|30000mv)(525)<1846628776 coins>(#21002)

When the mana drops below, say about, 28000, I want to be able to trance about 7 times. WITHOUT scripting, can it be done with Triggers?
Denmark #1
No
USA #2
Gosh, thanks.

Anywho, can it be done by just making MUSHClient, if it sees a specific number or a number below a certain number, do a command string?

Only reason I ask is because I cannot script.
Denmark #3
Heh.. well sorry, but as far as I know about triggers you
cant make them check for a number, but if you ask nicely
I'll help you make the script for it :)
USA #4
<Snicker> Alright, pretty please?
Help me make a script, pretty please? And I think your specialty is VB right? That works out, hehe..
Denmark #5
go into your config screen in MC, and click the scripting menu
and choose scripts, then make sure the 'Enable script' is active
scripting language is VBscript and select a location and filename
for your script.

click edit script and paste the following:

'---------------------------Storm Dragon Code--------------------------------

sub PromptParse (strTriggerName, trig_line, arrWildCards)
  select case lcase(StrTriggerName)
    case "install"
      world.addtrigger "SendPrompt", "(*/*hp|*m|*mv)(*)<* coins>(#*)", "", 1, -1, 0, "", "PromptParse"
    case "sendprompt"             '    1 2   3  4    5  6         7  - These are the wildcards
      world.setvariable "CurrentHP", cint(arrWildCards(1))
      world.setvariable "MaxHP", cint(arrWildCards(2))
      world.setvariable "CurrentMana", cint(arrWildCards(3))
      world.setvariable "CurrentVitality", cint(arrWildCards(4))
      world.setvariable "CurrentCoins", cint(arrWildCards(6))
    case else
  end select
' Below this line we can insert the subroutines that have to be checked everytime a prompt shows up.
  call ManaCheck
end sub

sub ManaCheck
  if world.getvariable("CurrentMana") <= world.getvariable("MinMana") then
    world.send "Trance"
    world.send "Trance"
    world.send "Trance"
    world.send "Trance"
    world.send "Trance"
    world.send "Trance"
    world.send "Trance"
  end if
end sub
'-----------------------End Storm Dragon Code--------------------------------


Ok.. we are done with the script, save it and return to the config screen
notice just above the help button, it says 'Script Prefix' it should say /
change it only if you use that character in the game (I mean when you start a line with it)
click the ok button and type the following into your command line

/promptparse "install", "", ""
/world.setvariable "MinMana", 23000

where the last number is the minimum mana you have before starting the trancing
Amended on Sun 23 Dec 2001 12:13 PM by Storm Dragon
USA #6
Error number: -2146828282
Event: Execution of line 10 column 7
Description: Overflow: 'cint'
Called by: Function/Sub: PromptParse called by trigger
Reason: processing trigger "SendPrompt"

On trying to load the first command you put there.. Hehe..
Denmark #7
Ah.. yes, I think the cint() is limited to 32000 or so
and the amount of coins you are carrying are way beyond that
Replace:
      world.setvariable "CurrentCoins", cint(arrWildCards(6))

With:
      world.setvariable "CurrentCoins", arrWildCards(6)


Or delete it completely if you dont believe you are going to use it
USA #8
Oh, I am definitely going to use this.. And now, thanks to your example and Nick's.. I may have a chance at learning this.. Lmao.. Thanks mate..
Australia Forum Administrator #9
Quote:

When the mana drops below, say about, 28000, I want to be able to trance about 7 times. WITHOUT scripting, can it be done with Triggers?


With recent versions of MUSHclient this can now be done just a trigger with inline scripting. I suppose it is still scripting, but it is simple enough.

Say your prompt was:

(32715/32715hp|29075m|30000mv)

You could make a trigger match on:

(*/*hp|*m|*mv)*

That makes the mana wildcard 3 (third asterisk). So put in the send text:


if CLng (%3) < 28000 then
  Send "trance"
  Send "trance"
  Send "trance"
  Send "trance"
  Send "trance"
  Send "trance"
end if



Then mark the trigger "send to script". That should do it.
Greece #10
trigger text:
^\((.*?)\/(.*?)hp\|(27\d\d\d)m\|(.*?)mv\)\((.*?)\)\<(.*?) coins\>\(\#(.*?)\)

Don't know if the syntax is actually correct, wrote this off the top of my head, but it IS possible, using regex, to match on 27 and 3 digits, which means that this'll match on any number between 27000 and 27999...
Some people shout "script, script!" way too early :p
I like scripts a lot myself, but regex is really powerful, and if you can do it with just an expression, why write a script?