YesNoOk
avatar

Global variable affecting multiple statedefs? (Read 2863 times)

Started by ade2004, September 19, 2021, 02:19:08 pm
Share this topic:
Global variable affecting multiple statedefs?
#1  September 19, 2021, 02:19:08 pm
  • avatar
  • ***
Hello, I was just wondering if this is possible. using a varset in common1 to set a variable and having it recall that variable across multiple states.

EDIT:
NVM, got it to work. Works within the same cns file across different states which serves my purpose.

EDIT2:
what I was initially asking was if a varset in common1 can work across multiple cns files in different states within a character.
Last Edit: September 19, 2021, 03:50:34 pm by ade2004
Re: Global variable affecting multiple statedefs?
#2  September 21, 2021, 11:15:58 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
Variables are for the character. Set one and its valid everywhere for everything. Helpers can redirect to it even if in their own file. Depending on your intpersistindex you can even call on it across rounds and matches. They're not locked to the state theyre set in.

That said. Helpers have their own vars. Set a var in a helper and you have to redirect to access it. Its not available naturally.


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.
Re: Global variable affecting multiple statedefs?
#3  September 21, 2021, 04:23:31 pm
  • avatar
  • ***
Thanks for the reply Cyanide. What about my EDIT #2? Is that possible? Setting a variable in common1. cns and using it on other state files for the character. If it helps I could describe the specifics of what I'm trying to achieve.
Re: Global variable affecting multiple statedefs?
#4  September 21, 2021, 11:43:01 pm
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
Yes. As long as its your characters personal common1 thats fine. If its a shared common1 like the one in data thats a full game only thing. Not because it won't work but because you may break other charracters already using the var.


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.
Re: Global variable affecting multiple statedefs?
#5  September 22, 2021, 12:17:31 am
  • avatar
  • ***
Yes. As long as its your characters personal common1 thats fine. If its a shared common1 like the one in data thats a full game only thing. Not because it won't work but because you may break other charracters already using the var.

How can I achieve that? that's EXACTLY what I want. I am making a full game so I need the variable in a shared common1 file


EDIT: rest assured the variable is unique
Re: Global variable affecting multiple statedefs?
#6  September 22, 2021, 11:43:23 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
Just use the one in the data folder. Thats why its there. Common mechanics. As long as the variable is unique for everyone you're fine.


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.
Re: Global variable affecting multiple statedefs?
#7  September 22, 2021, 04:13:01 pm
  • avatar
  • ***
Just use the one in the data folder. That's why its there. Common mechanics. As long as the variable is unique for everyone you're fine.

Yeah I tried that earlier but it didn't work, is there an issue with the way my code looks in common1?

[State 0, boss decider]
type = VarSet
trigger1 = 1
v = 18
value = 0 + random%3

Basically I'm trying to generate random images on the tower select.
the state for the battle plan is in statedef 18000, another common file that ALL chars share.
Re: Global variable affecting multiple statedefs?
#8  September 23, 2021, 07:39:58 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
All thats going to do (and i don't know where in the file it is) is constantly set a variable between 0 1 and 2.

Use displaytoclipboard in state -2 to see if your varset works


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.
Re: Global variable affecting multiple statedefs?
#9  September 23, 2021, 06:04:05 pm
  • avatar
  • ***
All thats going to do (and i don't know where in the file it is) is constantly set a variable between 0 1 and 2.

Use displaytoclipboard in state -2 to see if your varset works

It's in common1.cns, under [statedef -3]

There is no state -2 in the common1.cns, that's how this full game was structured. However [state -2] exists in the characters own 1.cns file