Using Ruby as a scripting language within a C app

F

forgottenwizard

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.
 
B

Brian Candler

forgottenwizard said:
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.
 
H

Huw Collingbourne

forgottenwizard said:
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 Collingbourne

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

Brian Candler

Ken said:
Aside from being entertaining, what does this have to do with embedding
Ruby in a C-based MUD engine?

OK, I missed the smiley, <aside> tag etc.

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 :)
 
M

Marc Heiler

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

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. ;)
 
D

David Masover

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.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top