collapse

Author Topic: variables  (Read 1728 times)

0 Members and 5 Guests are viewing this topic.

Offline verz36

  • The Unlimited
  • *****
  • Posts: 723
  • Country: Dominican Republic do
  • Last Login:October 09, 2023, 12:31:46 PM
variables
« on: February 25, 2017, 02:27:34 PM »
hey guys, I looking to learn more about codes. I have done many research into this. I have learned few things but no matter how much I try, I cant figure out about variables. would the many of you coders out there care to teach me and help me understand about them? I want to know the use of them, why do we need them, how to implement them and what do they do. maybe give examples of them. I have tried to learn on my own but I don't see anywhere in the mugen docs any explanation of them that can help me understand them. any help with this will be greatly appreciated.



Offline Cyanide

  • MUGEN Content Architect
  • *****
  • Posts: 813
  • Last Login:March 29, 2019, 06:52:34 AM
    • Mugen Obscurity
Re: variables
« Reply #1 on: February 25, 2017, 05:17:41 PM »
Variables are just a way of saving ANY value and referring to it later. In their simplest sense they are an on/off switch.

Do a move
Set variable to 1, this variable now means "I have done a move"
You can now use that variable to say "i cannot do this move again" or "i have done this move and have unlocked another move" or "Now i have done this i can double my damage"

You can use them to save animations, or states. Basically if there is an integer or float number you might want to look at later, you can use a var to store it. You can do other things, but saving numbers and using them as on/off switches is where people start.

Offline Oh Não

  • Initiate
  • **
  • Posts: 13
  • Country: Brazil br
  • Last Login:April 04, 2017, 07:37:47 AM
  • Hi! I'm new!!
Re: variables
« Reply #2 on: February 25, 2017, 05:22:32 PM »
Variables are just a way of saving ANY value and referring to it later. In their simplest sense they are an on/off switch.

Do a move
Set variable to 1, this variable now means "I have done a move"
You can now use that variable to say "i cannot do this move again" or "i have done this move and have unlocked another move" or "Now i have done this i can double my damage"

You can use them to save animations, or states. Basically if there is an integer or float number you might want to look at later, you can use a var to store it. You can do other things, but saving numbers and using them as on/off switches is where people start.
I know I will not post anything useful for the topic, but I just wanted to say that this relatively simple explanation helped to understand a bit more about vars. Thanks Cyanide!

Offline verz36

  • The Unlimited
  • *****
  • Posts: 723
  • Country: Dominican Republic do
  • Last Login:October 09, 2023, 12:31:46 PM
Re: variables
« Reply #3 on: February 25, 2017, 06:19:24 PM »
ok, I get some of this now. but is there a difference then when they say the players variables? are we talking about the same thing. so if you use a variable, will u give it any number you want or does it has to be a specific number? to be honest with you, this is what is keeping me from taking that next step in coding. so im trying to get all this and learn it so that I can make that next step. thank you for taking your time and explain. can you give a sample where u would use one and why, maybe this with explanation can help me understand this further. thank you again for taking the time to help.

Offline ELECTRO

  • Cosmic Creations
  • Contributor
  • ****
  • Posts: 1321
  • Country: United States us
  • Last Login:October 17, 2024, 05:40:31 AM
  • The Living Dynamo
    • THE-BEY0NDER
    • THE BEY0NDER
    • ELECTRO'S LAIR
    • Email
Re: variables
« Reply #4 on: February 25, 2017, 10:19:01 PM »
From KFM

;Variables with this index and above will not have their values
;reset to 0 between rounds or matches. There are 60 int variables,
;indexed from 0 to 59, and 40 float variables, indexed from 0 to 39.
;If omitted, then it defaults to 60 and 40 for integer and float
;variables repectively, meaning that none are persistent, i.e. all
;are reset. If you want your variables to persist between matches,
;you need to override state 5900 from common1.cns.
IntPersistIndex = 60
FloatPersistIndex = 40


;------------------------------------------------------

Player = Your Character.I'm going to choose the number 58 to make my Var & it's starting value will be 0. It has to be something below 60 since 59 is the max. I will set it in Roundstate zero because it's the beginning of the round. The Var is holding this information now & becomes persistent until I tell it otherwise.

[State -3, NormalState]
type = VarSet
trigger1 = roundstate = 0
v = 58   
value = 0
;ignorehitpause =
;persistent =

Let's say I send my character to a custom state 3000. Once in the state I will change Var 58 value to 1.

[State 3000, Transform]
type = VarSet
trigger1 = time = 0
v = 58   
value = 1
;ignorehitpause =
;persistent =

Once I leave the state and go back to state 0 or standing state. I can put a change animation code to represent the transformation using the newly stored Var 58 which now has a value of 1.

[State 0, TransformedStance]
type = ChangeAnim
triggerall = Var(58) = 1
trigger1 = Anim != 5 && Anim != [0,1]
trigger2 = Anim = 5 && AnimTime = 0 ;Turn anim over
trigger3 = time = 0
value = 3000   ;New stance anim

Var 58 will always equal 1 until you change it back or until the round is over. So you can use this code for whatever you want like new moves in the transformation. Like this example.

;---------------------------------------------------------------------------
;Stand Medium Punch (No Transformation)
[State -1, Stand Medium Punch]
type = ChangeState
value = 205
triggerall = command = "y"
triggerall = command != "holddown"
triggerall = statetype != A
triggerall = var(58) = 0
trigger1 = statetype = S
trigger1 = ctrl

;---------------------------------------------------------------------------
;Stand Medium Punch (Transformation) Go to state 206 instead of normal 205
[State -1, Stand Medium Punch]
type = ChangeState
value = 206
triggerall = command = "y"
triggerall = command != "holddown"
triggerall = statetype != A
triggerall = var(58) = 1
trigger1 = statetype = S
trigger1 = ctrl

If you want to change the transformation back to normal during the same round, you just use the above code in your command to send your char to state 3001 instead of 3000. So just make a copy of state 3000 & rename it to 3001. In the state make your Var 58 = 0 now & when you exit state 3001, your stance & medium punch will be normal again.

You cannot use Var 58 again for other things since it involves your transformation. So you would then use Var 57 and below to store other things.

Last thing I want to say is that each helper has it's own set of Var from 0-59 that is separate from your  characters 0-59 var set. So don't be scared to use those anytime because they will be destroyed soon as the helper is destroyed. I'll give you a quick example of a code I use often on blood that flies around the map. I don't want the blood to always fly around the map the same way and be robotic. So I will make a quick Var to make it random.


[State 88121, varrandom]
type = VarRandom
trigger1 = 1                  (always active)
v = 2                            (the value of VarRandom)
range = -2,-7               (Anywere between range -2 & -7 will play if I call upon this Var)

[State 88121, varrandom]  (Same as above explanation, but i'm going to use 3 for a diff reason)
type = VarRandom
trigger1 = 1
v = 3
range = -4,4

[State 88121, velset]  (This is the reason I made those Vars & why)
type = velset
trigger1 = time = 1
y = var(2)                    (I want my Y value to use the range of VarRandom 2)
x = var(3)                    (Same deal but using the range of 3)

I hope this helped.


« Last Edit: February 25, 2017, 10:30:09 PM by ELECTRO »

Offline verz36

  • The Unlimited
  • *****
  • Posts: 723
  • Country: Dominican Republic do
  • Last Login:October 09, 2023, 12:31:46 PM
Re: variables
« Reply #5 on: February 25, 2017, 10:35:13 PM »
wow, I now understand this better. thanks a bunch... I hope this helps other people too.

Tags:
 


* IMT Facebook

Help us by Donating!

IMT Discord

Join us at our Discord! Click the image below!

* IMT Shoutbox

Sorry, this shoutbox does not exist.

* Recent Posts

D2TD VS Showcase Thread by D2TD
[November 24, 2024, 09:12:03 AM]


Marvel vs. Capcom: Eternity of Heroes REMAKE Game Update 1.3.0 - N.A.O.H. by LightFlare
[November 21, 2024, 09:44:09 PM]


Terrordrome: Rise of the Boogeymen Extended Version ( jeepers creepers) version by leonardo
[November 19, 2024, 10:22:47 PM]


Hill of the Nameless(1.1 Only) by Vegaz by LightFlare
[November 19, 2024, 10:50:39 AM]


Golden Axe Returns by gokudo99
[November 19, 2024, 03:59:31 AM]


Barkley Shut Up and Jam! Stages by Vegaz by LightFlare
[November 12, 2024, 11:26:21 AM]


[BOR] _Avengers United Battle Force_ by O Ilusionista
[November 11, 2024, 12:35:24 PM]


Eternal Lament Stage 1.1 & 1.0 by O Ilusionista
[November 11, 2024, 12:34:54 PM]


MatreroG's Stages W.I.P. Concepts by MatreroG
[November 11, 2024, 07:00:56 AM]


Spooky House(1.1 Only/AIGS) by Vegaz by LightFlare
[October 31, 2024, 11:31:36 AM]

* IMT Calendar

November 2024
Sun Mon Tue Wed Thu Fri Sat
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 [26] 27 28 29 30

SimplePortal 2.3.5 © 2008-2012, SimplePortal