Set variable in <target action> to use for if...then statement

gytfunke

Villager
Member
Joined
Oct 16, 2016
Messages
7
Reaction score
0
First Language
English
Primarily Uses
Hello there,


So, I'm having trouble with a particular skill.  I want it to randomly choose from among 8 possible outcomes.  I'm using a random number between 1 and 8 assigned to a value which should then be read by the if...then statement to decide which outcome to choose, but either the variable isn't being set to said random int or the if...then isn't reading the variable.  It always performs the default action (nothing) for if the variable isn't set to a number between 1 and 8.


I'm using yanfly's Battle Core notetags to do this, so everything happens in a <target action> as part of a skill notetag.


I am not JS fluent (at all), so I'm guessing that I'm probably missing something elementary.  Any ideas on how to fix this?

Code:
<target action>
eval: $gameVariables.setValue[10] = Math.randomInt(8)+1;
perform action
if ($gameVariables.value[10] == 1)
   animation 3: target
   eval this.elementID = 4
   action effect
   add state 12: target
else if ($gameVariables.value[10] == 2)
   animation 4: target
   eval this.elementID = 5
   action effect
   add state 13: target
else if ($gameVariables.value[10] == 3)
   animation 5: target
   eval this.elementID = 6
   action effect
   add state 14: target
else if ($gameVariables.value[10] == 4)
   animation 2: target
   action effect
   add state 5: target
else if ($gameVariables.value[10] == 5)
   animation 2: target
   action effect
   add state 6: target
else if ($gameVariables.value[10] == 6)
   animation 2: target
   action effect
   add state 15: target
else if ($gameVariables.value[10] == 7)
   animation 2: target
   action effect
   add state 16: target
else if ($gameVariables.value[10] == 8)
   animation 2: target
   action effect
   add state 17: target
else
   break action
</target action>
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
You use (number) for $gameVariables.value and $gameVariables.setValue, not [number]


I really have no idea if any of what you've got up there works with that plugin.  You seem to have a mix of script and plugin stuff and I don't know if it works that way.  But changing [] to () might get you further than you are now.
 

gytfunke

Villager
Member
Joined
Oct 16, 2016
Messages
7
Reaction score
0
First Language
English
Primarily Uses
Hmm, thank you for the especially quick reply.  Changing [] to () throws an 'improper leftside argument' error.  But then removing the equation fixes that.


I.e.


$gameVariables.setValue(10, math.randomInt(8)+1)


But that kept spitting out the default output- the 'else' case.


So, this is where I'm at, now, and instead of giving the 'else' case, I'm only ever getting the var=1 case.


<target action>
eval: $gameVariables.setValue(10, Math.randomInt(8)+1)
perform action
if $gameVariables.value(10, 1)
animation 3: target
eval: this.elementID = 4
action effect
add state 12: target
else if $gameVariables.value(10, 2)
animation 4: target
eval: this.elementID = 5
action effect
add state 13: target
// clipped for ease of reading
else
break action
</target action>




I've spent an embarrassingly long amount of time on this and am going to sleep.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
if ($gameVariables.value(10) === 1)


As I said, I don't know if you've got the right syntax or structure or anything.  I'm not familiar with the plugin (and you haven't provided a link).  You seem to be trying to mix plugin stuff with actual script calls and I don't know if that's going to work.  I suggest you go back to the plugin notes and see if those things are even possible in the context of the plugin.  I suspect they aren't.
 

gytfunke

Villager
Member
Joined
Oct 16, 2016
Messages
7
Reaction score
0
First Language
English
Primarily Uses
Thank you very much, Shaz!  That line of code made the if...else statements work properly!  Here's the working form:


(again, this is a Skill notetag for yanfly's Battle Engine Core plugin)

Code:
<target action>
eval: $gameVariables.setValue(10, Math.randomInt(8)+1)
perform action
if ($gameVariables.value(10) === 1) 
   animation 3: target
   action effect
   add state 12: target
else if ($gameVariables.value(10) === 2) 
   animation 4: target
   action effect
   add state 13: target
else if ($gameVariables.value(10) === 3) 
   animation 5: target
   action effect
   add state 14: target
else if ($gameVariables.value(10) === 4) 
   animation 2: target
   action effect
   add state 5: target
else if ($gameVariables.value(10) === 5) 
   animation 2: target
   action effect
   add state 6: target
else if ($gameVariables.value(10) === 6) 
   animation 2: target
   action effect
   add state 15: target
else if ($gameVariables.value(10) === 7) 
   animation 2: target
   action effect
   add state 16: target
else if ($gameVariables.value(10) === 8) 
   animation 2: target
   action effect
   add state 17: target
else
   break action
</target action>
 

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

Latest Threads

Latest Profile Posts

Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:

Forum statistics

Threads
105,854
Messages
1,017,004
Members
137,562
Latest member
tamedeathman
Top