Variables

Posted by Matthias on Wed 08 Oct 2003 08:54 PM — 6 posts, 24,177 views.

#0
Ok, how would I make it so that when a trigger is matched, it increases variable X by one point?
Russia #1
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.
Australia Forum Administrator #2
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
#3
O_o Are you psychic, Ked? If ye are, do what I'm thinking. If not, please exlpain what all that ranting meant. :)
Russia #4
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.


#5
================================================

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)