Using Ruby as a scripting language within a C app

I’m working on building a MUD, and I would like to be able to use Ruby
as the scripting language within the MUD (such as with mobiles, rooms,
objects, ect).

I would like someone to give me an idea on how to do this, as well as an
idea on how much effort and time this will require.

forgottenwizard wrote:

I’m working on building a MUD, and I would like to be able to use Ruby
as the scripting language within the MUD (such as with mobiles, rooms,
objects, ect).

I would like someone to give me an idea on how to do this, as well as an
idea on how much effort and time this will require.

http://poignantguide.net/ruby/chapter-6.html

Scroll down to “A Sponsored Dragon-Slaying” and enjoy.

forgottenwizard wrote:

I’m working on building a MUD, and I would like to be able to use Ruby
as the scripting language within the MUD (such as with mobiles, rooms,
objects, ect).

If you are using C/C++ (or indeed C#) in .NET you can embed Ruby
programs using our free Ruby Connector:

http://www.sapphiresteel.com/SapphireSteel-Downloads

For some ideas on writing adventure type games in Ruby, you may find my
Ruby adventure game tutorial of use:

http://www.bitwisemag.com/2/Adventures-In-Ruby
http://www.bitwisemag.com/2/Adventures-In-Ruby-Part-2
http://www.bitwisemag.com/2/Adventures-In-Ruby-Part-3

best wishes
Huw C.

SapphireSteel Software
Ruby and Rails In Visual Studio
http://www.sapphiresteel.com

Ken B. wrote:

On Mon, 22 Sep 2008 02:41:12 -0500, Brian C. wrote:

Scroll down to “A Sponsored Dragon-Slaying” and enjoy.
Aside from being entertaining, what does this have to do with embedding
Ruby in a C-based MUD engine?

OK, I missed the smiley,

For a more useful link, see
http://www.ruby-doc.org/docs/ProgrammingRuby/html/ext_ruby.html

The section “Embedding a Ruby Interpreter” is brief, but much of the
preceding stuff about VALUE and so on is relevant. There’s enough to get
started with experimenting anyway.

In any case, a simple Google for “embedded ruby” turns up a bunch of
useful stuff. The first hit is http://metaeditor.sourceforge.net/embed/

None of that is specific to the problem domain of MUDs (apart from
_why’s page), but once you have an embedded ruby interpreter, what you
do with it is up to you.

I’d question why you’d want to write any of the rest of it in C, but
that’s a different issue :slight_smile:

On Mon, 22 Sep 2008 02:41:12 -0500, Brian C. wrote:

Scroll down to “A Sponsored Dragon-Slaying” and enjoy.
Aside from being entertaining, what does this have to do with embedding
Ruby in a C-based MUD engine?

–Ken

I’d question why you’d want to write any of the rest of it in C, but
that’s a different issue :slight_smile:

I am not the original author, but personally I always enjoy it when
people do not ask why I want to do something that way, but rather help
how i do it.

In my experience way too often people who tried to ask for the why also
tried to persuade me that the way is wrong. Which may be fine but it
wastes my time as well in like 95% of the cases I personally experienced
and does not really help me as well. :wink:

On 05:58 Tue 23 Sep, Brian C. wrote:

http://www.ruby-doc.org/docs/ProgrammingRuby/html/ext_ruby.html
do with it is up to you.

I’d question why you’d want to write any of the rest of it in C, but
that’s a different issue :slight_smile:

Posted via http://www.ruby-forum.com/.

I’m starting off of an existing codebase, and trying to rewrite it into
Ruby seems like a waste.

On Tuesday 23 September 2008 15:03:42 Marc H. wrote:

I’d question why you’d want to write any of the rest of it in C, but
that’s a different issue :slight_smile:

I am not the original author, but personally I always enjoy it when
people do not ask why I want to do something that way, but rather help
how i do it.

There are advantages to both. Consider the hypothetical question:
“How can I delete every file on my hard drive with a single command?”

If there’s an easy way to do what I want to do, I’d like to know it.
“rm -rf /”

However, in the same message, it might be helpful to suggest other ways
of
thinking about the problem:

“Well, if you really want the data gone (to hide it), best ‘dd
if=/dev/zero
of=/dev/sda’. And if you only need to nuke a particular directory, you
can ‘rm -rf /foo’ – but you may want to look up ‘shred’ first.”

I might learn something. It might even save me weeks of work – might
stop me
from nuking my whole hard drive, in the above (contrived) example.

If not, it doesn’t waste very much time to read them and ignore them.

So, I think Brian’s post was actually helpful in that he’s pointed out a
few
useful resources for embedding a Ruby interpreter, and also suggested
that it
might be better to write it in Ruby. (I’d second that – a MUD doesn’t
have
to be fast, but it’s better if it’s flexible, and it really shouldn’t
take
long.)