if you are trying to make an actual inner class in Ruby, i am not sure, but if you want an anonymous function (which is what it looks like what you want to do), look at this web page
Understanding Ruby Blocks, Procs and Lambdas - Robert Sosinski
|
Any way to do this?
In ruby?Code:character.startAction(new DistancedAction(1, true, character, object_position, 1) { @Override public void executeAction() { character.teleport(pos); stop(); } });
Getting tired of making separate action classes.
if you are trying to make an actual inner class in Ruby, i am not sure, but if you want an anonymous function (which is what it looks like what you want to do), look at this web page
Understanding Ruby Blocks, Procs and Lambdas - Robert Sosinski
Ya that's along the lines of what I'm looking for. Thanks.
I kinda figured out what I wanted by editing the bootstrap file in apollo.
Code:bind_distance_action 1, true, player, event.position, 1 do |action| player.teleport(STAIRS[event.id].position); action.stop endCode:class ProcDistancedAction < DistancedAction def initialize(block, delay, immediate, player, position, distance) super delay, immediate, player, position, distance @block = block end def executeAction @block.call self end end def bind_distance_action(*args, &block) if block_given? args[2].startAction ProcDistancedAction.new(block, args[0], args[1], args[2], args[3], args[4]) end end
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |