Counter for draining power

by Unknown

Back to Mechanic's Corner.

Unknown2005-01-30 12:16:48
Can anyone give me some tips as to how to design a counter where I automatically unlink after a set number of times?

Thanks,

Anon
Vesar2005-01-30 14:44:24
Well, I'd just create a variable for the number of power "pulses" you've gotten. Trigger the text for a "pulse" from whatever sources you use and increment your counter. After each pulse, check to see if your counter is less that whatever number you specify before you start. If you reach that number, have it sever your link with a quick #IF statement. Something like #IF (@Counter >= @PulseCount) {unlink node;#var Counter 0;#var PulseCount 0}.
Gwylifar2005-01-30 22:37:05
You can save a variable by simply having one variable, "PointsLeft" and decrementing it until it's 0. Mathematically the same, but one less moving part. Also works better if you ever have it break and then resume. I use the same mechanism for spending lots of lessons.
Faethan2005-01-31 00:31:14
#ALIAS {link} {LINK MOTHER
#VAR linkcount %1}

#TRIGGER {power drain message goes here} {#Var linkcount (@linkcount - 1)
#IF (@linkcount = 0) {UNLINK MOTHER}
}
Vesar2005-01-31 01:12:26
QUOTE(Faethan @ Jan 30 2005, 07:31 PM)
#ALIAS {link} {LINK MOTHER
#VAR linkcount %1}

#TRIGGER {power drain message goes here} {#Var linkcount (@linkcount - 1)
#IF (@linkcount = 0) {UNLINK MOTHER}
}
39389



Correct me if I'm wrong, but won't that be an infinate loop with LINK? I used linkpower as my alias.
Unknown2005-01-31 05:14:08
Yes, it would be an infinite loop. That would be bad.
Faethan2005-01-31 05:56:33
yeah, don't listen to me then.
Unknown2005-01-31 08:51:45
Just put a tilde before the "link" in the alias to prevent it from firing the alias again:

CODE
#ALIAS {link} {~LINK MOTHER
#VAR linkcount %1}

#TRIGGER {power drain message goes here} {#Var linkcount (@linkcount - 1)
#IF (@linkcount = 0) {UNLINK MOTHER}
}
Unknown2005-01-31 11:38:55
Guys, use "nexus" instead of "mother". Or instead of the item id, or whatever. Just "nexus". It works 100% of all times, whereas using the item ID will mess you up if you draw power from the other side of your adjacent plane, and mother will mess you up, well, whenever someone walks in with a mother fae trailing behind.
I've seen too many people who've overdrawn because of that wacko.gif
Gwylifar2005-01-31 13:43:14
And "tree" messes up if someone calls a dryad tree, but "nexus" always works.

The ~ trick works to avoid the loop, but personally I just called my alias "linknexus".

Finally, replace that #var command with:
#add linkcount -1
Unknown2005-02-01 08:22:57
Or you could just make a trigger for when you start to drain power, rather than an alias.
Vesar2005-02-01 16:01:33
QUOTE(David @ Jan 31 2005, 06:38 AM)
Guys, use "nexus" instead of "mother". Or instead of the item id, or whatever. Just "nexus". It works 100% of all times, whereas using the item ID will mess you up if you draw power from the other side of your adjacent plane, and mother will mess you up, well, whenever someone walks in with a mother fae trailing behind.
I've seen too many people who've overdrawn because of that  wacko.gif
39573



Does that also work for astral nodes? I use an alias like "linkpower node 5" and it uses whatever you put in for "node" as the link source.