lib/flok/user_compiler.rb in flok-0.0.56 vs lib/flok/user_compiler.rb in flok-0.0.57

- old
+ new

@@ -194,10 +194,15 @@ //Call on_entry for the new action via the singleton on_entry //located in ctable __info__.cte.actions[__info__.action].on_entry(__base__) + //'choose_action' pseudo-action will be sent as 'null' as it's the initial state + if (old_action === "choose_action") { + old_action = null; + } + //Send off event for action change main_q.push([3, "if_event", __base__, "action", { from: old_action, to: "#{action_name}" }]); @@ -477,18 +482,32 @@ #Some macros expect controller instance @controller = self self.instance_eval(&block) + + #Ensure that choose_action exists + actions = @ctx.actions_for_controller(@name) + unless actions.detect{|e| e.name === :choose_action} + @ctx.action self, :choose_action do + on_entry %{ + Goto("#{actions[0].name}"); + } + end + end end #Create an action macro def macro name, &block @macros[name] = block end def on_entry str @_on_entry = _macro(str) + end + + def choose_action &block + @ctx.action self, :choose_action, &block end #Names of spots def spots *spots @spots += spots