| Class | Command |
| In: |
lib/command.rb
lib/command.rb |
| Parent: | Object |
| cmd | [R] | |
| cmd | [R] | |
| help | [R] | |
| help | [R] | |
| name | [R] | |
| name | [R] |
load builds a command lookup trie from the commands listed in a yaml config file and in the and then defines/redefines them on the GameObject classes.
# File lib/command.rb, line 37 def self.load @log.info "Loading commands..." # first load the commands for objects ocmdtable = TernaryTrie.new if options['object_interface'] && !options['object_interface'].empty? options['object_interface'].each do |i| cmds = YAML::load_file("cmd/#{i}.yaml") cmds.each do |c| Kernel::load("cmd/#{i}/#{c.cmd}.rb") ocmdtable.insert(c.name, c) end GameObject.send(:include,ObjCmd) end else @log.warn "No command interfaces for GameObject" end # now load the commands for characters cmdtable = TernaryTrie.new if options['character_interface'] && !options['character_interface'].empty? options['character_interface'].each do |i| cmds = YAML::load_file("cmd/#{i}.yaml") cmds.each do |c| Kernel::load("cmd/#{i}/#{c.cmd}.rb") cmdtable.insert(c.name, c) end Character.send(:include,Cmd) end else @log.error "No command interfaces for Character" end @log.info "Done." return cmdtable, ocmdtable rescue Exception @log.error $! end
load builds a command lookup trie from the commands listed in a yaml config file and in the and then defines/redefines them on the GameObject classes.
# File lib/command.rb, line 37 def self.load @log.info "Loading commands..." # first load the commands for objects ocmdtable = TernaryTrie.new if options['object_interface'] && !options['object_interface'].empty? options['object_interface'].each do |i| cmds = YAML::load_file("cmd/#{i}.yaml") cmds.each do |c| Kernel::load("cmd/#{i}/#{c.cmd}.rb") ocmdtable.insert(c.name, c) end GameObject.send(:include,ObjCmd) end else @log.warn "No command interfaces for GameObject" end # now load the commands for characters cmdtable = TernaryTrie.new if options['character_interface'] && !options['character_interface'].empty? options['character_interface'].each do |i| cmds = YAML::load_file("cmd/#{i}.yaml") cmds.each do |c| Kernel::load("cmd/#{i}/#{c.cmd}.rb") cmdtable.insert(c.name, c) end Character.send(:include,Cmd) end else @log.error "No command interfaces for Character" end @log.info "Done." return cmdtable, ocmdtable rescue Exception @log.error $! end
Create a command
# File lib/command.rb, line 29 def initialize(cmd, name, help) @cmd,@name,@help=cmd,name,help end
Create a command
# File lib/command.rb, line 29 def initialize(cmd, name, help) @cmd,@name,@help=cmd,name,help end