From: Aaron Patterson Date: 2008-04-15T08:43:29+09:00 Subject: Re: My Longsword is broken. On Tue, Apr 15, 2008 at 02:08:42AM +0900, Ben Galyean wrote: > Hello all, > > Just started my first Ruby prog and hit a snag almost instantly. I > simply wish to have my selected weapon do it's prescribed damage as I > intend (in this case, it's 1-8 damage). Complete noob here so any help > at all would be greatly appreciated. The following is a re-creation of > my problem: Sometimes to fix your longsword, you must adjust your johnson: require 'johnson' ctx = Johnson::Context.new ctx[:ruby_rand] = lambda { |x| rand(x) } ctx.evaluate(<<-END var LongSword = { realDamage: function() { return ruby_rand(this.maxDamage); } } END ) ctx[:LongSword].maxDamage = 8 puts ctx[:LongSword].realDamage() http://github.com/jbarnette/johnson/tree/master Though there might be easier solutions...... -- Aaron Patterson http://tenderlovemaking.com/