Access Actor Variables...

Discussion in 'Learning Javascript' started by G4merSylver, Nov 17, 2015.

  1. G4merSylver

    G4merSylver Villager Member

    Messages:
    17
    Likes Received:
    10
    ... Dont look at me like that.

    I probably missed out something important, but how do I access Actor Variables?

    gameActors.actor(1).level

      => Wont Work

    this._level

      => Wont Work

    actor.level

      => Wont Work

    I probably missed to link the variables to something, but I have no idea to what I should link to?

    What I am attempting is checking the player level and change it depening on the level, there is a reason why I am not moving the levelcap up or down or give an anti-exp state.

    Could someone tell me obvious thing thats so obvious that even google laughs off its ass and wont tell me what it is?
     
    #1
  2. Iavra

    Iavra Veteran Veteran

    Messages:
    1,797
    Likes Received:
    856
    First Language:
    German
    This works for me:

    Code:
    $gameActors.actor(1).level
     
    #2
  3. Galv

    Galv Veteran Veteran

    Messages:
    1,172
    Likes Received:
    1,105
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    N/A
    I think you nearly had it right. A quick look in the default plugin code and it appears to be:

    Code:
    $gameActors.actor(1).level
    And there is also a function to change the level:
    Code:
    $gameActors.actor(y).changeLevel(x, false);
    EDIT: Fixed change level text here
     
    Last edited by a moderator: Nov 18, 2015
    #3
  4. G4merSylver

    G4merSylver Villager Member

    Messages:
    17
    Likes Received:
    10
    Using "$gameActors.actor(1).level" yields the following error:

    Cannot read property 'actor' of nullThe script is an simple function with just "console.log($gameActors.actor(1).level);".

    There are four actors so the property of actor shoulnt be null right?
     
    #4
  5. Andar

    Andar Veteran Veteran

    Messages:
    28,312
    Likes Received:
    6,437
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    when did you place that command?


    Actors are only initialised on new game, before that they don't exist.
     
    #5
  6. Iavra

    Iavra Veteran Veteran

    Messages:
    1,797
    Likes Received:
    856
    First Language:
    German
    That's actually not true. DataManager.setupNewGame() is called in Scene_Boot and creates all game objects, including $gameActors. Game_Actors itself creates a new actor at the given id, if it doesn't already exist.


    So, try to wait until the title screen appears and then execute your snippet via console (F8).
     
    #6
  7. G4merSylver

    G4merSylver Villager Member

    Messages:
    17
    Likes Received:
    10
    -- Edit:

    Alright it works now, but there is one more thing: How can I keep updating the function?

    e.G running it in a routine, I would say to loop it with an while option... But I believe it will just result in it crashing?

    The loop should be connected to the check of the level of the player and an second variable, or should I just add it to the LevelUp option?
     
    Last edited by a moderator: Nov 17, 2015
    #7
  8. DarknessFalls

    DarknessFalls Rpg Maker Jesus - JS Dev. Veteran

    Messages:
    1,393
    Likes Received:
    209
    First Language:
    English
    $gameActors is what you want to look at
     
    #8
  9. G4merSylver

    G4merSylver Villager Member

    Messages:
    17
    Likes Received:
    10
    ^ Thanks, took me quite a bit to notice that the variables arent found in the F1 documentation but inside the scripts... I feel kinda stupid? XD
     
    #9
  10. basicleader

    basicleader Villager Member

    Messages:
    25
    Likes Received:
    6
    First Language:
    French
    Interesting, I know pretty much nothing about script calls myself, but how would you go about using this changelevel one ingame?

    I tried putting it as a "script" in an event on action trigger, but I got an error, I get an error when I use it inside the console too... I'm kinda lost!

    The simple consolelog worked and is useful so now I can check things out! Thanks!! =) 
     
    #10
  11. G4merSylver

    G4merSylver Villager Member

    Messages:
    17
    Likes Received:
    10
    Not sure if I understood what you meant...

    So you wrote an JavaScript.

    You created an Event.

    The event used the "$gameActors.changeLevel(x, false);"?

    The only thing that I noticed as wrong would be that you need to chose the Actor to.

    $gameActors.actor(y).changeLevel(x, false);
     
    #11
    Galv likes this.

Share This Page