Is it possible to assign a class level as a switch/variable?

Discussion in 'Javascript/Plugin Support' started by Ravos9988, Jul 20, 2019.

  1. Ravos9988

    Ravos9988 Villager Member

    Messages:
    23
    Likes Received:
    6
    Location:
    Texas
    First Language:
    English
    Primarily Uses:
    RMMV
    Relevant plugin: YEP_ClassChangeCore

    I have FINALLY figured out the plugin commands. lol. Ive got my first class change event scripted and working, and even switches so the player cannot go back to previous class, or a class not currently in their path (physical/magical).

    Now my challenge is this:
    I want to make it so at class level 10, the player can go to the ClassChange NPC I made to get promoted.

    My problem:
    Because I have a switch that says [if class 2a/b =ON, Text "cant change classes", END], even though actor is level 10 in class 2a/b, it refers to that message. (its worth noting that I also have a note tag on class 3a/b with [level unlock requirements = class 2a/b= level 10])

    EDIT:
    I kept digging and eventually found the game data tab under variables. Now my problem is getting the if statement to work. I managed to get it to work on [if level <10 = TRUE, Text "Level not high enough", END], but cannot figure out the >10 or =10 to run.

    Solution I'm looking for:
    I'm trying to figure out an [if] statement that calls up the actors current class level to check if level requirement is met, if true it moves to the class change menu.
    so something like this:

    .if [actor]class level = level 10
    ....Text: "Youre eligible for promotion! Would you like to proceed?"
    ....Option: etc, etc, etc...
    ....if yes
    ........UnlockClass 1 3a/b
    ........EnablePrimaryClassChange 1
    ........OpenClass

    and so on.

    is there a way to assign an actor level as a variable or switch for this kind of [if] statement? if so, could you provide me an example or a tut (if one is available)? If it helps i can even show you my current event script thus far.

    As always, thank you in advance! :kaodes:
     
    Last edited: Jul 20, 2019
    #1
  2. standardplayer

    standardplayer Keeper of Kitties Veteran

    Messages:
    224
    Likes Received:
    752
    First Language:
    English
    Primarily Uses:
    N/A
    So you want the actor's level, that's all? I'm not sure if I'm understanding the whole problem. You said you've figured out the class change bit of it, but the trouble is with the if statement. But then it sounds like the problem is just checking the actor's level?

    If that is the case
    ravos9988Help1.png ravos9988Help2.png

    With ClassChangeCore, the actor's current level is still reflective of the 'class' level. Therefore, if you want to check to see if an actor's current class is at a certain level, you just ask for the actor's current level, which can be done through control variable/game data.

    EDIT: I have noticed however that the ClassChangeCore adds a property called classLevel. I tested and noticed that even though my 'actor' level was 5, because the database has it initially set at 5, and even though as a result my starting class is level 5, the classLevel function returns 1. Which would makes sense, because I never leveled the class as far as the plugin is concerned. Perhaps an oversight, or perhaps I'm just an idiot.

    Either way
    A safer way to get the true correct value seems be using Control Variable, but clicking the script option instead, and typing
    $gameActors.actor(id).classLevel()
    Replace id in the parenthesis with the database number of the actor in question. If you're using enough actors to make that a headache, let me know and I'll write a loop to make that go smoothly.
     
    Last edited: Jul 20, 2019
    #2
  3. Ravos9988

    Ravos9988 Villager Member

    Messages:
    23
    Likes Received:
    6
    Location:
    Texas
    First Language:
    English
    Primarily Uses:
    RMMV
    @standardplayer you are an absolute godsend, my new bestfriend. THANK YOU.

    Although, I DID try inserting the charLevel variable at the top of the event page before, but it ended up breaking the action button and wouldnt do anything. I removed it, and the action button worked..this time when i added it, it worked perfectly... could it have been because a certain statement was out of order?
     
    #3
  4. standardplayer

    standardplayer Keeper of Kitties Veteran

    Messages:
    224
    Likes Received:
    752
    First Language:
    English
    Primarily Uses:
    N/A
    You mean that the ok button would no longer do anything? Did you have to restart the game?
     
    #4
  5. standardplayer

    standardplayer Keeper of Kitties Veteran

    Messages:
    224
    Likes Received:
    752
    First Language:
    English
    Primarily Uses:
    N/A
    Not to double post, but I never know if someone will go back see edits if they've already read the post.
    A statement being out of order can always result in an unintended side effect, something not working or flat out crashing/freezing your game.
    Eventing isn't scripting, but anyone who can script can look at the event editor and know it's made with scripting in mind,



    A simple trick is to add a text box at different points in your event to tell you it's reaching a certain point in execution.
    This is helpful because you can narrow down where an event stopped working. If the textbox you're trying to see is showing, you at least know the event reached that point before it 'broke'.
    It's not the only way to use a textbox to check for errors, but it's a simple and useful one.

    Also, if you didn't know, hitting F9 will bring up the list of switches and variables during a playtest. You can change them or at least just check them, to see if a change you attempted was successful, for example.
     
    #5
  6. Ravos9988

    Ravos9988 Villager Member

    Messages:
    23
    Likes Received:
    6
    Location:
    Texas
    First Language:
    English
    Primarily Uses:
    RMMV
    @standardplayer not quite. I would run the playtest, walk up to the NPC, and when I hit the action button to interact, nothing would happen. Then I took out the variable above the if statement, and the action button would work but I wouldnt have the variable in the event.

    This time, with the variable at the top, it didnt do that, and I'm curious as to why. Either way, I'm over the moon right now because I've been fidging with this event for almost a week now and it finally works. Lol
     
    #6
    standardplayer likes this.

Share This Page