Using LearnableAbility throwing error

So this may come down to me still learning ruby, but getting an error I’m not grasping.
I’m working on a set of items to simulate hacking in a futuristic game. The following script is in a plugin titled ate hacking so the path is plugins\atehacking\public\ate_lattice_script.rb

The code is below but when I run devstart the system throws an error when it gets to include LearnableAbility

NameError: uninitialized constant AresMUSH::AteLatticeScript::LearnableAbility

Is this because this plugin tries to load earlier than FS3Skill? Or something I’m not seeing.

module AresMUSH
  class AteLatticeScript < Ohm::Model
    include ObjectModel
    include LearnableAbility

    reference :character, "AresMUSH::Character"
    attribute :name
    attribute :description
    attribute :memory_blocks
    attribute :target
    attribute :type
    attribute :combat_enabled
    attribute :visibility
    index :name
  end
end
1 Like

Yes, that looks like a plugin ordering issue. Included modules are one of the few things that are affected by the order in which plugins are loaded, because the include needs to be ‘available’ at load time. Most other things Ruby doesn’t look for until run time, after everything has been loaded.

For that reason, modules aren’t normally shared across plugins. LearnableAbility in particular is highly FS3-specific, so that’s not something I would expect to see used outside of the fs3skills plugin.

Cool I didn’t know if Ruby was one of those languages that pre-reads all the files before it starts processing or not. Sounds like the answer is not.

1 Like

Yeah Ruby loads as it goes. For static apps you can just specify the files in the desired load order in require statements like these. That’s what the Ares engine does.

But the beauty of Ruby is that it can also load things dynamically, even as the app is running. That is what powers Ares’ plugin framework. For that, things are loaded as you specify load <filename>. Because the plugin framework dynamically ‘discovers’ the plugins and the files within them, you can’t specify an order in the traditional Ruby way.

1 Like