YesNoOk
avatar

":=" versus "variables" (Read 1714 times)

Started by KHAeon, October 22, 2009, 02:14:55 am
Share this topic:
":=" versus "variables"
#1  October 22, 2009, 02:14:55 am
  • avatar
  • *
  • MUGEN {Japanese} LIMITLESS
I have a good understanding of how to use variables / float variables and how they work, but there is a tiny piece of coding that I don't get....

[mcode]:=[/mcode]WHAT IS THIS THING?  ???

I have read that it is very useful and a great time saver, but I don't have the slightest idea of how it works...
Please explain what it is and how I should decide whether to use it or variables.
And if it is at all related to the IfElse trigger, please explain.

Spoiler, click to toggle visibilty
[/center]
Last Edit: October 22, 2009, 02:37:56 am by KHTalon
Re: ":=" versus "variables"
#2  October 22, 2009, 04:09:59 am
  • **
From the docs (exp.html):
Quote
:=

The assignment operator. An unredirected variable name (var(n) or fvar(n) for suitable values of n) must appear on the left-hand side. If the left-hand side contains an integer variable, then the right-hand side is truncated to an integer before assignment. If the left-hand side contains a float variable, then the right-hand side is converted to float if necessary before assignment. In both cases, the value of the expression is the value that is assigned to the variable.

In other words var(X) := Y, will give variable X the value Y.

It can save you some (Var) controllers. A simple example:
[mcode][State -2, Total Hittime]
type = VarAdd
trigger1 = p2movetype = H
trigger2 = var(20):=0
var(20) = 1
ignorehitpause = 1[/mcode]
As long as p2movetype = H is true, this will add 1 to var(20). But if it is false, the second trigger will be checked and var(20) will then be set back to 0. So you dont need an extra VarSet controller to reset the variable.

Latest Creation: SSBB Assist Trophies
Re: ":=" versus "variables"
#3  October 24, 2009, 05:04:25 pm
  • avatar
  • *
  • MUGEN {Japanese} LIMITLESS
Thank you, I'm going to toy around with this a bit, because I do use a lot of variables.
Re: ":=" versus "variables"
#4  October 24, 2009, 06:20:09 pm
  • ******
  • Limited time to use Infinite power !
    • France
    • network.mugenguild.com/cybaster/