Register forum user name Search FAQ

Gammon Forum

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 ➜ Triggering on variables

Triggering on variables

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1  2 

Posted by Magnum   Canada  (580 posts)  Bio
Date Reply #15 on Wed 07 Aug 2002 06:40 PM (UTC)

Amended on Wed 07 Aug 2002 06:43 PM (UTC) by Magnum

Message
Reminder, This is PAGE 2 on the forums, Check page 1, I have a new post there too.
Quote:

And also, would I be able to also like type "exitall" to exit that particular question and stop any other triggers which may bring up questions like those until activated by myself?

Hmm. Ok, first of all, I assume you made a trigger to call the "Ask_Encounter_Question". Let's say it's something like this:

<triggers>
  <trigger
   enabled="y"
   match="Llama checks you out."
   name="Mob_Llama_Enters"
   script="Ask_Encounter_Question"
   sequence="100"
  >
  </trigger>
</triggers>

The sample label above for the trigger is "Mob_Llama_Enters". We could build a subroutine to turn the trigger on and off:

Sub Toggle_AutoQuestion (Aliasname, AliasLine, arrWildcards)
  Dim TriggerState
  Dim TriggerName
  TriggerName = "Mob_Llama_Enters"
  If World.IsTrigger(TriggerName) Then
    TriggerState = World.GetTriggerInfo(TriggerName, 8)
    If TriggerState Then
      World.EnableTrigger TriggerName, vbFalse
      World.Note "Trigger Disabled: " & TriggerName
    Else
      World.EnableTrigger TriggerName, vbTrue
      World.Note "Trigger Enabled: " & TriggerName
    End if
  Else
    World.Note "Error: Couldn't find the trigger: " & TriggerName
  End If
End Sub

That subroutine checks to see if the trigger exists. If so, if it was enabled, then it becomes disabled. If it was disabled, then it becomes enabled. You would use an alias to call that subroutine:

<aliases>
  <alias
   name="Toggle_AutoQuestion"
   script="Toggle_AutoQuestion"
   match="autoq"
   enabled="y"
   ignore_case="y"
  >
  </alias>
</aliases>

Use the copy and paste mentioned in the previous message to add that as an alias.

All of this code I have provided you works with just one trigger, hardcoded to a single mob. If you are interested in learning Visual Basic, you may want to take this on as a project, and see if you can modify the code so that it would work on multiple mobs (without duplicating the script a bunch of times for each mob) It might not be too hard.

Nick, I would like to point him to the Visual Basic Manual help file, but I don't want to navigate MS's site to find the link. Any chance you could host it yourself here as well, since so many people here are likely to need it?

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
Top

Posted by Penguin   (46 posts)  Bio
Date Reply #16 on Thu 08 Aug 2002 05:34 AM (UTC)
Message
lol.. I forgot to remove the alias thing from the script:P oops.
grin anyway I managed to get the questions to work:) Thanks.. however there seems to be a problem with the "autoq" command. The error message "Error: Couldn't find the trigger: Mob_Llama_Enters" appears when I type "autoq". And after typing that, the question still appears when triggered.
Top

Posted by Magnum   Canada  (580 posts)  Bio
Date Reply #17 on Thu 08 Aug 2002 07:39 AM (UTC)
Message
Do either:

- Replace the line:

TriggerName = "Mob_Llama_Enters"

... with a different value in quotes. Put the actual label of your 'Llama enters' trigger.

OR

- Check/Change the label of your 'Llama enters' trigger, and make sure it matches what is in quotes, above.

Incidentally, I realized later, if you enter something that causes an error, with the "pick" alias, the question gets reset anyway. For example, if you typed "pick 4", then you get told that's not an option, and the question is reset. You can't do "pick 3" after that. Indeed, You can only use the "pick" alias once, then the answers are reset! That could be a problem if you wanted to do "pick 1" and then "pick 2" after.

Why not take a stab at coding and see if you can edit the script so it's more flexible? :)

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #18 on Thu 08 Aug 2002 10:15 AM (UTC)
Message
So, "pick 4" is really "exitall?

Perhaps don't disable the alias if an invalid answer is given?

eg.


If Not IsNumeric(ArrWildcards(1)) Then
    World.Note "Invalid answer: You must pick a number."
     Exit Sub
  Else

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Penguin   (46 posts)  Bio
Date Reply #19 on Thu 08 Aug 2002 10:55 AM (UTC)
Message
Yup, entering an invalid choice clears the question, which works quite fine for me. However I still have problems with the "autoq" thing. Just to get me back on track, "autoq" is supposed to exit all further questions which may occur due to triggers right?

Anyway the same error message still appears

Error: Couldn't find the trigger: R_question

even though I changed the label of the trigger to "R_question" and edited the value of TriggerName in the script file to "R_question" Don't see what's wrong.. unless something is wrong with the script itself?
Top

Posted by Magnum   Canada  (580 posts)  Bio
Date Reply #20 on Thu 08 Aug 2002 08:50 PM (UTC)
Message
Heh... Ok, I'll blame this one on Nick. :) :)

I checked the documentation for "World.IsTrigger()" here:
http://www.gammon.com.au/scripts/function.php?name=IsTrigger&searchfor=

and realized, the function returns a "0" if the trigger does exist. That contradicts standard Visual Basic Programming. If you do this:

/World.Note True

directly in the command box, you will see a "-1" result. If you change it to False, you will see a "0" result.

...So, "World.IsTrigger()" is giving us backwards results. Oh well, we will compensate. Change the appropriate line to this:

  If NOT World.IsTrigger(TriggerName) Then

...And things should work, I believe.

P.S. to Nick: I can see why you made this function the way you did... Heh, just a surprise for those of us who don't RTFM till something goes wrong... LOL.

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #21 on Thu 08 Aug 2002 09:15 PM (UTC)
Message
Strictly speaking, it returns eOK, where eOK happens to be defined as 0.

The reason was, I wanted to return more than just "true" or "false", as the other return value was "bad label".

The return of eOK is consistent with the way most other trigger routines work.

However I agree that I then do, rather confusingly, use 0 or 1 in some other places to indicate false or true, in circumstances where they are the only two valid responses.

Also, also, in Jscript (and C etc) true is 1, not -1.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #22 on Fri 09 Aug 2002 01:37 AM (UTC)
Message
Quote:

Also, I seem to recall that in version 3.20, errors in the script file would be brought out by the Scripting Error window while attempting to save the script file. Is it changed now?


It attempts to compile script files when you save the script, and when you save an alias (etc.) with a script argument it tries to resolve that (ie. find the routine for it), so you may well get an error message at that point too.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Twilight_Player   (1 post)  Bio
Date Reply #23 on Sat 10 Aug 2002 10:04 AM (UTC)
Message
Following the Above codes i have been able to create many 'selection screens'...however...instead of using e.g 'autoq_look' or 'autoq_login' to check the current status of the selection screen, how would i be able to write a script to show all the autoq commands' status..
e.g autoq_status (and it shows autoq_look status : enabled, autoq_login : disabled...etc etc...)
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.


64,140 views.

This is page 2, subject is 2 pages long:  [Previous page]  1  2 

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.