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 ➜ VBscript ➜ Variable addition

Variable addition

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


Posted by Mezekht   (3 posts)  Bio
Date Tue 28 Dec 2004 08:55 PM (UTC)
Message
I am trying to write a script that will count how many potions I quaff, and if that number exceeds 7, "Drink Mystical". The trigger is Quaff * *. I have tried a number of different things, but can't get the script to work. Any help would be greatly appreciated. My variable is thus far entitled HealNumber.
Top

Posted by Hoss   USA  (48 posts)  Bio
Date Reply #1 on Tue 28 Dec 2004 10:29 PM (UTC)
Message
I would just make a trigger that matches on Quaff * *
then set it to send to script and have it do this

world.setvariable "quaff", Cint(getvariable("quaff")) +1

if world.getvariable ("quaff") >= 7 then
world.send "Drink Mystical"
world.setvariable "quaff", Cint(getvariable("quaff")) -1
end if

All this does is each time it matches on Quaff * * it'll add on to the variable and when it reaches 7 or 7+ then it will drink mystical and then decreases the number of quaff by one if you need to time it out you could just a world.DoAfter and that would add a simple timer to it.

Hoss
Top

Posted by Mezekht   (3 posts)  Bio
Date Reply #2 on Tue 28 Dec 2004 11:01 PM (UTC)
Message
sub QuaffCount(strTriggerName, trig_line, arrWildCards)
world.setvariable "quaff", Cint(getvariable("quaff")) +1

if world.getvariable ("quaff") >= 7 then
world.send "Drink Mystical"
end if


end sub

The trigger is:

Quaff * *

I have it set to send to script QuaffCount, it is enabled. Script is also enabled.
Quaff Heal-Potion Skin-Pouch appears on the screen, but nothing happens, it doesn't define the variables or anything at all. I am sure there is a very simple explanation and I am retarded.
Top

Posted by Poromenos   Greece  (1,037 posts)  Bio
Date Reply #3 on Tue 28 Dec 2004 11:41 PM (UTC)

Amended on Tue 28 Dec 2004 11:44 PM (UTC) by Poromenos

Message
Bah matt :P

if world.getvariable ("quaff") >= 7 then
world.send "Drink Mystical"
world.setvariable "quaff", "0"
end if
world.send "quaff potion container"
Remove it from the trigger box, you're probably sending to output.

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

Posted by Poromenos   Greece  (1,037 posts)  Bio
Date Reply #4 on Wed 29 Dec 2004 12:19 AM (UTC)
Message
Oh yeah, make an alias, not a trigger :p

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

Posted by Mezekht   (3 posts)  Bio
Date Reply #5 on Wed 29 Dec 2004 08:46 AM (UTC)
Message
Nods, it works great as an alias. Out of curiosity, I have some other triggers/aliases that world.send a lot of Quaff thisorthat, is there a way to send it to the mud and make the alias fire? If not I will just change them all around.
Top

Posted by Poromenos   Greece  (1,037 posts)  Bio
Date Reply #6 on Wed 29 Dec 2004 12:08 PM (UTC)
Message
Hm, no, send just sends it. If you had world.execute you could make a quaff alias, but it's better if you just change them all.

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

Posted by Aheram   (23 posts)  Bio
Date Reply #7 on Sun 02 Jan 2005 09:40 AM (UTC)
Message
Ooh! Cool. You learn something new everyday! I just used what I learned from this thread and made a simple Delayed Fireball counter!
Top

Posted by Aheram   (23 posts)  Bio
Date Reply #8 on Sun 02 Jan 2005 10:24 AM (UTC)
Message
And now, I have a question.

Since I am able to count how many Delayed Fireballs I have created and also able to calculate how long spells last, I am wondering if I can bring those two together and be able to figure out how long Delayed Fireballssss (emphasis on the plural!) are going to last?

Hm hm! Let me do it in steps!

1) "^(You|> You) feel a small stone materalise\.$"

A trigger will match on that and do "world.setvariable "delayed", Cint(getvariable("delayed")) +1" and "world.setvariable "SpellDelayedTimer", now".

NOW, if I am only casting one Delayed Fireball, I will be fine. I can just set an alias that displays a variable of the result of "CLng(GetVariable("SpellDelayedDuration"))-CLng(Datediff("s", getvariable("SpellDelayedTimer"), now))", except I will be casting more than one! I want this alias to be able display the time left of the OLDEST Delayed Fireball. If the oldest one disappears, I want this alias then to display the time left for the next oldest one. :(
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #9 on Sun 02 Jan 2005 12:06 PM (UTC)
Message
Youll just need to store multiple values for the different fireball instances. The easiest way to do it (as it will be a dynamic size) would probably be to use an array. Then just use the first value (or last), and delete it when its done.

First would mean more proccessing as they expire (having to re-key things as 2 becomes 1, 3 becomes 2 etc) while last would mean having to renumber when casting (because you'll have to do the opposite, 2 becomes 3, 1 becomes 2, your new time becomes 1).

The opposites of both are simple: either adding or subtracting from the end.

That is of course, if you were using MC arrays. If you wanted to use a VBScript array, you could use push/shift or pop/unshift.

You'd just have to write that VB array to a MC variable if you wanted it saved.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Aheram   (23 posts)  Bio
Date Reply #10 on Sun 02 Jan 2005 08:02 PM (UTC)
Message
Wow. I understood none of that! I guess I have to wait until I am a bit more experienced and knowledgeable before I attempt to do that. 15 days of experience is not enough! Haha.

I have a question. Anyone know how to force the client to give me only XX.XXX after it does CL/CL*100? I know there is a limit, since it starts rounding it up at the 13th decimal... thingy (forgot what these things are called!).
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #11 on Sun 02 Jan 2005 08:31 PM (UTC)
Message
FormatNumber(Expression [,NumDigitsAfterDecimal [,IncludeLeadingDigit [,UseParensForNegativeNumbers [,GroupDigits]]]])
Check out the Script Docs for more information.

FormatNumber(Number,3,-1)
Actually, since you have a percentage, you might try checking out FormatPercent as well.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Aheram   (23 posts)  Bio
Date Reply #12 on Sun 02 Jan 2005 09:40 PM (UTC)
Message
I see... where would I plug this in then?
Top

Posted by Aheram   (23 posts)  Bio
Date Reply #13 on Sun 02 Jan 2005 10:01 PM (UTC)
Message
Never mind. I got it.

world.setvariable "testresult2", FormatPercent(GetVariable("Testresult2"))
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.


35,512 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.