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 ➜ Variables

Variables

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


Posted by Matthias   (28 posts)  Bio
Date Wed 08 Oct 2003 08:54 PM (UTC)
Message
Ok, how would I make it so that when a trigger is matched, it increases variable X by one point?

Give a man a fire and you warm him for a day.
Set a man on fire and you warm him for the rest of his life.
Top

Posted by Ked   Russia  (524 posts)  Bio
Date Reply #1 on Thu 09 Oct 2003 12:40 AM (UTC)
Message
Heh, I hope you aren't trying to make a curing system without using a script file. I would stronly advise against trying. If you have a script file already then I'd suggest moving from MC variables to script ones - that's become the general rule of thumb for Rapture curing scripts.
You'll soon bump into the limitations of herb based lists of afflictions (bloodroot = 2, goldenseal = 5, etc.), one of the biggest of which being that they are very hard to prioritize. As soon as you do, you'll be forced to use internal script variables for actual afflictions (paralysis = vbTrue, stupidity = vbTrue, etc), unless you want to litter your script with insane amounts of callbacks:


dim stupidity
 ...
if stupidity then
  cureit
end if


versus:


if cint(world.GetVariable("Stupidity")) then
 cureit
end if


MC variables are good for storing data between sessions or making the data in the main script visible to the plugins, or small tasks that you are sure won't grow into something as large and speed-reliant as keeping track of dozens of afflictions and parsing through them every second. Learn to use script variables before it's too late and you don't have too much code to rewrite ;)

If you are still not convinced, here's a way of doing what you asked about with MC variables and in-trigger scripting.

Put the following into your trigger's "Send" box and select "Script from the "Send to" foldout:


dim tempVar
tempVar = cint(world.GetVariable("varName"))
tempVar = tempVar + 1
world.SetVariable "varName", cstr(tempVar)


Though even writing that makes my heart bleed... For comparison, here's how it could be done in a script file:


'Declare an affliction variable, this is done once
'for all afflictions near the beginning of a script file
dim brootVariable

'This is a sub called by your trigger
'
sub IncrementVariable (name, output, wildcs)
'Figure out which variable this trigger increments from its' name
 select case name
  case "broot_trigger"
   brootVariable = brootVariable + 1
 end select
end sub


However, this isn't any good either, since if you get paralysis twice in a row it'll increment the brootVariable by 2, making you cure it twice, which is yet another major limitation of herb queues - you never have an easy way of telling what's already there and what's not. Herb queueing is a silly zMud practice that no one should get too far into. So... store afflictions, not cures. Ok, enough of my ranting. Good luck.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #2 on Thu 09 Oct 2003 10:16 PM (UTC)
Message
Quote:

Put the following into your trigger's "Send" box and select "Script from the "Send to" foldout:


dim tempVar
tempVar = cint(world.GetVariable("varName"))
tempVar = tempVar + 1
world.SetVariable "varName", cstr(tempVar)


You can shorten that a bit ...


SetVariable "varName", CInt (GetVariable("varName")) + 1

- Nick Gammon

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

Posted by Matthias   (28 posts)  Bio
Date Reply #3 on Fri 10 Oct 2003 04:08 AM (UTC)
Message
O_o Are you psychic, Ked? If ye are, do what I'm thinking. If not, please exlpain what all that ranting meant. :)

Give a man a fire and you warm him for a day.
Set a man on fire and you warm him for the rest of his life.
Top

Posted by Ked   Russia  (524 posts)  Bio
Date Reply #4 on Fri 10 Oct 2003 04:39 AM (UTC)
Message
Well, I am not a psychic, but judging from your previous posts and the recent one about incrementing variables I made a wild guess that you are trying to make a herb queue, which isn't a good idea in my opinion. If my guess was right, then you can post what you've already done so far and I'll try to give more specific help. If it was wrong, well... doh. You can still use that last line of Nick's post.


Top

Posted by Gore   (207 posts)  Bio
Date Reply #5 on Sat 10 Jan 2004 10:13 AM (UTC)
Message
================================================

However, this isn't any good either, since if you get paralysis twice in a row it'll increment the brootVariable by 2, making you cure it twice, which is yet another major limitation of herb queues - you never have an easy way of telling what's already there and what's not. Herb queueing is a silly zMud practice that no one should get too far into. So... store afflictions, not cures. Ok, enough of my ranting. Good luck.

================================================

Just a head's up, on ZMud, I used a method of checking what afflictions I had, I.E. when my curare trigger fired, it'd be something like..

if paralysis = 0 then
paralysis = paralysis + 1
call queue_sub_routine
elseif paralysis = true then
call queue_sub_routine
end if

Note, this isn't exact to syntax, but rather, that'd how I dealth with inrementing, so you don't over increment.

Hope this helps (although this is a bit late for a post heh)
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.


18,445 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.