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 ➜ Zmud stuff

Zmud stuff

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


Pages: 1 2  

Posted by Penguin   (46 posts)  Bio
Date Thu 30 May 2002 10:14 AM (UTC)
Message
I'm not too sure with Zmud scripting cos I hardly use it.. but can anyone help me with the following terms?

#VAR light {%additem(%proper(%1),@light}

VA light ""
#t+ wholight
#wa 1000
#t- wholight

Maybe tell me what they do? Or how to replace them using VBscript? Thanks.
Top

Posted by Shadowfyr   USA  (1,791 posts)  Bio
Date Reply #1 on Thu 30 May 2002 06:23 PM (UTC)

Amended on Thu 30 May 2002 06:26 PM (UTC) by Shadowfyr

Message
Hmm... Well I don't know much about it either. I converted a 'time to reboot' script I use to it with some help, but found the commands inconsistant, buggy and in some cases not working even close to the way described. However I will take a shot at it...

#VAR light {%additem(%proper(%1),@light}:
Define a variable 'light' and
Places the proper name (i.e. sam -> Sam) in %1 into 'light'.

VA light "" - Sets the variable light to blank.
#t+ - Turns on the triggers in the wholight group.
#wa 1000 - Waits a bit.
#t- - Turns off the triggers in the wholight group.

Now doing this in MUSHClient...

The first bit becomes:
world.setvariable "light", ucase(mid(wildcard(1),1,1)) & mid(wildcard(1),2,len(wildcard(1))-1)

Or something close to this. Apparently MS doesn't think a command to change a name to its proper form was important enough to support directly. :p I don't know how your getting the value in the existing script but wildcard(1) is the equivalent of %1 in most cases.

The second part is complicated since there is no real wait command in MUSHClient in the sense of how ZMUD uses it, nor are triggers 'groupable', however since there appears to only be one in this instance (I assume):

world.setvariable "light", ""
world.enabletrigger "wholight", 1
world.addtimer ("lightwait", 0, 0, 1, "", 16388, "killtrigger")

The 16388 makes this a temporary and one shot timer.

And then another script as follows to execute the last bit:

  sub killscript (Timername)
    world.enabletrigger "wholight", 0
  end sub
Top

Posted by Penguin   (46 posts)  Bio
Date Reply #2 on Fri 31 May 2002 01:08 AM (UTC)
Message
Theres another command linked to an alias called "light"
#FORALL {@light} {tell %lower(%i) (Light) %1}

I tried to do this by writing a script which goes like this:

Sub Light_Tell (AliasName, TriggerLine, arrWildcards)
shadowperson = world.GetVariable("light")
shadowperson = UCase(Left(person, 1)) & LCase(Mid(person, 2, Len(person)))
World.Send "tell" & shadowperson & "$BOLD$(Light) %1"
End Sub

This is accompanied by an alias "light *" which calls upon the script. However it doesn't seem to work... Do you know what might be wrong?
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #3 on Fri 31 May 2002 01:34 AM (UTC)
Message
Do you really need all the case conversion? Most MUDs won't mind if you send to an all lower-case name. From what I gather you are trying to do, you are making a list of people (trigger) and sending to all of those people (alias).

To make the list, you simply can append to a variable, like this:


sub NewPerson (sName, sLine, wildcards)

  world.setvariable "people", world.getvariable ("people") _
        & ", " & wildcards (1)

end sub


This will append to the list (obviously you need to clear it out sometime).

Now, to tell something to everyone in the list. Make an alias, eg.


<aliases>
  <alias
   name="TellAll"
   script="DoTellAll"
   match="tellall *"
   enabled="y"
  >
  </alias>
</aliases>


Put this in the script file ... 

sub DoTellAll (sName, sLine, wildcards)

  for each x in split (world.getvariable ("people"), ",")
    if trim (x) <> "" then
       world.send "tell " & x & " " & wildcards (1)
    end if 
  next

end sub


What this is doing is getting the contents of the variable "people", using "split" to break it up at the commas, using "for each" to walk the array output from "split", and then sending to the world, providing the name doesn't end up blank.

- Nick Gammon

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

Posted by Penguin   (46 posts)  Bio
Date Reply #4 on Fri 31 May 2002 10:43 AM (UTC)
Message
Hmm. What I'm trying to do here is get a list of people from a 'who friend' list then send tells to each one of them. For example:

Loser the dwarf Warrior
Winner the elf Archer

I have a trigger: (\w) the (elf|dwarf) to try and set their names as variables.. but I can't connect everything(aliases, triggers, scripts) to make it work.
Top

Posted by Shadowfyr   USA  (1,791 posts)  Bio
Date Reply #5 on Fri 31 May 2002 08:47 PM (UTC)

Amended on Fri 31 May 2002 08:59 PM (UTC) by Shadowfyr

Message
Well.. The problem here is two fold. First is that most muds are not trigger friendly. If you have a prompt or something that contains 'fixed' (i.e. unchanging) an 'unique' information you can use a method that pulls all names from the list using * as the match pattern and turns that trigger off if it sees the unique features in your prompt. Most muds do not have such a unique prompt and the various list commands don't provide any easy way to identify the end of the list either.

Considering all these facts you can either do something like Gammon suggest, but 'hard code' the names into the script like so:

dim people
people = "loser winner sam fred ..."

or make the command that adds names to you friends list also execute a script to tack them onto a variable like Gammon suggested.

The third option is to add something unique to your prompt and use the * matching trick to read them all and disable the * trigger when you hit the prompt. If you do that then I assume from your example that you also have titles and maybe pre-titles (in front of the name). If you have both then:

sub Grabname (trigname, output, wildcards)
  dim temp, temp2
  temp = split(wildcards(1), " ")
  select case temp(1)
    case "xyzzy" 'Some unique word at the start of the prompt.
      world.enabletrigger "Grabname", 0
      exit sub
    case "celestial" 'The first pre-title
      temp2 = temp(2)
    case "..." 'Additional pre-titles
               'NOTE: if a pretitle has more than one word
               'then you need to grab temp(3) or at worst
               'temp(4) to get the name. For instance
               'The Lord x or The Lady x, would both
               'match on 'The' and return temp(3). Some
               'complex version could require a mess of
               'if-then statements to sort out after the
               'first word is matched, but that's life. ;)
    case else 'No pretitle, just take the name
      temp2 = temp(1)
  end select
  world.send "tell " & temp2 & " " & world.getvariable("Message")
end sub

This assumes you can A) can set your prompt to start with some specific word that will never be in a name or pre-title and B) that you set up an alias that calls a script to enable the trigger that calls Grabname and sends the actual command to list them. You may also want to make the trigger omit from output, so you will only see the results of the command and not the entire list as it is read. If however you have no pretitles at all then you can eliminate the case statement completely and simply check the first temp(1) value for a name or the prompt, which would be:
sub Grabname (trigname, output, wildcards)
  dim temp
  temp = split(wildcards(1), " ")
  if temp(1) = "xyzzy" then
    world.enabletrigger "Grabname", 0
  else
    world.send "tell " & temp(1) & " " & world.getvariable("Message")
  end if
end sub

which is much shorter, but can't handle any change that may later be made that adds pre-titles to the mud.
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #6 on Fri 31 May 2002 10:12 PM (UTC)
Message
Quote:

Hmm. What I'm trying to do here is get a list of people from a 'who friend' list then send tells to each one of them. For example:

Loser the dwarf Warrior
Winner the elf Archer

I have a trigger: (\w) the (elf|dwarf) to try and set their names as variables.. but I can't connect everything(aliases, triggers, scripts) to make it work.


You need a trigger that matches on:


(\w+) the (silvan|sindar|dwarf|dunedain|dunlending|eorling|hobbit)


This is initially disabled. Then you make an alias "getfriends" or whatever, that enables that trigger, and does a "who friends". The alias can also add a 2-second timer (or whatever) to disable the trigger again when its time is up (or use another trigger to look for something at the end of the who list, if there is such a thing).

The trigger adds names to the list, as I described earlier.

- Nick Gammon

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

Posted by Penguin   (46 posts)  Bio
Date Reply #7 on Fri 31 May 2002 11:37 PM (UTC)
Message
Hmm.. the names don't seem to be registering as variables. When I type 'whofriends' my alias to call the script:

sub NewPerson (sName, sLine, wildcards)
world.enabletrigger "NameTrigger", 1
world.send "who friend"
world.setvariable "people", world.getvariable ("people") _
& ", " & wildcards (1)
end sub

If I go to World Properties -> Scripting -> Variables, under people it has a few commas instead of their names. I have added a trigger as suggested by Nick, which is labeled "NameTrigger" in the above script. Can anyone figure out what is wrong?
Top

Posted by Penguin   (46 posts)  Bio
Date Reply #8 on Fri 31 May 2002 11:48 PM (UTC)
Message
Oh yeah and a minor adjustment to the trigger: I'm using two wildcards instead of one now, because behind the name and race lies their title.
It now looks like this:
* the the(silvan|sindar|dwarf|dunedain|dunlending|eorling|hobbit)*

Am I allowed to use '*' at the start? Do I need to edit my scriptfile now that there are two wildcards?
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #9 on Sat 01 Jun 2002 01:16 AM (UTC)
Message
This line needs to go in the trigger, not the alias. It is done for every matching person:


world.setvariable "people", world.getvariable ("people") _ 
           & ", " & wildcards (1) 


And no, you don't need to change the script, the person will still be wildcard 1.

- Nick Gammon

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

Posted by Penguin   (46 posts)  Bio
Date Reply #10 on Sat 01 Jun 2002 04:20 AM (UTC)
Message
The variable 'people' still appear as commas only. I dont know what is wrong. I'll paste my aliases/triggers/scripts.

Trigger: Total friends: *
Label: DisableNameTrigger
Script: Disable_NameTrigger

Sub Disable_NameTrigger (AliasName, TriggerLine, arrWildcards)
World.enabletrigger "NameTrigger", 0
End Sub

Trigger: * the (silvan|sindar|dwarf|dunedain|dunlending|eorling|hobbit) *
Send: world.setvariable "people", world.getvariable ("people") _
& ", " & wildcards (1)
Label: NameTrigger

Alias: whofriends
Label: WhoFriends
Script: NewPerson

sub NewPerson (sName, sLine, wildcards)
world.enabletrigger "NameTrigger", 1
world.send "who friend"
end sub

Alias: tellall *
Label: TellFriends
Script: DoTellAll
sub DoTellAll (sName, sLine, wildcards)

for each x in split (world.getvariable ("people"), ",")
if trim (x) <> "" then
world.send "tell " & x & " " & wildcards (1)
end if
next

end sub

I believe the error lies right in the trigger or something, since the names of my friends are not registered.
Top

Posted by Penguin   (46 posts)  Bio
Date Reply #11 on Sun 02 Jun 2002 02:54 AM (UTC)
Message
It seems that the (silvan|sindar|dwarf|dunedain|dunlending|eorling|hobbit) part isn't working. I added a small trigger, "* the silvan *" to change the color to yellow. It colored my silvan friend who appeared in the who list. However when I changed it to "* the (hobbit|silvan) *" neither my hobbit friend nor my silvan friend got colored. A bug maybe?
Top

Posted by Penguin   (46 posts)  Bio
Date Reply #12 on Sun 02 Jun 2002 03:58 AM (UTC)
Message
Woo! I managed to get it somewhat working.. changed the trigger to "* the *" instead of the (hobbit|dwarf|...) thing. Only problem now is that the tells I send to my friends have a , behind them(except for the last guy on the list). For example:

tell Winner, test
tell Loser, test
tell Hahaha test

And so only the tell to Hahaha is registered. How do I get rid of the commas?

My script to send tells is the same as before.

sub DoTellAll (sName, sLine, wildcards)

for each x in split (World.getvariable ("people"))
if trim (x) <> "" then
world.send "tell " & x & " " & wildcards (1)
end if
next

end sub
Top

Posted by Vaejor   (120 posts)  Bio
Date Reply #13 on Sun 02 Jun 2002 04:29 AM (UTC)
Message
Quote:

for each x in split (World.getvariable ("people"))


could be:

for each x in split (World.getvariable ("people"), ",")


this will use the comma as the primary point to seperate the names instead of a space
Top

Posted by Penguin   (46 posts)  Bio
Date Reply #14 on Sun 02 Jun 2002 05:07 AM (UTC)
Message
WOO!! I managed to it working now!!! Bwahahahahaha! Thanks everyone:) There's still something minor though. Now when I type my alias to get variables again it adds on to the list variables. like for example, if Winner was on and I already set him as a variable. Then when Loser logs on and I try to get a new list.. instead of just adding Loser to the list and sending tells to Loser, I send tells to Winner, Loser then Winner again. Is there anyway to clear the list first without having to do it manually by going to world properties -> scripting -> variables?
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.


54,745 views.

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

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.