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 ➜ Help with creating multiple variables via trigger

Help with creating multiple variables via trigger

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


Posted by Karl_Newbie   USA  (23 posts)  Bio
Date Tue 08 Jun 2004 05:35 AM (UTC)

Amended on Tue 08 Jun 2004 05:39 AM (UTC) by Karl_Newbie

Message
Hi. I've been experimenting some but reached an impasse here.
Many objects in the mud are entirely identical in name and keywords. If there are 3 packs in your character's inventory the mud always has one pack randomly set as the default target of eg 'exam pack' 'get out of pack'

The solution is to use the object's unique identification number eg pack: 324234 or pack: 2342342 or pack: 3423423. eg exam 2342342

Now it is easy enough to make an alias for each pack p1, p2, p3. But I often have scripts that utilize those specific identification numbers which leads to problems since the id numbers change often enough.


I was wondering how to do a script that when I get the identification numbers of all the objects in my inventory, if each pack could be set to a variable eg. p1, p2, p3. And the scripts could expand those variables.

The problem I have is that if I make a trigger to catch a pack: *, and set it as a variable it will always set the pack that appears in the output last as the pack variable called by the script.

Checking the inventory would call this up
The identification numbers are:
pack: 3453453
herb: 534534
cup: 3423423
duck: 343242
pack: 9234
pen: 234224
bag: 342429
pack: 34234
>

Every object in the realm has a unique idenfication number

I would want each of those packs to then set by trigger as variables pack1, pack2, pack3 which I could have expandle in by aliases and triggers eg exam p1 sends examine @pack1


The problem is I only know how to set one of the packs as a variable since the trigger is only set to match ;pack: *; and create variable 'pack1'

How could I get the trigger to take the second occurance of a pack as variable pack2, and third as pack3 and so on?

Thanks
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 08 Jun 2004 07:31 AM (UTC)
Message
What I would do is, whatever starts this process off zeroes out a "pack count".

eg.

Trigger: The identification numbers are:
Send: 0
Send to: variable
Variable: pack_count

---

Then when each "pack: *" trigger fires you would "send to script" something like this:

'
' add 1 to pack count
'
setvariable "pack_count", cint (getvariable ("pack_count")) + 1

'
' remember id for pack x
'
setvariable "pack" & getvariable ("pack_count"), "%1"

- Nick Gammon

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

Posted by Karl_Newbie   USA  (23 posts)  Bio
Date Reply #2 on Tue 08 Jun 2004 06:36 PM (UTC)
Message
Works perfectly. I copied the idea for making multiple variables for other objects by turning the by turning on and off sword: * bottle * triggers. Thanks
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.


10,537 views.

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.