Editing Code Tutorial

Early discussions with some folks showed that the nuts and bolts of editing the code was a stumbling block. So I’ve revamped the introductory code tutorials to include a new tutorial about the different ways to edit code - ssh, ftp, github, and finally options for setting up your own test game independent of the real game. Hope that helps.

2 Likes

I’m not sure where you’d put this, but one of the things I discovered about halfway through my current code project is the somewhat obvious fact that you can search for bits of code in github. It is super useful when trying to track helpers and the like backward to see what they actually do. It might be worth mentioning in a tutorial somewhere?

1 Like

Sure, good idea.

Filed away under “things you take for granted when you use GitHub every day…”

Added - https://aresmush.com/tutorials/code/edit-code/finding-code/

1 Like

So, obviously, I’m learning this as I go.
Here’s the error I’m hitting in the tutorial (for creating the goals command):

%% Problem loading plugin ‘custom’: uninitialized constant AresMush::Custom::GoalsCmd::CommandHandler

In searching this, it would seem it’s behaving as if ‘CommandHandler’ doesn’t exist. Obviously… it does, or else a lot of other things wouldn’t work.

Do I need to enable the custom plugin dir or something similar to it talks to the CommandHandler, perhaps? Or did I miss something else along the way…

No, you shouldn’t need to do anything. Maybe there’s a typo or something?

The complete goals command should look like this.

module AresMUSH
  module Custom
    class GoalsCmd
      include CommandHandler

      attr_accessor :name

      def parse_args
        self.name = cmd.args ? titlecase_arg(cmd.args) : enactor_name
      end

      def check_can_view
        return nil if self.name == enactor_name
        return nil if enactor.has_permission?("view_bgs")
        return "You're not allowed to view other peoples' goals."
      end

      def handle
        ClassTargetFinder.with_a_character(self.name, client, enactor) do |model|
          template = BorderedDisplayTemplate.new model.goals, "#{model.name}'s Goals"
          client.emit template.render
        end
      end
    end
  end
end

That is (as far as I can tell) what I have. Now, something I have actually never known is… how vital is spacing? I’ve always figured that’s more an aesthetics thing and to make it just easier to read. It doesn’t actually matter for the execution, right?

And this just goes under the plugins/custom folder, right?

Here’s what I’ve got:

Ah… it’s module AresMUSH (not AresMush).

All of the common utilities (including CommandHandler, the Character class, and more) are in a “module” - which is basically Ruby’s way of organizing code. It helps with name collisions, so AresMUSH::Event doesn’t conflict with some other code module that also wants an Event class.

Because your code is in the AresMush module instead of the AresMUSH module, it doesn’t have access to any of that.

But no, spacing doesn’t matter in Ruby. (It does in Python, btw, if you ever dabble in Evennia code.) Though spacing can help you identify issues with your ‘end’ markers being in the wrong place, which is a common problem. Most code editors have a built-in command to re-indent the file.

Ah-ha! This is why a second set of eyes is good.

And yeah, I’m using Sublime. I use it for… just about everything. From dabbling in code to random note-taking. I didn’t know about the command to indent. Handy. I’ve honestly just always thought it was aesthetics (the joys of being self-taught through trial and error ;)).

And good to know re: Python, actually. It’s something I’ve been meaning to learn in general (not for Evennia, just overall).

1 Like

Cool. This might help: How to Automatically Reindent Code With Sublime Text

1 Like

I had actually already found something similar on StackOverflow, but thank you! :slight_smile:

(Much easier than going into the menu option every time. :D)

I was running through the “goals” tutorial - which, btw, thank you for adding how to stick that on the web. :slight_smile:

Anyway. It seems to be working, except web-chargen has “undefined” for the goals blurb. Where’s this snippet stored, so I can edit that?

1 Like

Since you’re just doing this for your game and not trying to share it with the world, there’s no need to make a configurable blurb.

From the tutorial:

Tip: RP Hooks has a configurable “blurb” that gets displayed as instructions above the data entry field in chargen. You don’t need a config option for goals - just put some plain text there instead.

But in case you’re curious, the hooks blurb is stored in the chargen.yml config file. It gets sent to the web as part of the ChargenInfoRequestHandler request, which returns a bunch of static chargen config info like group options and the instruction blurbs.

1 Like

I wasn’t sure if I should start a new topic or jump onto this topic as I’m having issues with one of the Code tutorials.

When following the “Create a Plugin” tutorial I’m having issues with the script that is run:

bin/script create_plugin,<PluginName>

I’m getting the following error:

Using rubyzip 1.2.2
Fetching sassc 2.0.0
Installing sassc 2.0.0 with native extensions
Gem::RuntimeRequirementNotMetError: sassc requires Ruby version >= 2.3.3. The current ruby version is 2.3.1.112.
An error occurred while installing sassc (2.0.0), and Bundler cannot continue.
Make sure that `gem install sassc -v '2.0.0' --source 'http://rubygems.org/'` succeeds before bundling.

In Gemfile:
  sassc
Could not find sassc-2.0.0 in any of the sources
Run `bundle install` to install missing gems.

Following the commands doesn’t resolve the issue. I’m going to attempt to upgrade Ruby now from 2.3.1.112 to 2.3.3 or higher in the hopes it will resolve the problem.

I’m not sure what system you’re using, but the supported Ares install is on Ruby 2.6. It works OK with 2.5 as well, but earlier versions may or may not work due to gem compatibility issues - as you’ve discovered. Updating your ruby version should do the trick. I advocate using Ruby Version Manager to handle your rubies; this makes updating to a new ruby version a breeze.

I followed the Ares self install instructions and went with Ubuntu 16.04.5 for the image.

Did you install it awhile ago? The Ruby version does change over time and sometimes necessary upgrades to it are mentioned in the release notes.

I can certainly add an error-check in the Gem file to make sure you have the correct version of Ruby installed to make such issues more clear in the future.

For reference, the current installer installs and uses Ruby 2.6: