YesNoOk
avatar

Avoiding warnings (CNS) (Read 3026 times)

Started by Just No Point, October 07, 2015, 02:22:13 pm
Share this topic:
Avoiding warnings (CNS)
#1  October 07, 2015, 02:22:13 pm
  • ******
    • www.justnopoint.com/
Several common error conditions often produce a flood of warnings in characters. Here are some of the most common scenarios and how to avoid them.

Coercion of floats to ints

If MUGEN expects an int somewhere (e.g., a var number), but a float is provided, then MUGEN will convert the int to a float. However, it will complain, because this may represent an error on your part. To get rid of the warning, indicate that you know what you are doing by supplying an explicit conversion to int with floor() or ceil().

Nonexistent trigger redirection targets

If you redirect to a target that doesn't exist, such as a helper when you don't have one, then bottom is produced and a warning is logged. This is because the expression is logically ambiguous. You can avoid the warning by checking for existence of the target before redirecting. So,

Code:
trigger1 = helper(1234), time > 20
would generate a warning if helper 1234 didn't exist, but

Code:
trigger1 = numhelper(1234) > 0
trigger1 = helper(1234), time > 20
would not. This is because the first trigger1 line causes evaluation to be aborted before attempting the redirection.

Alternatively, you can use the Cond trigger to isolate code that could potentially produce a warning. Suppose we wanted an expression that gives helper(1234)'s life, if it exists, or the player's life otherwise. Then we could write

Code:
Cond(numhelper(1234) > 0, (helper(1234), life), life)
(The extra parentheses around helper(1234), life are not required, but improve readability.)

Missing required animations/sprites

This is not an expressions problem. Add the animations/sprites!
Re: Avoiding warnings (CNS)
#2  May 18, 2016, 07:26:28 pm
  • *****
  • Gaps? Where we're going, we don't need gaps...
    • USA
    • ricepigeon.neocities.org
Var index out of range

Mugen only supports up to 60 integer variables (Var(0)~Var(59)) and 40 floating point variables (Fvar(0)~Fvar(39)) per character/helper. Using a var index outside of these ranges (ie: Var(99)) will produce this error. Either change the variable index or, if more variables are needed, consider using helper variables with redirection triggers.
Re: Avoiding warnings (CNS)
#3  June 21, 2016, 09:50:35 pm
  • *****
  • Shame on you!
    • USA
vVv Wheat Stage Released vVv