The Script class defines te characteristic of an executable program.
Compile a program
return
success or failure
# File lib/core/script.rb, line 60 def compile case language when :boolexp true when :fart @prog = Farts::Parser.new.parse(src) log.info "Compile of FART program - #{name}" true else false end rescue Exception log.error $! @prog = nil false end
Execute a program
return
success or failure
# File lib/core/script.rb, line 79 def execute(ev) case language when :boolexp actor = get_object(ev.from) BoolExpParser.new(actor).parse(src) when :fart vars = {} vars['actor'] = get_object(ev.from) vars['this'] = get_object(ev.to) if ev.msg.kind_of?(GameObject) vars['args'] = get_object(ev.msg) else vars['args'] = ev.msg end load if !@prog compile if !@prog @prog ? @prog.execute(vars) : false else false end rescue Exception log.error $! false end
Load a program
return
success or failure
# File lib/core/script.rb, line 41 def load(str=nil) case language when :boolexp self.src = str log.info "Load of BoolExp program - #{name}" true when :fart File.open("farts/#{name}.fart") {|f| self.src = f.read } log.info "Load of FART program - #{name}" true else false end end