[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Help with creating multiple variables via trigger
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Help with creating multiple variables via trigger

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


Posted by Karl_Newbie   USA  (23 posts)  [Biography] 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
[Go to top] top

Posted by Nick Gammon   Australia  (21,607 posts)  [Biography] 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
[Go to top] top

Posted by Karl_Newbie   USA  (23 posts)  [Biography] 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
[Go to top] 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.


2,794 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]