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.
 Entire forum ➜ MUSHclient ➜ General ➜ Belt system

Belt system

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


Pages: 1 2  

Posted by Zendu   (66 posts)  Bio
Date Thu 13 May 2004 11:15 AM (UTC)
Message
I give up!


world.DeleteVariable ("count-ash") & world.DeleteVariable ("count-kelp") & world.DeleteVariable ("count-bayberry") & world.DeleteVariable ("count-kola") & world.DeleteVariable ("count-bellwort") & world.DeleteVariable ("count-Lobelia") & world.DeleteVariable ("count-bloodroot") & world.DeleteVariable ("count-moss") & world.DeleteVariable ("count-cohosh") & world.DeleteVariable ("count-pear") & world.DeleteVariable ("count-elm") & world.DeleteVariable ("count-skullcap") & world.DeleteVariable ("count-enchinacea") & world.DeleteVariable ("count-sileris") & world.DeleteVariable ("count-ginsing") & world.DeleteVariable ("count-valerian") & world.DeleteVariable ("count-goldenseal") & world.DeleteVariable ("count-weed") & world.DeleteVariable ("count-hawthorn") & world.DeleteVariable ("count-Leather") & world.DeleteVariable ("count-Coal") & world.DeleteVariable ("count-Obsidian") & world.DeleteVariable ("count-Cloth") & world.DeleteVariable ("count-Rope") & world.DeleteVariable ("count-Gold") & world.DeleteVariable ("count-Silver") & world.DeleteVariable ("count-Ice") & world.DeleteVariable ("count-Steel") & world.DeleteVariable ("count-Iron") & world.DeleteVariable ("count-Wood") & world.DeleteVariable ("count-stag") & world.DeleteVariable ("count-yellow") & world.DeleteVariable ("count-red") & world.DeleteVariable ("count-gold") & world.DeleteVariable ("count-green") & world.DeleteVariable ("count-blue") & world.DeleteVariable ("count-purple")
world.Send "p pocketbelt19630"
world.Send "p pocketbelt131810"
world.Send "p pocketbelt131999"
world.Send "p pocketbelt132009"
world.Send "p pocketbelt131215"
world.Send "p pocketbelt87258"
world.Send "p pocketbelt25680"
world.Send "p pocketbelt86557"
world.Send "p pocketbelt130587"
world.Send "p pocketbelt68619"
world.Note "herbs:" & GetVariable ("count-ash") & GetVariable ("count-kelp") & GetVariable ("count-bayberry") & GetVariable ("count-kola") & GetVariable ("count-bellwort") & GetVariable ("count-Lobelia") & GetVariable ("count-bloodroot") & GetVariable ("count-moss") & GetVariable ("count-cohosh") & GetVariable ("count-pear") & GetVariable ("count-elm") & GetVariable ("count-skullcap") & GetVariable ("count-enchinacea") & GetVariable ("count-sileris") & GetVariable ("count-ginsing") & GetVariable ("count-valerian") & GetVariable ("count-goldenseal") & GetVariable ("count-weed") & GetVariable ("count-hawthorn") & GetVariable ("count-Leather") & GetVariable ("count-Coal") & GetVariable ("count-Obsidian") & GetVariable ("count-Cloth") & GetVariable ("count-Rope") & GetVariable ("count-Gold") & GetVariable ("count-Silver") & GetVariable ("count-Ice") & GetVariable ("count-Steel") & GetVariable ("count-Iron") & GetVariable ("count-Wood") & GetVariable ("count-stag") & GetVariable ("count-yellow") & GetVariable ("count-red") & GetVariable ("count-gold") & GetVariable ("count-green") & GetVariable ("count-blue") & GetVariable ("count-purple")


This SHOULD delete, then add up the amount of herbs i have in my belts! [i have adding triggers, they work fine]

God im helpless
Currently using MushClient 3.46 on Win Xp pro on [url=www.aetolia.com]Aetolia[/url]
Top

Posted by Ked   Russia  (524 posts)  Bio
Date Reply #1 on Thu 13 May 2004 02:59 PM (UTC)
Message
The world.DeleteVariable&world.DeleteVariable&... doesn't make much sense. It should throw an error of some sort, I think. But in any case, why delete the variables when you can just set them to 0? And it would be much better to do this in a script file, using arrays or lists, or whatever your favourite language has to offer. An example is in yet another one of my plugins - RiftList, at www.darkfenixxx.biz/achaea.
Top

Posted by Poromenos   Greece  (1,037 posts)  Bio
Date Reply #2 on Thu 13 May 2004 05:15 PM (UTC)
Message
I don't know, I was making a plugin yesterday that was supposed to delete some variables, and I added notes to see what it was doing. It was deleting variables 1, 2 and 3, and adding a variable called 0. When i reloaded it, it still deleted 1, 2 and 3, which shouldn't have been there. Maybe it was my fault, but I just deleted the state file and reloaded it, and it works now. Maybe it has the same problem with you? Although I don't know how legal the stringing together commands with ampersands is.

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
Top

Posted by Zendu   (66 posts)  Bio
Date Reply #3 on Thu 13 May 2004 08:22 PM (UTC)
Message
so how do i set all those to 0? its also having problems with the world.note line (i know there are better ways to do this, however i realy wanted to try making this on my own)

God im helpless
Currently using MushClient 3.46 on Win Xp pro on [url=www.aetolia.com]Aetolia[/url]
Top

Posted by Shadowfyr   USA  (1,788 posts)  Bio
Date Reply #4 on Thu 13 May 2004 09:23 PM (UTC)

Amended on Thu 13 May 2004 09:26 PM (UTC) by Shadowfyr

Message
The problem with your note line is how and when things execute. Mushclient does not run script in parallel, so if you send a command to the mud inside of a script, the command isn't executed until after your script exits and returns control to Mushclient. So, what happens is that your note line gets sent, *then* all the commands you did with 'send' are executed and I assume triggers capture those and put them in variables.

There are two ways to fix this. One is to use a timer to delay when the note happens. In other words, you would use world.addtimer as a temporary timer, then have that call its own script containing your note line. The other way is to use some response from the mud, so if you know "p pocketbelt68619" would always produce some sort of unique response you could have the script for it generate your note instead.

I am posting a suggestion about something I think can stream line the issue with deleting or clearing variables, making it easiereasier in the future, but it may be a while before/if Nick impliments it.
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #5 on Thu 13 May 2004 10:45 PM (UTC)

Amended on Thu 13 May 2004 10:52 PM (UTC) by Nick Gammon

Message
Quote:

world.DeleteVariable ("count-ash") & world.DeleteVariable ("count-kelp") ...


This is not going to do what you expect.

By stringing together the deletes it is going to do something strange like this. Say you only had the first two like I have there.

It is trying to DeleteVariable a single variable named:

"count-ash" concatenated with world.DeleteVariable ("count-kelp")

Say that world.DeleteVariable ("count-kelp") works it will return "0" so the other Delete will try to delete:

"count-ash0"

which will not exist.

Thus, depending on the order of execution of the & things it will probably delete at most a single variable.

A simple loop might be better, like this:


varList = World.GetVariableList

If Not IsEmpty (varList) Then
  
  For Each v In varList 
    if Left (v, 6) = "count_" then
       world.DeleteVariable v
    end if
  Next

End If


This will delete all variables starting with "count_".

You could instead do:


  world.SetVariable v, "0"


if you wanted to just set them to zero.

Also, as I mentioned in a recent reply, you cannot have hyphens in variable names, so those variables won't exist anyway. Use underscores instead.

Also, Shadowfyr is right, sending stuff to the MUD and getting a reply takes a finite time, you cannot expect the trigger to fire while your "deletevariable" script is running - it won't.




- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #6 on Thu 13 May 2004 10:50 PM (UTC)
Message
A better way anyway might be to use the new "array" functions, which can store everything in an array.

eg.


ArrayCreate "herbs" ' make array

ArraySet "herbs", "ash", 22
ArraySet "herbs", "kelp", 5


... and so on.

Then to find a particular value you do this:


world.Note ArrayGet ("herbs", "ash")


To delete the lot just do:


ArrayClear "herbs"


Now that is simpler, isn't it?

The whole lot can be exported to a variable for next time like this:


SetVariable "herbs", ArrayExport ("herbs", ",")


This makes a single variable "herbs" with each value as a comma-delimited list of names/value pairs.

Read up on the array functions, I think they will make your life easier.

- Nick Gammon

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

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #7 on Fri 14 May 2004 01:09 AM (UTC)
Message
Also, your variable names cant have - (dash) in them. If you want a seperator, try an underscore (_).

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Zendu   (66 posts)  Bio
Date Reply #8 on Fri 14 May 2004 09:54 AM (UTC)
Message
so it should look like this
Clear:
ArrayClear "herbs"
(probe the belts)

ADD:
^(.*?) ash$
ArraySet "count", "ash", + %1

DELAY, THEN:
World.Note ArrayExport ("herbs", ",")



do i need the newest version of Mush to do this? mine doesnt recognize array commands

God im helpless
Currently using MushClient 3.46 on Win Xp pro on [url=www.aetolia.com]Aetolia[/url]
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #9 on Sat 15 May 2004 02:31 AM (UTC)
Message
Have a look at this page:

http://www.gammon.com.au/mushclient/function.php?name=ArrayGet

It mentions that you need version 3.46 or more.

- Nick Gammon

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

Posted by Zendu   (66 posts)  Bio
Date Reply #10 on Sun 16 May 2004 06:35 AM (UTC)

Amended on Sun 16 May 2004 09:15 AM (UTC) by Zendu

Message
how do i get all them?

DoAfter 1,
"herbs", ArrayExport ("herbs", ",")
world.Note GetVariable ("herbs"), 12





the trigger
ArraySet "herbs", "myrrh", + %1


seems to add the ammount, the whole goal in this is for it to add multiple lines like

154 myrrh
250 myrrh
250 myrrh

God im helpless
Currently using MushClient 3.46 on Win Xp pro on [url=www.aetolia.com]Aetolia[/url]
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #11 on Sun 16 May 2004 09:09 PM (UTC)
Message
I'm not sure I understand here. Was that one or two triggers, or a trigger and an alias? What gets sent by the MUD exactly? When do you want all of them? Little snippets like that are just confusing.

Quote:

ArraySet "herbs", "myrrh", + %1


This won't make much sense, all you are doing is setting something like (assumming %1 contains "50"):

ArraySet "herbs", "myrrh", + 50


That will just make myrrh 50, not the old value plus 50.

You want something like this to bump the amount, if that is what you are trying to do:


ArraySet "herbs", "myrrh", CInt (ArrayGet ("herbs", "myrrh")) + %1


That retrieves the old value and adds the new one to it.

- Nick Gammon

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

Posted by Zendu   (66 posts)  Bio
Date Reply #12 on Mon 17 May 2004 03:52 AM (UTC)
Message
My goal is one alias "belts" that

Clears the array herbs
then probes several pocketbelts(which displays alot of herbs like 250 myrrh,250 myrrh, 82 myrrh, 32 red ink etc etc)
The triggers are set to add those amount to the arrays.
Then i whould like the alias to display the total amounts. So i need a delay (i think?) so that it has time to do the adding

God im helpless
Currently using MushClient 3.46 on Win Xp pro on [url=www.aetolia.com]Aetolia[/url]
Top

Posted by Zendu   (66 posts)  Bio
Date Reply #13 on Mon 17 May 2004 04:08 AM (UTC)
Message
got everything working, but its in 2 aliases, now all i need is to put it on one

God im helpless
Currently using MushClient 3.46 on Win Xp pro on [url=www.aetolia.com]Aetolia[/url]
Top

Posted by Ked   Russia  (524 posts)  Bio
Date Reply #14 on Mon 17 May 2004 01:09 PM (UTC)
Message
A delay for the "probe belt" commands to produce output would be susceptible to lag. A better way would be to use triggers. If I remember correctly (haven't used pocketbelts in ages) then probing them gives you something like:

Your pocketbelt is holding:
100 myrrh, 25 ginseng, 30 goldenseal
10 bloodroot, 15 kelp, 29 valerian
H:2340, M:3400 ce-

All you'd need to do is make a trigger for the first line, a trigger for the prompt, and a regular expression trigger for the actual herbs. The first line trigger then could enable the herb trigger and the prompt trigger, and the prompt trigger would disable the herb one. That would work regardless of how bad the lag is, since it'll start counting the herbs only when you know that it's the actual pocketbelt you are looking at, and end counting them as soon as the pocketbelt output ends (with a prompt). That's how most of such systems work.
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.


57,859 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.