MV strange issue with my Action sequence [YEP]

Hello!
i'll try and keep things brief, I have a food system in a project I'm working on where certain items, when consumed, increase the stats of the target, but also increases their hunger, and once they're full, they can't eat anymore and have to fight battles to get hungry again. I have most of the system sorted out, save for the actual food items.

I used DreamX_SaveTarget to save the targeted actor ID to variable 19, and using that I would use action sequences to check what the variable equels and then to change the other variables. however, for some reason when using the item, the targeted actor gets the stat boosts, but doesn't get their hunger increased, the former of which can only happen after the hunger has been increased according to the action sequence.

Can anyone that's better than me at this take a look and see what's wrong? if so that'd be very helpful!

below is the action sequence in its entirety, as well as a cutdown simplified version that has notes to explain what I'm trying to achieve better.

Spoiler: full action sequence
Code:
<target action>
if $gameVariables.value(19) == 1
  if (target.isStateAffected(13))
    GAIN ITEM 24: 1
    COMMON EVENT: 11
  else
    if $gameVariables.value(9) < 100
      CHANGE VARIABLE 9 += 1
      action effect
      if $gameVariables.value(9) > 100
      ADD STATE 13: target, (show)
      end
    else
      GAIN ITEM 24: 1
      COMMON EVENT: 10
    end
  end
if else $gameVariables.value(19) == 2
  if (target.isStateAffected(13))
    GAIN ITEM 24: 1
    COMMON EVENT: 11
  else
    if $gameVariables.value(10) < 100
      CHANGE VARIABLE 10 += 1
      action effect
      if $gameVariables.value(10) > 100
      ADD STATE 13: target, (show)
      end
    else
      GAIN ITEM 24: 1
      COMMON EVENT: 10
    end
  end
if else $gameVariables.value(19) == 3
  if (target.isStateAffected(13))
    GAIN ITEM 24: 1
    COMMON EVENT: 11
  else
    if $gameVariables.value(11) < 100
      CHANGE VARIABLE 11 += 1
      action effect
      if $gameVariables.value(11) > 100
      ADD STATE 13: target, (show)
      end
    else
      GAIN ITEM 24: 1
      COMMON EVENT: 10
    end
  end
if else $gameVariables.value(19) == 4
  if (target.isStateAffected(13))
    GAIN ITEM 24: 1
    COMMON EVENT: 11
  else
    if $gameVariables.value(12) < 100
      CHANGE VARIABLE 12 += 1
      action effect
      if $gameVariables.value(12) > 100
      ADD STATE 13: target, (show)
      end
    else
      GAIN ITEM 24: 1
      COMMON EVENT: 10
    end
  end
if else $gameVariables.value(19) == 5
  if (target.isStateAffected(13))
    GAIN ITEM 24: 1
    COMMON EVENT: 11
  else
    if $gameVariables.value(13) < 100
      CHANGE VARIABLE 13 += 1
      action effect
      if $gameVariables.value(13) > 100
      ADD STATE 13: target, (show)
      end
    else
      GAIN ITEM 24: 1
      COMMON EVENT: 10
    end
  end
if else $gameVariables.value(19) == 6
  if (target.isStateAffected(13))
    GAIN ITEM 24: 1
    COMMON EVENT: 11
  else
    if $gameVariables.value(14) < 100
      action effect
      CHANGE VARIABLE 14 += 1
      if $gameVariables.value(14) > 100
      ADD STATE 13: target, (show)
      end
    else
      GAIN ITEM 24: 1
      COMMON EVENT: 10
    end
  end
end
</target action>

Spoiler: simplified action sequence with notes
Code:
<target action>
//check if the actor id
if $gameVariables.value(19) == 1
//check if the actor has the "sick" status effect
  if (target.isStateAffected(13))
    //gives item back and displays text saying the actor is sick
    GAIN ITEM 24: 1
    COMMON EVENT: 11
  else
    //checks if target is full
    if $gameVariables.value(9) < 100
      //increases the correlated actor's hunger variable before giving the stat increases (action effect)
      CHANGE VARIABLE 9 += 1
      action effect
      //check if the hunger variable is now past the limit
      if $gameVariables.value(9) > 100
      //gives the target the sick status effect
      ADD STATE 13: target, (show)
      end
    //if the target is full but not sick, it gives the item back and displays a different message
    else
      GAIN ITEM 24: 1
      COMMON EVENT: 10
    end
  end
end
</target action>

Spoiler: the item this is being used for
1680416103422.png
the code might be correct, but you miss parenthesis on the "if" parts like

JavaScript:
if $gameVariables.value(19) == 1

// should be

if ($gameVariables.value(19) == 1)

not entirely sure if you need { and } or will be readed automatically as I seen
some using without it, but the if should be in parenthesis at least on each instance
you used in your notetag and should work afterwards, otherwise, I dont know what
could be missing.
May just be me here but I think indentation and if else don't actually work in MV action sequencing.
May just be me here but I think indentation and if else don't actually work in MV action sequencing.
If else is part of the action sequence plugin, so it should work,
or, are you saying that it's just a broken part of the plugin?

also, the indentation is just to make it easier to read for myself, it's not required or anything
the code might be correct, but you miss parenthesis on the "if" parts like

JavaScript:
if $gameVariables.value(19) == 1

// should be

if ($gameVariables.value(19) == 1)

not entirely sure if you need { and } or will be readed automatically as I seen
some using without it, but the if should be in parenthesis at least on each instance
you used in your notetag and should work afterwards, otherwise, I dont know what
could be missing.
thanks for the help, but sadly this didn't work.

i didn't put parenthesis around the if on my first draft because I had made use of the if/else before in another project and the parenthesis didn't seem to be necessary for it to function.

again, thank you for trying to help,
for now i'll try seeing if I can find a workaround that'll make it function properly like common events or something
there was a plugin that can nest alot of "if, if else, else if" things, but I dont know
who made it, as it might be usefull for you.

I cannot tell if the "if condition" without paranthesis works.
as I dont know much lunatic, but only read things that could be of help.

if it didn't work out, than I dont know what is wrong with the code.
but if you use plugin correctly as the documentation said, maybe there
is something in the YEP tip and trick part that might help on those things.

there is alot of lunatic codes, in case it might help to get your skill working.

I wish you good luck on your project, and that the help you need come by
that knows lunatic code ^^
If else is part of the action sequence plugin, so it should work,
or, are you saying that it's just a broken part of the plugin?

also, the indentation is just to make it easier to read for myself, it's not required or anything
I'm saying nested ifs don't exist in action sequence.

As @ShadowDragon mentioned, there is an extra plugin that makes those possible.
[here is a link] with the nested if statements that might work for you,
as you can place as many if's you need or else if, if else.

read the document though, so it will work out for you.

if it still doesn't work, than I'm out of options though.
I believe I found the issue, and it's that I never realized that action sequences just
don't work when using something outside of battle, not even stuff like changing variables or calling common events

In the end, I used the damage formula box to set my variables and then called the common event that roughly does the same thing I wanted. kinda sucks I wasted so much time on this but at least it works now.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/strange-issue-with-my-action-sequence-yep.156342/