Only actor# can access item command

● ARCHIVED · READ-ONLY
Started by deilin 10 posts View original ↗
  1. I've tried many ways to make it so the additemcommand only appears on actor() to partial success. I got it so only actor() can open item window in battle, but the command item still appears in actorcommand window...

    I can't seem to identify the active id of the member i'm selecting an action for. If I can get that variable specified, I should be able to finish the script
  2. I guess this little method from Window_ActorCommand is what you should focus on:



    Code:
    #--------------------------------------------------------------------------
    # * Create Command List
    #--------------------------------------------------------------------------
    def make_command_list
    return unless @actor
    add_attack_command
    add_skill_commands
    add_guard_command
    add_item_command
    end
    As you can see at the top there's a variable called @actor, this one is holding the actor the selection is for, so if you want the to check this actors actor ID you have to look at @actor.actor_id.

    There's one little thing to add though, since actor_id is private, just put this above or below you current code:



    Code:
    class Game_Actor < Game_Battler
    attr_reader :actor_id
    end
  3. Ah. Yeah. Had the @actor.actor_id, but had a nil error. This should help with my other scripts getting the same error.after working on it more, here is my end script...



    Code:
    #------------------------
    #CANUSE commands
    #Modifies what actor commands appear in battle based on
    #by DeiLin
    #free to use with credit given
    #------------------------
    module CANUSE
    #leaving [] below will disallow all actors
    CANATTACK = [] #actor ids that can use attack command
    CANGUARD = [] #actor ids that can use guard command
    CANITEM = [] #actor ids that can use item command
    #Skill isn't included since it's based on RPG Maker VX ACE traits
    end
    #------------------------
    #Don't modify below unless you know what you are doing.
    #------------------------
    class Game_Actor < Game_Battler
    attr_reader :actor_id
    end
    class Window_ActorCommand < Window_Command
    attr_reader :actor
    attr_reader :actor_id
    
    def make_command_list
    return unless @actor
    add_attack_command if CANUSE::CANATTACK.include?(actor.actor_id)
    add_skill_commands
    add_guard_command if CANUSE::CANGUARD.include?(actor.actor_id)
    add_item_command if CANUSE::CANITEM.include?(actor.actor_id)
    end
    end
  4. looks good to me, but why are you adding attribute readers for actor and actor_id in Window_ActorCommand?

    @actor is an instance variable of that class, so you it's not necessary and the actor_id is inside the @actor, you made that already "visible" to the outside with the attribute reader in Game_Actor.
  5. if I didn't, the script wont work. it still comes up nil, or errors out somewhere else.

    If I got rid of the attr_readers (any one) the script doesn't work

    @actor, from what it seems, comes up 0 or 1 (actor inactive or active), so I had to read actor and actor_id
  6. That's because you try to access a local variable (actor, without the @)

    This version works perfectly fine for me:



    Code:
    #------------------------
    #CANUSE commands
    #Modifies what actor commands appear in battle based on
    #by DeiLin
    #free to use with credit given
    #------------------------
    module CANUSE
      #leaving [] below will disallow all actors
      CANATTACK = [1] #actor ids that can use attack command
      CANGUARD = [] #actor ids that can use guard command
      CANITEM = [] #actor ids that can use item command
      #Skill isn't included since it's based on RPG Maker VX ACE traits
    end
    #------------------------
    #Don't modify below unless you know what you are doing.
    #------------------------
    class Game_Actor < Game_Battler
    attr_reader  :actor_id
    end
    class Window_ActorCommand < Window_Command
      def make_command_list
        return unless @actor
        add_attack_command if CANUSE::CANATTACK.include?(@actor.actor_id)
        add_skill_commands
        add_guard_command if CANUSE::CANGUARD.include?(@actor.actor_id)
        add_item_command if CANUSE::CANITEM.include?(@actor.actor_id)
      end
    end
  7. that was one of the first sets I tried, but it was coming up nil errors...
  8. do you have any other scripts in that project?

    I tired this in a brand new one and it worked Oo?
  9. I have 13 scripts in the game so far
  10. Does any of them do anything with Window_ActorCommand?

    It could be that one of them edits the standard behavior of the window/what is saved in the @actor variable