Christian Tucker
Christian Tucker

Reputation: 627

Java Constructors in a Ruby Script

I'm trying to figure out how to add constructor parameters to my JRuby Script. I have had it working before with the following code.

class Man < NpcCombat
    def attackScripts attacker, victim
        return [BasicAttack.meleeAttack(attacker, victim,AttackStyle::Mode::MELEE_ACCURATE, 2, Weapon::FISTS)]
    end
end

However the Java Class "NpcCombat" now has a integer parameter, such as NpcCombat(int). I'm trying to figure out how to change this in my ruby script, but it's not working.

Upvotes: 1

Views: 92

Answers (1)

frostmatthew
frostmatthew

Reputation: 3298

I've never used jruby, but based on Ruby I imagine adding an initialize block that calls the super constructor should work:

class Man < NpcCombat
  def initialize(num)
    super(num)
  end 

  ...

end

Upvotes: 1

Related Questions