assigning game variables in the script VxAce

Countyoungblood

Sleeping Dragon
Veteran
Joined
Dec 9, 2017
Messages
622
Reaction score
403
First Language
English
Primarily Uses
RMVXA
$game_variables[x] = y doesnt work for me.

v[x] = y doesnt work either.



how can i assign a value to a game variable inside a method?
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
681
Reaction score
446
First Language
English
Primarily Uses
RMVXA
The first one should work, and the second one should work in a skill formula. You need to make sure that x and y are the values you want them to be. x definitely should be an integer greater than 0.

In your method, try the following after setting x and y to what they need to be:
Code:
$game_variables[x] = y
p(x, y, $game_variables[x])
# ^this will print to the console the value of x, y, and the value of variable x
 

Countyoungblood

Sleeping Dragon
Veteran
Joined
Dec 9, 2017
Messages
622
Reaction score
403
First Language
English
Primarily Uses
RMVXA
The first one should work, and the second one should work in a skill formula. You need to make sure that x and y are the values you want them to be. x definitely should be an integer greater than 0.

In your method, try the following after setting x and y to what they need to be:
Code:
$game_variables[x] = y
p(x, y, $game_variables[x])
# ^this will print to the console the value of x, y, and the value of variable x
even writing things like $game_variables[1] = 9 aren't working. ive been calling a method from an attack formula and added a method to on_turn_end which prints variables 1-4 (which actually works fine but didn't report any changes when the method was called by the attack)

Ive written another attack with v[2]=4 in the formula which does show up in the console print.

its an interesting mystery about $game_variables but I've decided to just push forward with what I have functioning. I've managed to assign my variables as needed inside the attack formula and now am focused on fixing this line to check the state of an objects last target (the function of the variables)

def check_state_from_var
return if not state?(20)
if $game_variables[self.index].state?(27)
self.remove_state(20)
self.add_state(22)
else
return
end
this runs on round end 4 times (redundant but not the priority problem)
it checks for state 20
if so check the variable equal to the objects index which is assigned the last targets index which im wanting to check for state 27
if state 27 is found remove state 20 on the object
and add state 22.


the problem is with testing for state 27. I've tried a number of combinations today in order to test the objects last targets states but most of that time I had another error with assigning the variables and was unaware. thanks to theo Ive learned just enough about the console to be able to print out my variables and know for sure they were assigned.

......why?
.......reasons.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,573
Reaction score
6,503
First Language
Indonesian
Primarily Uses
RMVXA
$game_variables[x] = y doesnt work for me.
Try in the event script call. Don't put it in a complex formula like what you're trying to do.
Simply $game_variables[x] = y then check the value by using show text.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

I made some sideview closets for MV!
You can find them in my MV resource thread.
People1.png & SF_People1.png added!!!!

Adventurer:
"Why your body looks like a bird?"

Stranger:
"Because I'm harpy"

Adventurer:
"Clap along if you feel like a room without a roof"

*Both dancing to Pharrell Williams song*
Stream will be live shortly with a make-up session of the Interactive Text Adventure! Feel free to drop by!

Forum statistics

Threads
105,507
Messages
1,014,275
Members
137,177
Latest member
tranphong
Top