|
nazradin Apprentice
Joined: 23 Mar 2003 Posts: 114 Location: New Zealand
|
Posted: Mon Jul 12, 2004 5:12 pm
pulse timer question |
I am trying to make a timer that times when get a mana pulse untill the next pulse. This is for a simu game. The mana pulses come around every 2 minutes but have a 30 secnd variation in order to hinder mechanical abuse.
@mana is a game defined variable that i use to keep track of current mana
does the below look correct?
#CLASS {pulsetimer}
#ALARM "pulsetimer" {*1} {#IF (@pulsetimer >= 1) {#ADD pulsetimer +1}}
#ALARM "manacounter" {*1} {#VAR manacounter {%additem(%item @mana), @lastmana)};#if (@lastmana 2 > @lastmana 1) {pulsetime = 1};#DELN lastmana 1}
#class 0
cheers Naz |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Mon Jul 12, 2004 7:01 pm |
No, it doesn't look correct. %additem should have two arguments but you only have one. %item should be followed by two arguments but you don't have any. (@lastmana 2 > @lastmana 1) will parse as ((@lastmana) (2 > @lastmana) (1)), which will always be true and can't be what you want. You don't make any use of @manacounter, but it appears it might have been intended to be @lastmana. You never reduce the value of @pulsetimer.
The tick timer would probably be more accurate unless you are using it for something else.
#TS 120
#ALARM manapulse {*1} {#IF (@mana > @lastmana) {#TZ};#VAR lastmana @mana}
Putting this in a trigger which gets the value of @mana would be better than using #ALARM.
If the ticktimer is in use:
#ALARM manapulse {*1} {#IF (@mana > @lastmana) {#VAR pulsetime @pulsetimer;#VAR pulsetimer 1} {#ADD pulsetimer 1};#VAR lastmana @mana} |
|
|
|
nazradin Apprentice
Joined: 23 Mar 2003 Posts: 114 Location: New Zealand
|
Posted: Tue Jul 13, 2004 7:18 pm |
thanks lightbulb , the one using the tick timer stalled when the period was longer than 120, but the other version was more suited anyway as i can use a button display next to my other alarms so everything is close with a glance.
i was trying to make a var with 2 values , compare values then delete and replace, using different vars is much better.
thanks Naz |
|
|
|
|
|