News:

MFG's Character of the Month: October 2026 Nominations

Main Menu

Integer and Float

Started by Fixer, July 27, 2016, 03:37:54 PM

Previous topic - Next topic

Fixer

I am having the "expression truncated to integer" error in the console, and i saw in a very old topic the solution for it where it says that i have to floor or ciel the expression, but where exactly in the code should i add the floor or ciel?
This is one of the codes that needs this fix i think, so how would the code looks like after the process?

[State -2, 0]
Type = VarSet
TriggerAll = Var(59)
TriggerAll = RoundState = 2
TriggerAll = NumHelPer(35000) > 0
TriggerAll = StateNo != [120,155]
TriggerAll = GetHitVar(Damage) = 0
TriggerAll = MoveType = H
TriggerAll = Var(57) = 0
TriggerAll = Var(56) = 0
Trigger1 = HelPer(35000),Var(17) = [1,2]
Trigger1 = HelPer(35000),Var(1) = 1
Trigger1 = HelPer(35000),Var(0) = [1,2]
V = 57
Value = EnemyNear(fvar(37)),PrevStateNo
IgnoreHitPause = 1

Chronan

EnemyNear(fvar(37)) is your problem from the looks of things. EnemyNear expects an INT value but you are feeding it a FLOAT, so it is truncating off those extra digits.

Changing it to:
EnemyNear(ciel(fvar(37)))
-or-
EnemyNear(floor(fvar(37)))

should stop your debug flood.

Fixer

#2
Well, ive set floor in that case but it still the same, maybe i have to do that in other states too... i need to set that only in the "Value = x" part or also in places like this: ?

[State 0, VarSet]
type = VarSet
Triggerall = fvar(36) = 0               <--------should be "floor(fvar(36)" ?
trigger1 = Palno = 4
fvar(36) = 1
ignorehitpause = 1

And also in the VarAdd?

Jesuszilla

You don't have to in places like that, oddly enough. I get away with it all the time. But it may be safer to do it the way you're talking about because floats are not perfect when it comes to hard equality.

Fixer

Another char have this same error but it dont have any fvar, also in the varset it only have the sysvar, so what i need to do?

Cyanide

Does any value turn into a non decimal? For example if you do the math do or can you get a value like

1.3947

For example. If you have that, but the code expects a set value, as varsets, or possets, or posadds do, you need to floor/ciel the value and mugen will no longer throw an error.

If you're not sure what to do as per the post above, please post the code. Right now the best we can say is "add floor or ciel to it" and hope you know what you're doing.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.

Fixer

#6
It dont send any value like that and the code looks perfect but i can put ceil and floor everywhere but it still send the messages, i solved this problem in another really complex char but in that char which is kinda old it seens to be impossible, can i send you the code via PM? coz as i don't know the part which is causing the problem, so i would have to send the whole code?

Cyanide

Mugen will be telling you where the fault is. Find that code block and post it. We certainly don't need everything and for this type of issue mugen will tell you exactly where to look. It's always expression truncated to integer in state blah.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.

Fixer

Well, the state of the debug change as a move, so it's in every state?!
Here is one of them:
Spoiler (click to show)
;-----------------------------------
;Punch 1(stand)------------------------
[Statedef 200]
type = S
physics = S
movetype = A
juggle = 1
ctrl = 0
poweradd = 20
anim = 200
sprpriority = 2

[State 200, 1]
type = HitDef
trigger1 = AnimElem = 3
trigger2 = AnimElem = 4
trigger2 = AnimElem != 3
attr = S, NA
damage = 24, 5
animtype = Light
guardflag = MA
hitflag = MAF
priority = 4, Hit
pausetime = 8, 10
sparkno = s845
sparkxy = -13, -73
hitsound = s6, 1
guardsound = s9, 0
guard.sparkno  = s855
ground.type = Low
ground.slidetime = 5
ground.hittime  = 10
ground.velocity = -2
air.velocity = -1,-.8
air.hittime = 12
yaccel = .5

[State 200, 2]
type = PlaySnd
trigger1 = Time = 1
value = 15,1

[State 200, 2]
type = PlaySnd
trigger1 = Time = 1 && Random <= 499
value = 16,0

[State 200, 3]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1
;-------------------------------------------;

Cyanide

Ok, it's state -2 or -1 or -3 in that case. Not uncommon.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.

Fixer

Oh, so it's always related with that states, this makes things much easier to me, the char dont have the -1 state, here are the others:
-3:
Spoiler (click to show)
;============================================
;State -3
;==========================================================

[Statedef -3]

[state -3, GameTime Variable]
Type = VarSet
trigger1 = 1
var(1) = gametime

[State -3, Landing Sound]
type = PlaySnd
triggerall = Time = 1
trigger1 = stateno = 52
trigger2 = stateno = 106
value = 5, 0

[State -3, Jump sound]
type = PlaySnd
triggerall = Time = 1
trigger1 = stateno = 40
value = 4, 0

[State -3, Sky Jump sound]
type = PlaySnd
triggerall = Time = 1
trigger1 = stateno = 46
trigger2 = stateno = 47
trigger3 = stateno = 48
value = 4, 1
volume = 8

[State -3, BackDash Sound]
type = PlaySnd
triggerall = Time = 1
trigger1 = stateno = 105
value = 5, 0

[State -3, ryuuko slide]
type = ChangeState
value = 3080
trigger1 = prevstateno = 3050
trigger1 = stateno = 52

[State -3, ryuuko finish]
type = ChangeState
value = 3280
trigger1 = prevstateno = 3260
trigger1 = stateno = 53

[State -3, ryuuko Recharge]
type = ChangeState
value = 991
trigger1 = prevstateno = 3280
trigger1 = stateno = 53

[State -3, stopintrosnd]
type = StopSnd
channel = 5
trigger1 = stateno != 190

[State -3, stopintrosnd2]
type = StopSnd
channel = 6
trigger1 = stateno != 190

[State -3, stopintrosnd2]
type = StopSnd
channel = 7
trigger1 = stateno != 190

[State -3, stopintrosnd2]
type = StopSnd
channel = 8
trigger1 = stateno != 190
-2:
Spoiler (click to show)
[StateDef -2] ;==================================================

[State -2, Debug Data]
type = DisplayToClipboard
trigger1 = 1
text = "P2BodyDist X = %f,P2Dist Y = %f,P2Vel Y = %f,P2Vel X = %f,JuggleVar = %d"
params = P2BodyDist X,P2Dist Y,(enemynear, Vel Y),(enemynear, Vel X),var(6)

[state -2, custom state check]
Type = VarSet
trigger1 = 1
var(2) = floor(var(1)) = gametime

[State -2, Charge Interrupt]
type = StopSnd
channel = 1
trigger1 = var(2) = 0

[State -2, Charge Interrupt]
type = StopSnd
channel = 2
trigger1 = var(2) = 0

[State -2, Charge Interrupt]
type = StopSnd
channel = 3
trigger1 = var(2) = 0

[State -2, Charge Interrupt]
type = RemoveExplod
ID = 816
trigger1 = var(2) = 0

[State -2, Charge Interrupt]
type = RemoveExplod
ID = 815
trigger1 = var(2) = 0
trigger1 = Time = 2
trigger1 = NumExplod(815) = 1
trigger2 = var(2) = 0
trigger2 = Time = 2
trigger2 = NumExplod(805) = 1

[State -2, Charge Interrupt]
type = Explod
anim = 825
ID = 825
sprpriority = 3
postype = p1
pos = -5, 10
bindtime = 1
trigger1 = var(2) = 0
trigger1 = NumExplod(815) = 1
trigger1 = Time = 1
trigger2 = var(2) = 0
trigger2 = NumExplod(805) = 1
trigger2 = Time = 1

[State -2, Haoh - Ken Juggle System]
type = Explod
ID = 803
anim = 803
triggerall = NumHelper(1200) >= 1
trigger1 = p2stateno = 5000
trigger2 = p2stateno = 5010
trigger3 = p2stateno = 5020

[State -2, Haoh - Ken Juggle System]
type = Explod
ID = 803
anim = 803
triggerall = NumHelper(1210) >= 1
trigger1 = p2stateno = 5000
trigger2 = p2stateno = 5010
trigger3 = p2stateno = 5020

[State -2, initiate bar drain]
type = PowerAdd
value = -17
trigger1 = NumExplod(804) >= 1

[State -2, stop bar drain]
type = RemoveExplod
ID = 804
trigger1 = NumExplod(804) >= 1
trigger1 = Power = 0

[State -2, MatchWon]
type = helper
trigger1 = win && matchover
trigger1 = Anim = 180
trigger1 = AnimElem = 7
trigger1 = PalNo = 1
helpertype = normal
name = "MatchWon"
stateno = 700
persistent = 0

[State -2, MatchWon]
type = helper
trigger1 = win && matchover
trigger1 = Anim = 180
trigger1 = AnimElem = 7
trigger1 = PalNo = 2
helpertype = normal
name = "MatchWon"
stateno = 701
persistent = 0

[State -2, MatchWon]
type = helper
trigger1 = win && matchover
trigger1 = Anim = 180
trigger1 = AnimElem = 7
trigger1 = PalNo = 3
helpertype = normal
name = "MatchWon"
stateno = 702
persistent = 0

Chronan

Your -1 states are in the CMD. But you may not need to check there, as I think I see the issue:

Either delete this whole state controller below:
[State -2, Debug Data]
type = DisplayToClipboard
trigger1 = 1
text = "P2BodyDist X = %f,P2Dist Y = %f,P2Vel Y = %f,P2Vel X = %f,JuggleVar = %d"
params = P2BodyDist X,P2Dist Y,(enemynear, Vel Y),(enemynear, Vel X),var(6)

Or replace it with:
[State -2, Debug Data]
type = DisplayToClipboard
trigger1 = 1
text = "P2BodyDist X = %f,P2Dist Y = %f,P2Vel Y = %f,P2Vel X = %f,JuggleVar = %d"
params = P2BodyDist X,P2Dist Y,(enemynear, ceil(Vel Y)),(enemynear, ceil(Vel X)),var(6)

Display to Clipboard is typically used to debug values/logic, it won't change anything in the character by not having it unless the trigger is assigning values to variables(its not). So the code is not needed. But a problem there is "enemynear",which expects an INT, is getting float values(velocities are floats). So I'd imagine the debug flood, at least partly occurs whenever the character moves.

If that doesn't fix it, then the [-1] states in the CMD might be useful in case there is variable assignment happening in there or just triggers like enemynear, Vel Y.

Jesuszilla

Uh, %f stands for float. You don't (and shouldn't) ceil or floor those.

Also this:
[state -2, custom state check]
Type = VarSet
trigger1 = 1
var(2) = floor(var(1)) = gametime


Is stupid and redundant. You don't have to floor an integer variable.

Chronan

Uh, I was reading it like this:
enemynear(Vel Y)
whatever that could mean, rather than:
enemynear, Vel Y
Uh, my mistake.

Fixer

Problem solved guys, the statedef -1 was also causing the flood, i love that char, that's why i was insisting on it. Thanks a lot for the help.