Yanfly Equip Reqs Lunatic Syntax HelP!

Discussion in 'JS Plugin Requests' started by Aryn, Nov 25, 2018.

  1. Aryn

    Aryn Villager Member

    Messages:
    21
    Likes Received:
    5
    First Language:
    English
    Primarily Uses:
    RMMV
    I hope someone with Java knowledge can help me out with this. I am not a programmer, but I am programmer-friendly--meaning I can look at syntax and basically understand what it's doing. I would like to use Yanfly's Equip Requirements Plugin with *variables*, which is the one thing it doesn't natively support. (I think this is odd, in light of Yanfly's Actor Variables.) I'm having two problems. First, I've tried a number of syntax variations for the <Custom Equip Requirement Condition>, to no avail. Second, and more puzzlingly, I can't get <Custom Equip Requirement Text> to simply display text as per Yanfly's instructions. However, "Requirements" does show up, and normal equip reqs (e.g., atk > 1) seem to work fine.

    Here's what I'm working with. Please help! (Note: I couldn't determine if "$gameVariables.name(77)" was a proper call, but this doesn't even work as a pure text string.)

    <Custom Equip Requirement Text>
    text = ‘Minimum ' + $gameVariables.name(77) + ' = 1’;
    </Custom Equip Requirement Text>

    <Custom Equip Requirement Condition>
    if (user.actorId() == 1) && $gameVariables.value(77) >= 1 {
    condition = true;
    } else {
    if (user.actorId() == 1)
    condition = false;
    } else {
    condition = true;
    }
    </Custom Equip Requirement Condition>
     
    #1
  2. Poryg

    Poryg Pixie of the Emvee kingdom, Ham of a Hamster Veteran

    Messages:
    3,312
    Likes Received:
    7,984
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    Typo.

    <Custom Equip Requirement Condition>
    if (user.actorId() == 1 && $gameVariables.value(77) >= 1) {
    condition = true;
    } else {
    if (user.actorId() == 1) {
    condition = false;
    } else {
    condition = true;
    }
    }
    </Custom Equip Requirement Condition>
     
    Last edited: Nov 25, 2018
    #2
    Aryn likes this.
  3. Aryn

    Aryn Villager Member

    Messages:
    21
    Likes Received:
    5
    First Language:
    English
    Primarily Uses:
    RMMV
    Thank you for your quick reply! But are you sure? I double checked the curly brackets, and it seems there are 3 sets, all closed in the original syntax. Also, neither version is working still. Everything works except lunatic mode. :(
     
    #3
  4. Poryg

    Poryg Pixie of the Emvee kingdom, Ham of a Hamster Veteran

    Messages:
    3,312
    Likes Received:
    7,984
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    There's one more typo I forgot to fix. In particular I forgot to add one more bracket. I edited it and added the missing bracket there.
     
    #4
    Aryn likes this.
  5. Aloe Guvner

    Aloe Guvner Walrus Veteran

    Messages:
    1,239
    Likes Received:
    793
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMMV
    If you're writing Javascript in the notetag box, there's a larger chance of syntax errors (as opposed to a proper code editor that can catch your mistakes). I would recommend using a tool to check for mistakes, a very easy one is https://www.jslint.com

    Additionally, syntax errors should show in the console (press F8 during playtest), but it depends on how the plugin author does error handling.
     
    #5
    Aryn likes this.
  6. Aryn

    Aryn Villager Member

    Messages:
    21
    Likes Received:
    5
    First Language:
    English
    Primarily Uses:
    RMMV
    Yes! That worked. Thank you so much! I was also running this through my brother (a programmer), who pointed out this was simpler:

    var condition = true
    if ($gameVariables.value(77) < 1 && user.actorId() === 1) {
    condition = false
    }

    Any idea why the simple text doesn't work, though? That seems much more straightforward.

    Edit: (Also, thank you Aloe, I'm just learning to run this stuff through jsfiddle, which I think is similar.)
     
    #6
  7. Poryg

    Poryg Pixie of the Emvee kingdom, Ham of a Hamster Veteran

    Messages:
    3,312
    Likes Received:
    7,984
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    Not sure why it doesn't work even as plaintext. I cannot even test it right now, since I'm not at home. Nevertheless, just so you know, $gameVariables.name doesm't exist.
     
    #7
    Aryn likes this.
  8. Aryn

    Aryn Villager Member

    Messages:
    21
    Likes Received:
    5
    First Language:
    English
    Primarily Uses:
    RMMV
    Ha, I figured. Thanks. I'm trying to access the variable name instead of the value and hadn't figured out how. Not absolutely necessary, though. I'll keep experimenting to see if I can get it to work.

    Edit: Got it. Of course it was stupid. I copy-pasted Yanfly's example and it input slightly different versions of the single quote, which messed up the string. Live and learn. Thank you guys so much. Now solved.
     
    Last edited: Nov 25, 2018
    #8
  9. Poryg

    Poryg Pixie of the Emvee kingdom, Ham of a Hamster Veteran

    Messages:
    3,312
    Likes Received:
    7,984
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    The engine will ignore variable names.
     
    #9
    Aryn likes this.
  10. Aloe Guvner

    Aloe Guvner Walrus Veteran

    Messages:
    1,239
    Likes Received:
    793
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMMV
    Variable names are stored in a different place:
    Code:
    $dataSystem.variables[i]
    Where i is the ID# of the variable.
     
    #10
    Aryn likes this.
  11. Aryn

    Aryn Villager Member

    Messages:
    21
    Likes Received:
    5
    First Language:
    English
    Primarily Uses:
    RMMV
    Fantastic! Many thanks.
     
    #11

Share This Page