i posted a beta of this code on another forum, yet i am pretty sure it did not work, wonder if this works and how can it be improved. first we need 3 states, one state will be sued to reset the counter, the second state is used to do the counting (and perform any action you need the loop for), and the third is used to stop the loop for one tick. Again, mugen pseudo code because mugen code takes long to write:
Spoiler, click to toggle visibilty
statedef 1; this is where the loop starts and we reset the var
trigger1 =1
varset(0) = 0
trigger1 =1
changestate
value = 2
statedef 2; this is where the counting is done
perform action that uses the counting var
varset(0) = var(0) +1; increase the var
trigger1= var(0)< limit
changestate
value = 2; change back to this state if the loop is not yet over
trigger1= var(0)>=limit
var(1)=gametime;trick to avoid crashing mugen by having infinite loops
trigger1= var(0)>=limit
changestate
value = 3
statedef 3; end f the loop
trigger1 = var(1) < gametime
changestate
value = 1; restart the loop
if you are familiar/use rgular coding structures in mugen, it would be ncie if you post your code snippets.
and here is an actual mugen implementation
Spoiler, click to toggle visibilty
;
;
;straight horizontal projectile 2000
;
;debil
[StateDef 2005]
[State count]
type = varSet
trigger1 = 1
var(40) = 0
[State -1]
type = ChangeState
value = 2006
trigger1 = 1
[StateDef 2006]
[State esp]
Type = Helper
Trigger1 = 1;AnimelemTime(7) = 1
helperType = normal
name = "projectile"
ID = stateno
pos = AnimelemTime(7)*100 ,-30* var(40)
posType = p1;p2,front,back,left,right
facing = 1
StateNo = ( StateNo - ( StateNo % 50) )+ 30
keyctrl = 0
ownpal = 1
supermoveTime = 1
pausemoveTime = 1
size.xscale = 1
size.yscale = 1
size.ground.back = 21
size.ground.front = 14
size.air.back = 16
size.air.front = 18
size.height = 1
size.proj.doscale = 1
size.head.pos = -6,-5
size.mid.pos = -5,-62
size.shadowoffset = 1
[State count]
type = varSet
trigger1 = 1
var(40) = var(40) +1; increase the var
[State -1]
type = ChangeState
value = 2006
trigger1= var(40)< 5; change back to this state if the loop is not yet over
[State count]
type = varSet
trigger1 = var(40) >=5
var(41) = gametime;trick to avoid crashing mugen by having infinite loops
[State -1]
type = ChangeState
value = 2007
trigger1 = var(40) >=5
[StateDef 2007]
[State -1]
type = ChangeState
value = 2000
Trigger1 = AnimelemTime(7) > 2
[State -1]
type = ChangeState
value = 2005
trigger1 = var(41) < gametime
[StateDef 2000]
Type = S
moveType = A
physics = S
ctrl = 0
poweradd = 0
juggle = 10
facep2 = 1
hitdefpersist = 0
movehitpersist = 0
hitcountpersist = 0
sprpriority = 2
[State Vel ]
Type = VelSet
Trigger1 = !Time && Anim != StateNo
X = 0
Y = 0
[State Anim ]
Type = ChangeAnim
trigger1 = !time && Anim != StateNo
Value = StateNo
[State esp]
Type = StateTypeSet
Trigger1 = !AnimelemTime(9)
stateType = C
moveType = I
physics = C
[State esp]
Type = ChangeState
Trigger1 = AnimTime = 0
Value = 0
ctrl = 1
[State esp]
Type = PowerAdd
Trigger1 = NumHelper(stateno)
Trigger1 = Helper(stateno),movecontact
Value = 100
persistent = 0
[State esp]
type = ChangeState
value = 2005
Trigger1 = AnimelemTime(7) = 1
;projectile
[StateDef 2030]
Type = S
moveType = A
physics = N
ctrl = 0
poweradd = 0
juggle = 10
facep2 = 0
hitdefpersist = 0
movehitpersist = 0
hitcountpersist = 0
sprpriority = 3
[State InitVel]
Type = VelAdd
Trigger1 = !AnimelemTime(1)
X = 2.5
[State Anim ]
Type = ChangeAnim
trigger1 = !time && Anim != StateNo
Value = StateNo
[State ProjEsp ]
Type = AssertSpecial
Trigger1 = 1
flag = noshadow
[State projEsp]
Type = VelSet
Trigger1 = 0;!AnimelemTime(7)
X = 0
[State nextState ]
Type = ChangeState
Trigger1 = movecontact ;|| AnimTime = 0
Value = StateNo+1
[State hit ]
Type = Hitdef
Trigger1 = AnimelemTime(2) = 1
attr = C, SP
hitflag = MAF
guardflag = M
affectteam = E
AnimType = Back
air.AnimType = back
fall.AnimType = back
priority = 3,Hit
damage = Floor(Parent,Fvar(0)*Parent,Fvar(1)*20), 0
pauseTime = Floor(Parent,Fvar(3)*1),Floor(Fvar(3)*12)
guard.pauseTime = Floor(Parent,Fvar(3)*1), Floor(Fvar(3)*10)
sparkno = 0
guard.sparkno = 40
sparkxy = 16, -36
hitsound = 5, 0
guardsound = 6, 0
ground.Type = Low
air.Type = High
ground.slideTime = 16
guard.slideTime = 16
ground.hitTime = Floor(Parent,Fvar(4)*32)
guard.hitTime = Floor(Parent,Fvar(4)*32)
air.hitTime = Floor(Parent,Fvar(4)*13)
guard.ctrlTime = 0
airguard.ctrlTime = 99999999
guard.dist = 50
yaccel = 0.58333333
ground.velocity = -3.4444446563721
guard.velocity = -3.4444446563721
air.velocity = -3.4444446563721, -12.0500001907349
airguard.velocity = -3.4444446563721, -12.0500001907349
ground.cornerpush.veloff = 0
down.cornerpush.veloff = 0
air.cornerpush.veloff = 0
guard.cornerpush.veloff = 0
airguard.cornerpush.veloff = 0
air.juggle = 0
sprpriority = 2
;p1facing = -1
p1getp2facing = 0
;p2facing = -1
;p1StateNo =
p2StateNo = 5610
p2getp1state =1
;mindist =
;maxdist =
;snap =
forcestand = 0
fall = 0
fall.xvelocity = 0
fall.yvelocity = 0
fall.recover = 0
fall.recoverTime = 9
fall.damage = 0
air.fall = 1
down.velocity = 0
down.hitTime = 9
down.bounce = 0
id = 0
chainID = -1
nochainID = -1,-1
hitonce = 1
kill = 1
guard.kill = 1
fall.kill = 1
numhits = 1
getpower = Floor(Parent,Fvar(5)*64), Floor(Parent,Fvar(5)*64)
givepower = 20, 10
attack.width = 5,5
palfx.Time = 9
palfx.mul = 256,256,256
palfx.add = 0,0,0
;envshake.Time = 7
;envshake.freq = 20
;envshake.ampl = -2
;envshake.phase = 0
;fall.envshake.Time = 7
;fall.envshake.freq = 20
;fall.envshake.ampl = -2
;fall.envshake.phase = 0
[StateDef 2031]
Type = S
moveType = A
physics = N
ctrl = 0
poweradd = 0
juggle = 10
facep2 = 0
hitdefpersist = 0
movehitpersist = 0
hitcountpersist = 0
sprpriority = 3
[State Anim ]
Type = ChangeAnim
trigger1 = !time && Anim != StateNo
Value = StateNo
[State ProjEsp ]
Type = AssertSpecial
Trigger1 = 1
flag = noshadow
[State Bye ]
Type = destroyself
Trigger1 = AnimTime = 0