06 Nov, 2013, Davenge wrote in the 1st comment:
Votes: 0
I'm building off RocketMud and as such, I have to come up with a lot of my own stuff(obviously).

For scripting mob actions, etc, I was looking at using Lua because its pretty easy to learn and most people who are into gaming "scripting" already know it. The problem is, the lua language module doesn't appear(the documentation is not great) that you can't pass it ruby objects defined for its use. Like you would in C or C++. So I'm moving on from that idea, unless I'm wrong about this.

The goal would be to have a "script" with different methods defined in it that are called when the mob does something. For example, "big bat mob" might have a script somewhere /scripts/big_bat_mob.rb and within that is a method "def on_fight". How do I restrict access of this method? Do I do that by only passing it an object meant for it? Which would mean I'd have to create basically a object meant just for a script?

I'm new to ruby. What do you use for your ruby muds "scripting"? I've looked at TMud and CoralMud and I think I understand each in theory but ultimately I'm probably just lost !
06 Nov, 2013, quixadhal wrote in the 2nd comment:
Votes: 0
Personally, if you're using ruby for your core, I'd either use ruby as your scripting language as well (so you can easily reuse code), or invent your own mini-language that does exactly (and only) what you want/need it to do for the purpose of content creation.

I see no value in embedding a different language, as then you just have to learn two languages, and support both. If you have builders who eventually want to help you with driver-level coding, they now have to learn a whole new language as well.

My own games are written in C (no scripting at all), and LPC (an LPMUD has everything in LPC softcode, with the driver only handling network I/O, file access, and a minimal API of utility routines called efuns). All game logic and things dealing with user logins, security, etc… are in LPC, and that is called a mudlib.
06 Nov, 2013, plamzi wrote in the 3rd comment:
Votes: 0
One thing I would definitely do is embrace the power of a scripted engine. I will certainly allow coders and trusted power builders to write unsecured, but also unlimited, scripts. It's not much work, and it opens the door to great creativity.

Beyond that, if you are certain you'll ever have a practical need for a sandbox, there are a number of approaches you can take:

Throwaway object is definitely a fairly easy option–the downside is often you want to allow a script to modify certain properties of the objects it is accessing (e. g. changing a player's location). Also, some people may be worried about it being resource-hungry.

Another option that comes to mind is to run new or modified scripts from untrusted builders in a test mode, and compare the original objects from before the script to the state of the throwaways after the script. If the script hasn't modified anything, it can go live. If it has, it ends up in a queue for review and approval.

A variant of the above is if you run the new script through some string checks that may be able to catch code that is deemed illegal / unsafe. I'm not sure how easy that would be in ruby. It may result in you having to define certain kinds of syntax that are allowed, or certain helper functions that have to be called for any modification, etc.

There's also the option of having a separate interpreted scripting engine. If you go that way, I would stick to ruby even if I had to roll my own, but I understand that you may be tempted to leverage something existing in Lua. Still, if that something is not to your liking, in the long run it may end up wasting more time than it saves.

Finally, this may come off as a bit impertinent, but if you're new to ruby, are you sure you want to start with a project this huge? Isn't there a codebase option that is closer to a playable game on which you can learn? Sometimes, understanding a scripting engine is a matter of running a game with one for a few years.
06 Nov, 2013, Davenge wrote in the 4th comment:
Votes: 0
Great advice so far, thank you. Lots to consider.

For me, Plamzi, I wanted to build my own engine as a project. I've come to learn that I'm enjoying coding more than playing and I wanted to add a new language to my repertoire. Two birds one stone. I've been using CoralMud and TMud as references as well as read through a ruby book and done some tutorials like RubyMonk stuff.

If I was truly hungry for a new game engine that would be up and ready in a short(er) amount of time, I could just do a C or C++ with Lua embedded and that would be that. But, for this, its an adventure and I'm enjoying it. This is an, "it's the journey, not the destination" thing for me.
06 Nov, 2013, Runter wrote in the 5th comment:
Votes: 0
Just depends on your goal. I've had experience doing this and researching it. It's not a straight forward topic and there's distinct advantages and disadvantages to be aware of.

Ruby core & Scripting Ruby:
Advantages: Learn one language, can reuse code, ruby is a good choice for high level scripting
Disadvantages: You basically can't sandbox it against untrusted users. You can put safeguards, but ruby isn't built to be used this way in unsafe environments without a lot of work. Projects like codepad.org and interactive ruby tutorials have learned this the hard way with downtime as a result of unsafe code being ran in their sandbox. You basically need to have trusted users, or have a plan for restoring your system on a whim. You also should run your program in a complete virtualized environment.

Ruby core & Scripting in Lua:
Advantages: It's possible to safely sandbox your environment. Some users will be more familiar because other systems use Lua. Like WoW. It's also not out of the box an object oriented language. Some people with little programming experience may be more familiar.

Disadvantages: More work to take advantage of sandboxing, difficult to know if something really is safe without solid unit tests. Two languages for development.